Skip to content

Keep GALEVO data when one cloud request fails - #12

Merged
wojciech-aniol merged 2 commits into
mainfrom
galevo-read-errors
Nov 23, 2026
Merged

wojciech-aniol merged 2 commits into
mainfrom
galevo-read-errors

Conversation

@wojciech-aniol

@wojciech-aniol wojciech-aniol commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

One failing cloud request no longer makes every entity unavailable. An empty energy sequence gives None, a menu items 500/550 keeps the last menu items, and a GALEVO data items 500 is asked again in smaller parts (at most 4 extra requests per read; after 2 failed reads in a row the parts are kept 1 hour per gateway). Menu values that are errors or probe limit values (3276.0, 3276.7, -3276.8, -3277.0) are None. Covers fustom integration issues #514, #520, #492 / #525 and the menu check from fustom/python-ariston-api#195.

Changes

  • _get_consumption_sequence_last_value: None when v is empty or missing (#514: IndexError at the first energy update).
  • GALEVO update_state / async_update_state: a menu ConnectionException with status 500 or 550 logs a warning and keeps the last menu items; other errors still raise. The data items are no longer lost with it (#520).
  • get_properties / async_get_properties (#492 / #525):
    • After a 500 for the full request (it is still retried once after 5 s, as before), the item list is asked in halves. A half that answers 500 is split again (never below 2 items).
    • At most 4 part requests per read (owner's choice); part requests are not retried. Parts not asked within the limit and parts that fail are left out, with a warning.
    • Answers are merged into one {"items": [...]}. If no part answers, the first error is raised and nothing is kept.
    • The parts are kept only after 2 reads in a row with a 500 for the full request; a full answer resets the count. Then the part count that worked is kept in a module dict per (api_url, gateway) for 1 hour (owner's choice), and the full request is tried again. One 500 (a short cloud problem) asks in parts only for that read, so a busy cloud does not get twice the requests for an hour.
    • Never on 429 or other 4xx: those raise at once, also from a part. No useCache: true retry (upstream fix: issue 525 and issue 26 fustom/python-ariston-api#193 / #196 sends up to ~25 requests per poll).
  • _get_menu_item_by_id: for value, None when error is true, the value is None, or the value is one of the limit values above. Other keys (unit, options) are returned as before.
  • New public helper error_status(error) in ariston_api.py (HTTP status of a ConnectionException, or None).

Notes for review

  • The plan named "value equal to max or to a negative min" as the menu check. I used the fixed set of limit values instead: the owner's Nimbus has an enum menu item with value 1.0 and max 1.0, which that check would drop. Upstream fustom#195 also moved to the fixed set ("preserve boundary menu values").
  • A real 0.0 is kept (#539 does not prove zeros are a cloud marker).
  • Request cost on a gateway that always fails: the full request (2 HTTP requests with the built-in retry) plus up to 4 parts per read. Without a 500 a read still sends exactly 1 request (test_properties_without_error_send_one_request).
  • With 4 part requests the smallest part is about a quarter of the list (~11 of 44 items). Gateways that answer only for 1–2 items (fustom#492 reports) may still fail; going smaller needs a higher limit.
  • When the menu request fails at the first poll after setup there are no old items, so the menu sensors are not added until a reload.

Tests

Each new test fails on main (checked by running the new tests against the main code), except the guards that must already pass: one request without an error, no split for 401/403/502, menu 401 raises, 0.0 kept.

  • tests/test_ariston_api.py: halves merged; one read with a 500 does not keep the parts (also fail, ok, fail); two reads in a row keep them for 1 hour, then the full request again; a failed half split again within 4 part requests with no part retry; all parts fail (first error raised, nothing kept); 401/429 in a part raises at once.
  • tests/test_galevo_device.py: empty / missing v; menu 500/550 keeps old items (sync and async), 401 and no-status errors raise; menu limit values, error: true, None give None.

192 tests pass, ruff clean.

🤖 Generated with Claude Code

One failing cloud request made every entity unavailable:
- an empty consumption sequence raised IndexError in the energy update;
- a 500 from the menu items request failed the whole state update,
  though the data items were fine;
- some gateways answer 500 to the full data items request but not to
  smaller parts, so every poll failed.

Now an empty sequence gives None, a menu 500 or 550 keeps the last menu
items, and a data items 500 is asked again in halves (split again on
500) with at most 4 part requests per read. The part count is kept for
an hour per gateway. A menu value that is an error or a probe limit
value (3276.0, 3276.7, -3276.8, -3277.0) is None.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wojciech-aniol wojciech-aniol self-assigned this Nov 23, 2026
A single 500 can be a short cloud problem. Keeping the parts for an hour
after it doubled the requests per read for that hour, just when the
cloud was busy. Now one read with a 500 asks in parts only for itself;
the parts are kept after two reads in a row with a 500 for the full
request, and a full answer resets the count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wojciech-aniol
wojciech-aniol marked this pull request as ready for review November 23, 2026 10:06
@wojciech-aniol
wojciech-aniol merged commit 620a7d9 into main Nov 23, 2026
5 checks passed
@wojciech-aniol
wojciech-aniol deleted the galevo-read-errors branch November 23, 2026 10:06
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.

1 participant