fix: weather coordinator stopped polling after startup + zero-grid non-happy-flow hardening#95
Merged
Merged
Conversation
…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
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
DataUpdateCoordinatoronly keeps polling while it has listeners, and nothing subscribed to theWeatherDataCoordinator— so it fetched open-meteo data exactly once at startup and then served the same aging snapshot forever, whilelast_update_successstayedTrue("OK" in diagnostics and the simulator).ForecastCoordinatornow subscribes to the weather coordinator, which (re)starts its 30-min polling and recomputes forecasts as soon as fresh weather data arrivesasync_shutdownoverride inWeatherDataCoordinatorso the polling timer is properly cancelled on unload; Forecast- and OptimizationCoordinator now also callsuper().async_shutdown()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 translationsage_minutes+stalefor the weather block andage_minutesfor the forecast blockZero-grid controller non-happy flows:
_get_realtime_grid_wreturnsNonewhen 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)last_reportedinstead oflast_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 sumZeroGridControllerConfig.priorityand the unusedCONF/DEFAULT_ZERO_GRID_PRIORITYconstantsNote: 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_reportedfixes 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
feat:,fix:,chore:, etc.)devbranch (notmain, unless this is a hotfix)Screenshots / Logs (optional)
—
🤖 Generated with Claude Code
https://claude.ai/code/session_01RGaWy7zvSo8ZyRxbypmTBu
Generated by Claude Code