Skip to content

Make the SolisCloud API call timeout configurable (default unchanged at 10s) - #542

Open
calindragomir84 wants to merge 5 commits into
hultenvp:masterfrom
calindragomir84:configurable-api-timeout
Open

calindragomir84 wants to merge 5 commits into
hultenvp:masterfrom
calindragomir84:configurable-api-timeout

Conversation

@calindragomir84

Copy link
Copy Markdown

Problem

The timeout for a single SolisCloud API call is hard-coded to 10 seconds, in two places in
soliscloud_api.py (_get_data and the POST helper). When SolisCloud is slow — which it is under
load — calls are cut off before they return, and the integration reports No valid inverters found, login failed / No inverters found. The call is not being refused; it is not returning in time.

Measured today from a machine outside Home Assistant, using plain unsigned POSTs to
/v1/api/userStationList and /v1/api/inverterList (a healthy API rejects these instantly with
403 "Date can not be empty", so the round-trip cost is all server-side):

requests 24
responded 11 — median 9.03 s, max 14.21 s
no response within 15 s 12
502 Bad Gateway 1

Re-scored against the 10 s budget the integration actually allows, only 6 of 24 would have
completed. Five responses arrived between 12.1 s and 14.2 s — the API answered, just too late.

Response-time distribution, seconds: 1.7 · 2.8 · 4.5 · 6.2 · 7.8 · 9.0 · 12.1 · 12.2 · 12.6 · 12.9 · 14.2

Change

Adds a timeout option, exposed in the options flow next to refresh_ok / refresh_nok, and in
the initial setup step.

  • const.pyCONF_TIMEOUT, DEFAULT_TIMEOUT = 10
  • soliscloud_api.pySoliscloudConfig takes timeout: int = 10, exposes a timeout property,
    and both async_timeout.timeout(10) call sites become async_timeout.timeout(self.config.timeout)
  • __init__.py — reads the option, falls back to DEFAULT_TIMEOUT
  • config_flow.py — field in both the options flow and the initial step
  • translations/en.json — label

Default is 10, so behaviour is unchanged for anyone who does not set it. The constructor argument
is keyword-with-default, so existing callers keep working.

Testing

Running on Home Assistant 2026.9.1 against a live SolisCloud plant:

  • integration loads with no errors; no TypeError/KeyError on any code path exercised
  • the new field appears in the options form (integer, default 10) and the saved value persists
  • set to 30 and confirmed stored in the config entry

Like the existing refresh_ok / refresh_nok, the value is read when the entry is set up, so a
restart is needed for a change to take effect — consistent with the current
"Some changes require a restart of Home Assistant" note. Happy to add an update listener in a
separate PR if you'd like all three to apply without a restart.

Note

translations/en.json also loses one trailing space on the portal_password line — a side effect of
re-serialising the file, not an intentional change. Say the word and I'll restore it.

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