You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a769310
Browse filesBrowse the repository at this point in the historyBrowse files
fix(plan history): rebuild once per completed slot, and judge staleness by each view's own refresh interval
The plan page's History view is built by calculate_yesterday() from what actually happened, at most once every 59
minutes. The live Plan view starts at the current slot, so the slots finished since the last rebuild showed in
neither view: at 21:35 the History stopped at 20:30 and the Plan started at 21:30. And the page judged every view
against the live plan's 15-minute stale limit, so on the History view it warned "Plan data is stale" for about
45 minutes of every hour although nothing was wrong.
- calculate_yesterday() now rebuilds once per completed plan slot (plan_interval_minutes), on the first re-plan at
least one run (5 minutes) after the slot ends, so the boundary run's own cost_today write is recorded before
its history is read back. A rebuild takes 0.4-0.9 s on a live install; at the default 30-minute slots that is
48 a day instead of 24 (before #2913 it ran on every re-plan, about 144).
- Each dataset the page shows carries refresh_minutes, the longest Predbat should take to republish it (the live
plan: calculate_plan_every; the plan history: a slot, the run it waits and a re-plan interval). The page warns
a run after that, never under 15 minutes, against the data the current view shows, and hides the warning when
the view has no data. At the defaults: Plan 15 minutes (as before), History 50.
Trade-offs, kept: with calculate_plan_every at or above the slot length, re-plans can fall on slot boundaries
and the rebuild then happens there; cost_yesterday and savings_yesterday_* roll over at the first re-plan after
00:05 rather than at 00:00; cost_yesterday/savings_yesterday_predbat, with their large html/json attributes, are
written twice as often.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
self.log("Warn: Calculate yesterday: No history for {}.cost_today, so the savings and plan history can not be computed - check that Home Assistant is recording this entity (see the recorder notes in the FAQ)".format(self.prefix))
3206
-
# Record the attempt so this is retried on the normal hourly cadence rather than every cycle
3224
+
# Record the attempt so this is retried in the next slot rather than every cycle
0 commit comments