Improve PumpSpy coordinator resiliency and daily totals handling#17
Open
aschoorl wants to merge 6 commits intoCrewski:mainfrom
Open
Improve PumpSpy coordinator resiliency and daily totals handling#17aschoorl wants to merge 6 commits intoCrewski:mainfrom
aschoorl wants to merge 6 commits intoCrewski:mainfrom
Conversation
Use Home Assistant’s UpdateFailed in the coordinator so transient auth or connection errors don’t clear data and mark entities unavailable. Replaces previous silent None return with explicit failure signaling (InvalidAccessToken, ConnectionError). No functional change on success; reduces unavailable state flapping during brief outages.
- keep a reference to the coordinator during unload so we can reach its API client - call `coordinator.api.async_close()` after platforms unload, releasing the shared aiohttp session we introduced for connection reuse - avoids lingering TCP sockets or warnings when a config entry is removed or reloaded
When the PumpSpy server returns HTTP 500, fetch_current_data returns None. Previously the coordinator passed this through, causing sensors to crash on attribute access and go unavailable until the next successful poll. Now _async_update_data raises UpdateFailed so Home Assistant's DataUpdateCoordinator preserves the last known good state instead of pushing None to entities. Also downgraded the transient 500 log from error to warning.
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
DataUpdateCoordinatorsurface fetch errors while keeping unload logic minimal.0when the API hasn’t published data yet.Testing
python -m compileall custom_components/pumpspy_ha/sensor.py