Fix coordinator stall on transient API errors (retry backoff unit + raise UpdateFailed) - #120
Open
QuintinHumphreys wants to merge 1 commit into
Conversation
Two defects in AquaTempAPI caused the coordinator to appear "stalled" (entities stop updating) after a transient cloud/API error, requiring a config-entry reload to recover: 1. Retry backoff used the wrong unit. `asyncio.sleep` takes SECONDS, but the retry delay was `await sleep(1000)` in both `_internal_update` and `_perform_action`. On any transient error the coordinator's update method blocked for 1000s per retry (up to ~33 min across API_MAX_ATTEMPTS=3), so entities looked frozen. Changed to `await sleep(1)` (1s backoff, the evidently intended value). 2. `_internal_update` swallowed the error after exhausting retries: it logged and returned normally, so `_async_update_data` returned stale data as a success. The DataUpdateCoordinator therefore never raised UpdateFailed, entities never went `unavailable`, and the failure was hidden. This is inconsistent with `_perform_action`, which re-raises after max attempts. Now re-raise so the coordinator reports UpdateFailed and HA's normal retry/backoff engages. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Problem
After a transient AquaTemp cloud/API error (or a failed poll around an HA restart), the climate + sensor entities stop updating and stay frozen until the config entry is reloaded. HA's
DataUpdateCoordinatoris meant to auto-retry on its interval, so a persistent stall points at the integration breaking that contract.There are two root causes in
managers/aqua_temp_api.py.1. Retry backoff uses the wrong time unit (1000 s instead of 1 s)
asyncio.sleeptakes seconds, but the retry delay isawait sleep(1000)in both_internal_updateand_perform_action:_async_update_dataawaits_internal_update, so a single transient error blocks the coordinator's update method for 1000 s per retry - up to ~33 minutes acrossAPI_MAX_ATTEMPTS = 3. During that window the entities look frozen. The value was evidently intended as a short (1 s) backoff.2.
_internal_updateswallows the error after exhausting retriesAfter the final attempt,
_internal_updateonly logs and returns normally, so_async_update_datareturns stale data as a success. The coordinator setslast_update_success = True, never raisesUpdateFailed, and the entities never gounavailable- the failure is completely hidden. This is also inconsistent with_perform_action, which correctly re-raises after max attempts.Fix
await sleep(1000)toawait sleep(1)._internal_updateafter the last attempt, so the coordinator's existingtry/exceptwraps it inUpdateFailedand HA's normal retry/backoff engages.Testing
Applied to a live install (single AquaTemp heat pump). After
ha core check+ restart the integration loads cleanly (config entry stateloaded), the API-status binary sensor ison, and temperature sensors report fresh live values on the normal poll interval. NoUpdateFailedor login errors in the log.🤖 Generated with Claude Code