Skip to content

Auto-detect TOU V1/V2 support from HMI firmware version (#20) - #24

Merged
fboundy merged 1 commit into
mainfrom
patch
Jul 3, 2026
Merged

fboundy merged 1 commit into
mainfrom
patch

Conversation

@fboundy

@fboundy fboundy commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

Stops asking the installer to manually toggle has_v2; detects it automatically from the inverter's HMI firmware version, on both protocols, following the same silent-override-after-validation pattern already used for automatic model detection.

  • Shared helper hmi_version_supports_v2() (helpers.py): threshold 0x4B00, accepts either the raw Modbus register integer or the SolisCloud hex string, returns None (undeterminable) rather than raising.
  • Modbus path: _validate_config reads register 33002 right after its existing connectivity probe (in its own try/except, so a flaky read never blocks/retries the connect attempt) and overrides has_v2 in place when determinate.
  • Cloud path: _validate_cloud_config now also calls async_inverter_detail to fetch hmiVersionAll, returning it as an added tuple element; all three call sites (cloud-only, dual-mode, reconfigure) apply the override the same way model already does.
  • Fallback: an undeterminable/failed read leaves the user's form choice untouched — never blocks setup.
  • Open UX question from the issue resolved as recommended: kept the has_v2 toggle visible, silently overridden after validation (matches model's existing precedent).

Test plan

  • tests/test_hmi_version_detection.py: pure helper (threshold boundary, hex/int input, undeterminable cases)
  • tests/test_config_flow.py: Modbus-path override + read-failure fallback
  • tests/test_cloud_integration.py: cloud-only, dual-mode, and reconfigure override paths (also added missing async_inverter_detail mocks to existing tests that now exercise this call)
  • Full suite: 308 passed
  • ruff check / ruff format --check clean

Closes #20

Adds a shared hmi_version_supports_v2() helper (threshold 0x4B00,
accepts either the raw Modbus register or the SolisCloud hex string).
The Modbus config-flow path reads register 33002 right after its
existing connectivity probe and overrides has_v2 in place; the cloud
path adds one async_inverter_detail call to fetch hmiVersionAll and
returns it alongside the existing detected_model. Both follow the
same silent-override-after-validation pattern already used for model
detection, and never block setup if the read fails or is
unparseable - the user's form choice survives untouched.

Fixes #20
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Failed to generate code suggestions for PR

@fboundy
fboundy merged commit 260a90a into main Jul 3, 2026
6 checks passed
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.

Auto-detect TOU V1/V2 support from HMI firmware version instead of manual toggle

1 participant