Skip to content

Bound GALEVO recovery and share HTTP 429 cooldowns - #199

Closed
waterfietser wants to merge 7 commits into
fustom:mainfrom
waterfietser:fix/issue-1-galevo-resilience
Closed

waterfietser wants to merge 7 commits into
fustom:mainfrom
waterfietser:fix/issue-1-galevo-resilience

Conversation

@waterfietser

Copy link
Copy Markdown

Background

When a GALEVO property batch fails with HTTP 500 or times out, recovery can fan out into pair requests, individual requests, and provider-cache lookups. During a cloud outage, this can turn one failed poll into dozens of additional requests. The existing HTTP 429 handler also retries after waiting, and its cooldown applies only to the API instance that received the response.

Changes

  • Keep the initial full property batch. Split failed batches within a budget of eight follow-up requests, four consecutive failures, or 15 seconds of recovery. Match properties by ID and zone to preserve multi-zone behavior.
  • End retries immediately on HTTP 429. Share a cooldown across synchronous and asynchronous clients for the same account and API origin. Honor Retry-After and the server’s reported block duration. When neither is usable, start at 60 seconds and double the fallback up to 15 minutes.
  • Retain the last accepted GALEVO snapshot and feature flags when a refresh fails. Partial or provider-cached recovery results leave the refresh unsuccessful, so callers such as Home Assistant can report the device as unavailable until a fresh snapshot is accepted.
  • Keep the existing polling cadence, requested properties, and menu refresh frequency.

Verification

All 98 library tests passed on Linux with Python 3.14.2. The Home Assistant integration suite also passed all 82 tests against the patched checkout. The tests cover request and time budgets, concurrent rate limits, multi-zone recovery, and state retention. Live validation on an ATAG ONE thermostat is still pending.

Reported in waterfietser/ariston-remotethermo-home-assistant-v3#1.

Comment thread ariston/ariston_api.py Resolved
Comment thread ariston/ariston_api.py Resolved
Comment thread ariston/galevo_device.py
(item.get("id"), item.get(PropertyType.ZONE))
for item in self.data.get("items", [])
}
if not keys or not previous_keys.issubset(keys):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scope snapshot completeness to the current zone configuration. After a heating zone is removed and async_get_features() returns the new zone list, subsequent complete property responses still fail this guard because the previous snapshot contains keys for the removed zone. Compare only keys that still apply to the current configuration.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0c93c36. The completeness guard compares previously reported keys for the currently configured zones, including device-wide zone 0. The regression test refreshes the features after removing zone 2 and verifies that the new snapshot is accepted.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apply the optional ChFlowTemp rule to snapshot validation. If the previous snapshot included ChFlowTemp, this guard still requires it on the next poll. I reproduced a heat-pump refresh where split recovery returned all 43 required properties and fresh menu item 349 supplied the flow temperature, yet the device rejected the snapshot. Use the same optional-property rule in both recovery and snapshot validation, and add a test where ChFlowTemp is present on one poll and absent on the next.

Comment thread ariston/galevo_device.py Resolved

@astrinh0 astrinh0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the comments

Comment thread ariston/galevo_device.py
(item.get("id"), item.get(PropertyType.ZONE))
for item in self.data.get("items", [])
}
if not keys or not previous_keys.issubset(keys):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apply the optional ChFlowTemp rule to snapshot validation. If the previous snapshot included ChFlowTemp, this guard still requires it on the next poll. I reproduced a heat-pump refresh where split recovery returned all 43 required properties and fresh menu item 349 supplied the flow temperature, yet the device rejected the snapshot. Use the same optional-property rule in both recovery and snapshot validation, and add a test where ChFlowTemp is present on one poll and absent on the next.

Comment thread ariston/galevo_device.py
self.custom_features.clear()
self.custom_features.update(previous_features)
raise
self.menu_items_fresh = menu_items is not None

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mark partial menu refreshes as stale. If a menu group request and an individual item retry both return HTTP 500, the API skips the failed item and returns the rest. I reproduced a previously available heat-pump outdoor temperature disappearing and its capability flag turning off while menu_items_fresh stayed True. Preserve the last value for previously seen items whose fetch failed, and mark the menu refresh stale.

Comment thread ariston/galevo_device.py

def _update_state(self) -> None:
"""Set custom features"""
if self.custom_features.get(CustomDeviceFeatures.HAS_OUTSIDE_TEMP) is None:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A partial first response that omits OutsideTemp sets HAS_OUTSIDE_TEMP to False for the session. A later response with a valid reading leaves the flag disabled. Leave the capability undecided when the row is missing so a later complete response can establish it. This is a pre existing issue, if you could fix it will be nice

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.

2 participants