Skip to content

Allow integration setup when no inverters are found, with inverter discovery retry if 0 inverters are found.#531

Open
Cerbrus wants to merge 7 commits intohultenvp:masterfrom
Cerbrus:master
Open

Allow integration setup when no inverters are found, with inverter discovery retry if 0 inverters are found.#531
Cerbrus wants to merge 7 commits intohultenvp:masterfrom
Cerbrus:master

Conversation

@Cerbrus
Copy link
Copy Markdown

@Cerbrus Cerbrus commented Apr 3, 2026

Summary

  • Separates API failures from empty inverter lists in login() / fetch_inverter_list(), so valid credentials with 0 inverters no longer show a misleading "Cannot login" error
  • Registers the integration when credentials are valid but no inverters exist, logging a warning instead
  • Fetches the station name from the station detail API when no inverters are available
  • Adds a configurable refresh_inverter_discovery interval (default 300s) that retries inverter discovery when the list is empty

Bonus fixes

  • Retains form field values when the config flow displays a validation error, as the whole popup used to completely reset on error
  • Fixes config flow API Key Secret field showing "00" as default value
  • Fixes missing _plant_name attribute on SoliscloudAPI (not initialized in __init__)

Details

  • fetch_inverter_list() now raises SoliscloudApiError on API failures, and returns an empty dict on success with no records
  • login() catches SoliscloudApiError → returns False (auth error), empty dict → returns True (success, no inverters)
  • When no inverters are found, login() fetches the station name via _get_station_details()
  • async_update() detects an empty inverter list, logs out, and schedules a retry after the configured discovery interval
  • New CONF_REFRESH_INVERTER_DISCOVERY config option added to both setup and options flows
  • Config flow form defaults now use the previous user_input values when re-displaying after an error

Test plan

I've tested the checked items manually. The unchecked items require a working inverter/datalogger connection to verify, which I don't currently have. The installer hasn't fixed my setup, yet (that's the situation that prompted this fix).

  • Configure integration with valid credentials but no inverters → should succeed with a warning
  • Configure integration with invalid credentials → should still show auth error
  • With no inverters, verify re-discovery triggers after the configured interval
  • Connect an inverter and verify it gets picked up on the next discovery cycle
  • Verify existing setups with inverters are unaffected
  • Trigger a validation error and verify all fields retain their values
  • Verify Secret/Key ID fields no longer show "00" on first load

Cerbrus added 7 commits April 3, 2026 23:02
Previously, login() treated an empty inverter list as a login failure,
blocking integration setup entirely. This separates API errors (which
raise SoliscloudApiError) from a successful API response with zero
inverters, allowing the config entry to be created.

When no inverters are available, the service logs out and retries
discovery on a configurable interval (refresh_inverter_discovery,
default 300s) until inverters appear.

Also fixes the Secret/Key ID config fields showing "00" as a default
value by using None instead of empty string.

Fixes hultenvp#530
Previously, all fields in the credentials step were reset to their
defaults when a validation error occurred, forcing the user to re-enter
everything. Now the form is re-populated with the previously submitted
values.
If no inverters are found, the integration falls back to the Station ID
for the name, but we can load station details
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