Skip to content

fix: weather coordinator stopped polling after startup + zero-grid non-happy-flow hardening#95

Merged
bvweerd merged 4 commits into
devfrom
claude/zero-grid-controller-review-2est5s
Jul 14, 2026
Merged

fix: weather coordinator stopped polling after startup + zero-grid non-happy-flow hardening#95
bvweerd merged 4 commits into
devfrom
claude/zero-grid-controller-review-2est5s

Conversation

@bvweerd

@bvweerd bvweerd commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Description

Fixes the reported issue that the weather coordinator keeps showing "OK" while its data is half a day old, plus three non-happy-flow findings from a review of the zero-grid controller.

Weather coordinator (root cause of the stale-data report): a DataUpdateCoordinator only keeps polling while it has listeners, and nothing subscribed to the WeatherDataCoordinator — so it fetched open-meteo data exactly once at startup and then served the same aging snapshot forever, while last_update_success stayed True ("OK" in diagnostics and the simulator).

  • ForecastCoordinator now subscribes to the weather coordinator, which (re)starts its 30-min polling and recomputes forecasts as soon as fresh weather data arrives
  • Removed the no-op async_shutdown override in WeatherDataCoordinator so the polling timer is properly cancelled on unload; Forecast- and OptimizationCoordinator now also call super().async_shutdown()
  • New repair issue weather_data_stale (en+nl) when weather data is older than 2 h, cleared automatically on recovery; nl.json also gained the previously missing issue translations
  • Diagnostics now include age_minutes + stale for the weather block and age_minutes for the forecast block
  • Simulator coordinator-status badge shows "Stale (x h old)" instead of "OK", with a timestamp fallback for older diagnostics dumps

Zero-grid controller non-happy flows:

  • _get_realtime_grid_w returns None when all configured power sensors are unavailable/unreadable, instead of a fictitious 0 W (realtime loop holds the setpoint; the 15-min run falls back to the forecast-based grid estimate)
  • Stale-sensor detection now covers all configured consumption and production power sensors (previously only the first consumption sensor) and uses last_reported instead of last_updated, so a live push sensor with a constant value (e.g. production at 0 W overnight) is not misclassified as stale; unavailable sensors are skipped since they are already excluded from the grid sum
  • Removed dead ZeroGridControllerConfig.priority and the unused CONF/DEFAULT_ZERO_GRID_PRIORITY constants

Note: the stale-detection change touches the same block that #94 restructures; whichever merges second needs a trivial rebase (#94's flag can be set via self._find_stale_power_sensor(stale_limit_s) is not None). The two changes are complementary: last_reported fixes false staleness for push sensors, #94's toward-zero guard covers on-change-only sources.

Type of change

  • fix: Bug fix (patch version bump)

Checklist

  • Commit title follows Conventional Commits (feat:, fix:, chore:, etc.)
  • Tests added or updated where applicable (8 new tests, 3 updated)
  • Documentation updated if needed (docs/index.html simulator badge)
  • CI is green
  • PR targets the dev branch (not main, unless this is a hotfix)

Screenshots / Logs (optional)

🤖 Generated with Claude Code

https://claude.ai/code/session_01RGaWy7zvSo8ZyRxbypmTBu


Generated by Claude Code

claude added 3 commits July 14, 2026 07:10
…K on stale data

A DataUpdateCoordinator only keeps polling while it has listeners, and no
entity or coordinator subscribed to WeatherDataCoordinator. It therefore
fetched open-meteo data exactly once at startup and served the same aging
snapshot forever, while last_update_success stayed True — so diagnostics
and the simulator showed 'OK' on data that was half a day old.

- ForecastCoordinator now subscribes to the weather coordinator, which
  (re)starts its 30-min polling and recomputes forecasts as soon as fresh
  weather data arrives
- Removed the no-op async_shutdown override in WeatherDataCoordinator so
  the base class properly cancels the polling timer on unload; Forecast-
  and OptimizationCoordinator now also call super().async_shutdown()
- New repair issue 'weather_data_stale' (en+nl) when weather data is older
  than 2 h; cleared automatically on recovery
- Diagnostics now include age_minutes + stale for the weather block and
  age_minutes for the forecast block
- Simulator coordinator-status badge shows 'Stale (x h old)' instead of
  'OK' for stale weather data, with a timestamp fallback for old dumps
- nl.json: added missing issue translations

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RGaWy7zvSo8ZyRxbypmTBu
… coverage, dead config

- _get_realtime_grid_w now returns None when all configured power sensors
  are unavailable/unreadable, instead of a fictitious 0 W. The realtime
  loop then holds the setpoint and the 15-min optimizer run falls back to
  the forecast-based grid estimate rather than acting on a fake balanced
  grid.
- Stale-sensor detection in the realtime loop now covers all configured
  consumption AND production power sensors (previously only the first
  consumption sensor), and uses last_reported instead of last_updated:
  a live push sensor with a constant value (e.g. production at 0 W all
  night) only advances last_reported, so checking last_updated would flag
  every steady sensor as stale and block the realtime loop. Unavailable
  sensors are skipped — they are already excluded from the grid sum.
- Removed dead ZeroGridControllerConfig.priority and its unused
  CONF/DEFAULT_ZERO_GRID_PRIORITY constants (never referenced by any
  logic, config flow, or translation).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RGaWy7zvSo8ZyRxbypmTBu
Combines #94's per-mode stale handling (toward-zero unwind in zero_grid)
with this branch's broader staleness detection: the grid_sensor_stale flag
is now computed by _find_stale_power_sensor, which covers all configured
consumption and production power sensors and uses last_reported instead of
last_updated (a live push sensor with a constant value is not flagged;
on-change-only sources still rely on #94's toward-zero guard).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RGaWy7zvSo8ZyRxbypmTBu
@github-actions github-actions Bot added documentation Improvement or addition to documentation enhancement New feature or improvement bug Something isn't working as expected labels Jul 14, 2026
dt_util.utcnow() is untyped under follow_imports=silent, making the age
expression Any. Narrow the timestamp with isinstance(datetime) and type
the intermediate result explicitly.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RGaWy7zvSo8ZyRxbypmTBu
@bvweerd
bvweerd merged commit 4e78331 into dev Jul 14, 2026
6 checks passed
@bvweerd
bvweerd deleted the claude/zero-grid-controller-review-2est5s branch July 14, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working as expected documentation Improvement or addition to documentation enhancement New feature or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants