Skip to content

Commit 887dc64

Browse files
fix(plan history): use RUN_EVERY, not PREDICT_STEP, for the one-run wait
history_slot() and history_refresh_minutes() wait one run past a slot boundary, and their docstrings call that run PREDICT_STEP. One run is RUN_EVERY in const.py; PREDICT_STEP is the prediction step. Both are 5 today, so nothing changes now, but if either changed the wait would quietly be wrong. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent a769310 commit 887dc64

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎apps/predbat/output.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from html import escape as escape_html
2222
from datetime import timedelta
2323
from predbat import THIS_VERSION_DISPLAY
24-
from const import TIME_FORMAT, PREDICT_STEP, EXPORT_LIMIT_IDLE, MINUTE_WATT, FULL_EXPORT_POWER, EXPORT_MODE_TARGET, EXPORT_MODE_FREEZE, EXPORT_MODE_IDLE, CHARGE_STATE_PRECEDENCE, EXPORT_STATE_PRECEDENCE
24+
from const import TIME_FORMAT, PREDICT_STEP, RUN_EVERY, EXPORT_LIMIT_IDLE, MINUTE_WATT, FULL_EXPORT_POWER, EXPORT_MODE_TARGET, EXPORT_MODE_FREEZE, EXPORT_MODE_IDLE, CHARGE_STATE_PRECEDENCE, EXPORT_STATE_PRECEDENCE
2525
from utils import dp0, dp1, dp2, dp3, calc_percent_limit, minute_data, minute_data_state, find_charge_rate, export_mode_of, export_target_of, export_power_of, export_limit_sort_key, pack_export_limit, export_limit_from_stored
2626
from prediction import Prediction
2727

@@ -3189,18 +3189,18 @@ def plan_row_holding_for_car(self, minute_start, minute_end, car_hold_minutes=No
31893189
def history_slot(self, when):
31903190
"""Which plan slot the plan history rebuild at when counts towards, as (date, slot number from midnight).
31913191
3192-
Slots are plan_interval_minutes long, shifted one run (PREDICT_STEP) later: the run at a slot boundary
3192+
Slots are plan_interval_minutes long, shifted one run (RUN_EVERY) later: the run at a slot boundary
31933193
writes predbat.cost_today seconds before calculate_yesterday() reads its history back from Home
31943194
Assistant, so the slot just finished is rebuilt on the next run, once that value is recorded. This only
31953195
helps when that next run re-plans; with calculate_plan_every at or above the slot length, re-plans can
31963196
fall on boundaries and the rebuild then happens there.
31973197
"""
3198-
when = when - timedelta(minutes=PREDICT_STEP)
3198+
when = when - timedelta(minutes=RUN_EVERY)
31993199
return when.date(), (when.hour * 60 + when.minute) // self.plan_interval_minutes
32003200

32013201
def history_refresh_minutes(self):
32023202
"""The longest the plan history should go between rebuilds: a slot, the run it waits, and up to one re-plan interval."""
3203-
return self.plan_interval_minutes + PREDICT_STEP + self.calculate_plan_every
3203+
return self.plan_interval_minutes + RUN_EVERY + self.calculate_plan_every
32043204

32053205
def calculate_yesterday(self):
32063206
"""

0 commit comments

Comments
 (0)