Skip to content

Make LoadML and temperature coverage follow forecast_hours - #5398

Open
jacobidsmith wants to merge 3 commits into
springfall2008:mainfrom
jacobidsmith:loadml-forecast-hours
Open

jacobidsmith wants to merge 3 commits into
springfall2008:mainfrom
jacobidsmith:loadml-forecast-hours

Conversation

@jacobidsmith

Copy link
Copy Markdown

LoadML currently stops at 48 hours even when the existing YAML forecast_hours setting requests a longer forecast. With ML selected as the load source, this leaves the later plan without ML load data.

This change makes LoadML predictions and the future temperature coverage in the LoadMLPower chart follow forecast_hours, without adding another configuration setting.

Changes

  • Use forecast_hours to calculate the number of five-minute LoadML prediction steps.
  • Preserve the existing 24-hour minimum, 48-hour default, and integer configuration behaviour.
  • Preserve the original blending schedule through 48 hours, then retain a 50% ML / 50% historical blend beyond 48 hours.
  • Update prediction logs and saved metadata to reflect the actual forecast duration.
  • Keep existing saved models compatible, with no changes to training or model architecture.
  • Extend standard Open-Meteo temperature requests to cover the configured horizon, accounting for their midnight start and 16-calendar-day maximum.
  • Refresh cached temperature forecasts when they are too short for the requested horizon.
  • Preserve explicitly configured date ranges and other weather providers.
  • Retain the existing logged last-known-value fallback when future temperature or rate data runs out.

The separate Plan forecast hours helper remains unchanged.

Validation

  • The repository quick regression suite passed.
  • The slow LoadML training and persistence test group passed all 34 subtests separately.
  • All 14 configured pre-commit hooks passed.
  • Added tests cover prediction lengths, shared prediction stability, blending, saved-model compatibility, chart cutoffs, temperature request limits, and cache refresh.
  • Live Home Assistant testing followed 96 → 24 → 31 → 168 → 412 → 96 hours. LoadML generated the expected 1,152 → 288 → 372 → 2,016 → 4,944 → 1,152 prediction steps.
  • Both LoadML charts followed the configured horizon, and subsequent plan runs consumed the forecasts and completed without new exceptions.
  • The 412-hour run exercised the weather-provider limit and input fallback. Scheduled fine-tuning produced another complete forecast, and the saved model subsequently loaded successfully at 96 hours.

These live checks validate forecast generation and consumption, rather than long-range prediction accuracy. Exact published timestamp coverage, every later plan row, and long-run midnight behaviour were not independently verified. The remaining slow test groups (plan_preclip, annual_integration, and ml_training_perf) were not run.

@jacobidsmith

Copy link
Copy Markdown
Author

Added a follow-up fix so available future temperature and rate data are retained across forecast_hours, even when load or PV history is shorter.

Added regression coverage for short-history cases, including forecasts up to 412 hours, and updated the remaining fixed-48-hour documentation. LoadML rollout, training/persistence, and temperature tests passed, along with checks for the changed files.

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.

Copilot review overview

🟡 Changes recommended

Failed temperature refreshes can suppress usable cached data, and initial saved metadata can record the wrong horizon.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Extends LoadML and temperature coverage to follow forecast_hours while retaining existing model compatibility and blending behaviour.

Changes:

  • Makes LoadML rollout length configurable.
  • Extends Open-Meteo requests, cache validation, and chart coverage.
  • Adds regression tests and updates documentation.
File Description
docs/​load-ml.md Documents configurable forecast horizons.
docs/​components.md Updates LoadML component documentation.
apps/​predbat/​web.py Aligns chart temperature coverage.
apps/​predbat/​tests/​test_temperature.py Tests weather horizon and cache refresh.
apps/​predbat/​tests/​test_load_ml_rollout.py Tests configurable ML rollouts.
apps/​predbat/​temperature.py Extends weather requests and validates caches.
apps/​predbat/​load_predictor.py Generates variable-length forecasts.
apps/​predbat/​load_ml_component.py Propagates horizon configuration and inputs.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread apps/predbat/load_predictor.py Outdated
Comment thread apps/predbat/temperature.py

This branch has not been deployed

No deployments
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.

2 participants