Skip to content

fix(plan): widen forecast_minutes before building yesterday_load_step/yesterday_pv_step - #4419

Merged
springfall2008 merged 3 commits into
mainfrom
fix/history-yesterday-forecast-minutes-widen
Aug 3, 2026
Merged

fix(plan): widen forecast_minutes before building yesterday_load_step/yesterday_pv_step#4419
springfall2008 merged 3 commits into
mainfrom
fix/history-yesterday-forecast-minutes-widen

Conversation

@chalfontchubby

Copy link
Copy Markdown
Collaborator

Summary

  • The web plan "History" tab's Load kWh column reads 0 from ~6am onward every day, self-healing the next day - calculate_yesterday() built yesterday_load_step/yesterday_pv_step via step_data_history() while self.forecast_minutes was still the live plan's normal (too-small) horizon, so any offset past it silently read back as zero for the rest of the day.
  • Widens forecast_minutes before building those step-data dicts (the widening already existed later in the function, just applied too late), restoring it immediately after.
  • Added a regression test reproducing the exact real-world numbers that exposed this (forecast_plan_hours=30, minutes_now=910), verified it fails without the fix and passes with it.

Fixes #4418

Test plan

  • ./run_all --quick passes
  • New regression test (test_calculate_yesterday.py) fails on the pre-fix code, passes on the fix
  • run_pre_commit clean

…/yesterday_pv_step

calculate_yesterday() built these step-data dicts via step_data_history()
while self.forecast_minutes was still the live plan's normal horizon.
step_data_history() only fills offsets up to forecast_minutes + plan_interval_minutes,
but the web plan "History" tab needs a full yesterday (24h) plus today-so-far
up to minutes_now - so any offset past the live horizon silently read back
as zero Load/PV for the rest of the day (reproduced live: forecast_plan_hours=30,
Load kWh read 0 from ~06:00 onward every day, self-healing the next day).

The widening fix already existed later in the function, just applied too
late - after the step-data dicts were already built too small.

Fixes #4418

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an incorrect “History” view calculation path in calculate_yesterday() where yesterday_load_step/yesterday_pv_step could be built with a too-small forecast_minutes horizon, causing load/PV accumulation to silently fall back to zeros later in the day. It widens forecast_minutes earlier (before building the step-data dicts) and adds a regression test targeting the real-world reproduction parameters from issue #4418.

Changes:

  • Widen self.forecast_minutes before building yesterday_load_step / yesterday_pv_step, then restore it afterward.
  • Add a regression test that asserts forecast_minutes is already widened at the first step_data_history() call (and is restored after).
  • Document the rationale inline to prevent regressions.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
apps/predbat/output.py Widen/restore forecast_minutes earlier in calculate_yesterday() so History-mode step data covers “yesterday + today so far”.
apps/predbat/tests/test_calculate_yesterday.py Adds a regression test for issue #4418, validating the widening happens before step-data generation.

Comment thread apps/predbat/output.py Outdated
Comment thread apps/predbat/tests/test_calculate_yesterday.py Outdated
springfall2008 and others added 2 commits August 2, 2026 20:45
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@springfall2008
springfall2008 merged commit 48d7330 into main Aug 3, 2026
2 checks passed
@springfall2008
springfall2008 deleted the fix/history-yesterday-forecast-minutes-widen branch August 3, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Web plan 'History' tab: Load kWh column reads 0 from ~6am onward (self-heals the next day)

3 participants