refactor(coordinator): _on_data hook — collapse 4 _async_update_data overrides - #13
Merged
Merged
Conversation
…te_data overrides Live/Price/Optimization/Notifications each duplicated the same 5-line skeleton: `data = await super()._async_update_data(); self._side_effect(data); return data`. Base coordinator now calls `await self._on_data(data)` after every successful fetch (default hook is a no-op). Each subclass keeps the same side-effect method (EMS repair, negative-price bus events, decision events, notification persist) and wires it via a 2-line `_on_data` override — the boilerplate goes away. No behavioural change: same fetch pipeline, same side effects fire in the same order, same errors surface as UpdateFailed via the base try/except. Suite green (226); live-verified on homie — integration loads clean, live + price coordinators refresh, no coordinator errors in the HA log. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
3 tasks
mrebbert
pushed a commit
that referenced
this pull request
Aug 12, 2026
Three PRs (#12/#13/#14) landed post-#11 with no user-visible change — document them under `[Unreleased] > Changed` so the eventual release captures them alongside the co2_saved_kg addition. Per feedback-release-notes-scope memory: refactor mentions stay in CHANGELOG only; release-notes/v0.1.53.md (when created at release time) stays user-facing. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
Third candidate from the post-0.1.53 refactor audit. Live/Price/Optimization/Notifications each duplicated the same 5-line skeleton:
```python
async def _async_update_data(self) -> T:
data = await super()._async_update_data()
self._side_effect(data)
return data
```
Base coordinator now calls `await self._on_data(data)` after every successful fetch (default is a no-op). Each subclass keeps its existing side-effect method (EMS repair, negative-price bus events, decision events, notification persist + Store) and wires it via a 2-line `_on_data` override.
Net −3 lines but the real win is uniformity: one documented extension point for "post-fetch side effects" instead of four copies of the same wrapper template.
Test plan
Notes