Skip to content

Commit

Permalink
Fix bug with 'today' field in iboost_best (#1386)
Browse files Browse the repository at this point in the history
* Fix bug with 'today' field in iboost_best

#1378

* [pre-commit.ci lite] apply automatic fixes

* Update custom-dictionary-workspace.txt

---------

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
  • Loading branch information
springfall2008 and pre-commit-ci-lite[bot] authored Aug 24, 2024
1 parent e155ed2 commit 9a1ff83
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions .cspell/custom-dictionary-workspace.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ pytz
rarr
Redownload
remotecontrol
resetmidnight
resultmid
rname
rowspan
Expand Down
6 changes: 4 additions & 2 deletions apps/predbat/predbat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2066,12 +2066,14 @@ def find_charge_window_optimised(self, charge_windows):
charge_window_optimised[minute] = window_n
return charge_window_optimised

def filtered_today(self, time_data):
def filtered_today(self, time_data, resetmidnight=False):
"""
Grab figure for today (midnight)
"""
today = self.midnight_utc
tomorrow = today + timedelta(days=1)
if resetmidnight:
tomorrow = tomorrow - timedelta(minutes=PREDICT_STEP)
tomorrow_stamp = tomorrow.strftime(TIME_FORMAT)
tomorrow_value = time_data.get(tomorrow_stamp, None)
return tomorrow_value
Expand Down Expand Up @@ -2633,7 +2635,7 @@ def run_prediction(self, charge_limit, charge_window, discharge_window, discharg
state=self.dp2(final_iboost_kwh),
attributes={
"results": self.filtered_times(predict_iboost),
"today": self.filtered_today(predict_iboost),
"today": self.filtered_today(predict_iboost, resetmidnight=True),
"friendly_name": "Predicted iBoost energy best",
"state_class": "measurement",
"unit_of_measurement": "kWh",
Expand Down

0 comments on commit 9a1ff83

Please sign in to comment.