Make the SolisCloud API call timeout configurable (default unchanged at 10s) - #542
Open
calindragomir84 wants to merge 5 commits into
Open
calindragomir84 wants to merge 5 commits into
calindragomir84 wants to merge 5 commits into
Conversation
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
The timeout for a single SolisCloud API call is hard-coded to 10 seconds, in two places in
soliscloud_api.py(_get_dataand the POST helper). When SolisCloud is slow — which it is underload — 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/userStationListand/v1/api/inverterList(a healthy API rejects these instantly with403 "Date can not be empty", so the round-trip cost is all server-side):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
timeoutoption, exposed in the options flow next torefresh_ok/refresh_nok, and inthe initial setup step.
const.py—CONF_TIMEOUT,DEFAULT_TIMEOUT = 10soliscloud_api.py—SoliscloudConfigtakestimeout: int = 10, exposes atimeoutproperty,and both
async_timeout.timeout(10)call sites becomeasync_timeout.timeout(self.config.timeout)__init__.py— reads the option, falls back toDEFAULT_TIMEOUTconfig_flow.py— field in both the options flow and the initial steptranslations/en.json— labelDefault 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:
TypeError/KeyErroron any code path exercisedLike the existing
refresh_ok/refresh_nok, the value is read when the entry is set up, so arestart 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.jsonalso loses one trailing space on theportal_passwordline — a side effect ofre-serialising the file, not an intentional change. Say the word and I'll restore it.