Skip to content

Back off on 429 without block duration; throttle GALEVO hybrid menu items - #202

Closed
rudelafuente wants to merge 3 commits into
fustom:mainfrom
rudelafuente:fix/429-backoff-and-hybrid-menu-throttle
Closed

rudelafuente wants to merge 3 commits into
fustom:mainfrom
rudelafuente:fix/429-backoff-and-hybrid-menu-throttle

Conversation

@rudelafuente

Copy link
Copy Markdown

Problem

Since fustom/ariston-remotethermo-home-assistant-v3#530, heat pump and hybrid GALEVO systems request four extra menu-item groups on every state refresh (more when the per-item fallback runs). With the default 180 s interval that is roughly 120–280 requests/hour per account. Ariston then answers 429 Requests are blocked without a block duration. In that case the client waits 5 s, retries, and every coordinator keeps polling, so the block never expires (fustom/ariston-remotethermo-home-assistant-v3#545). The block is account-wide: the official Ariston NET app stops working too.

Changes

  • A 429 without a parsable duration no longer retries. All requests of the API instance pause for 15 min, doubling up to 2 h while the block persists. A successful response resets the pause. 429s with a parsed duration keep the current sleep-and-retry-once behaviour.
  • GALEVO hybrid/heat pump menu items are requested at most every 30 min. Core menu items are still refreshed every poll, and the last hybrid values are kept in between.

Tests

  • New tests cover the backoff (doubling, cap, reset after success, sync path) and the hybrid throttle.
  • test_429_without_parsable_body is updated to the new behaviour. One heat pump test now marks the hybrid refresh as due before its second refresh.
  • python -m unittest discover passes, with 99 % coverage.

Tested against mocked responses. I'm running the same logic as a local patch on a GALEVO heat pump (NIMBUS) and will report request rates in #545 once the account block clears.

🤖 Generated with Claude Code

…tems

Heat pump and hybrid GALEVO systems request four extra menu-item groups on
every state refresh (more when the per-item fallback runs), which exhausts
Ariston's per-account request budget. Ariston then answers "429 Requests are
blocked" without a duration; the 5 s fallback retry and the coordinators'
regular polling keep the account blocked indefinitely.

- A 429 without a parsable duration no longer retries: every request of the
  API instance pauses for 15 minutes, doubling up to 2 hours while the block
  persists. A successful response resets the pause. A 429 with a parsed
  duration keeps the sleep-and-retry-once behaviour.
- GALEVO hybrid/heat pump menu items are requested at most every 30 minutes;
  the last values are kept in between.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread ariston/ariston_api.py Resolved
Comment thread tests/test_galevo_device.py Resolved
…ttle only after a fetch

Review feedback on fustom#202:

- A parsed 429 no longer shortens a longer pause that is already active: it
  neither waits nor retries in that case, and the retry after waiting out a
  block is skipped if a longer pause started meanwhile.
- Retries (405 re-login, 5xx) now go through the pause check, so an in-flight
  500 cannot retry into a pause started by another response.
- A 429 without a duration that was in flight when the pause began does not
  double the pause again, and an in-flight success does not reset the backoff.
- The 30-minute hybrid menu window starts only once the hybrid items were
  fetched and stored. A poll skipped by a 429 pause, a retained server error or
  a failed properties request no longer delays the next attempt.

Adds concurrency tests (two requests in flight, responses released in order)
for the async path, sync twins, and regression tests for the hybrid window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Remper1997

Copy link
Copy Markdown

Request-volume data that may help compare this PR with #200, both of which address fustom/ariston-remotethermo-home-assistant-v3#545.

Not live-tested on this PR. I simulated it with the same harness for both PRs: the real AristonAPI + AristonGalevoDevice, a fake HTTP session counting requests, and a GALEVO pure heat pump (hpSys: true). 10 polls, 10 minutes apart:

requests per poll total in 100 min
current main 6, 6, 6, … 60
#200 6, then 2 24
this PR 2, but 6 every 30 min 36

Live context from the same installation (GALEVO pure heat pump, gateway firmware 104.115.22C, HA 2026.11.0) while testing #200:

  • With 2 requests per poll at a 600 s interval, polls succeeded without 429 for the period I could observe.
  • A separate client that sent ~10 requests within ~20 s got 429 Requests are blocked (no duration), while Home Assistant's own polling kept working. The budget looks very small and possibly per session/token.

Hybrid values going stale for up to 30 min is less of a concern than request volume on this unit. Still, the counts above suggest that caching the discovered ids (as #200 does) saves more requests than throttling the groups.

@rudelafuente

Copy link
Copy Markdown
Author

Thanks for the numbers, Remper1997, that's a useful comparison. Caching the discovered ids, as #200 does, clearly saves more requests than throttling the groups, and #200 came first.

If astrinh0 prefers to take #200, I'm happy to close this one. Whatever lands first and fixes fustom/ariston-remotethermo-home-assistant-v3#545 is what matters. Two parts of this PR may still be worth reusing:

  • the in-flight handling: an active pause can't be shortened, and retries (405/5xx) go through the pause check;
  • its concurrency tests, which keep two requests in flight and release their responses in order.

I'll add our live data from a night without 429s on #200.

@astrinh0

Copy link
Copy Markdown
Collaborator

Do you prefer to merge #200? If so close this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants