Skip to content

Auto-detect Modbus inverter serial number from device registers - #26

Merged
fboundy merged 2 commits into
mainfrom
patch
Jul 3, 2026
Merged

fboundy merged 2 commits into
mainfrom
patch

Conversation

@fboundy

@fboundy fboundy commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to issue #20 (HMI-version auto-detection), prompted by the question: why do we still ask for serial/model/firmware when they can be read from the device?

  • Firmware version: already auto-detected (Auto-detect TOU V1/V2 support from HMI firmware version instead of manual toggle #20).
  • Serial number (Modbus): registers 33004-33019 already hold the ASCII serial (used by the existing "Serial Number" sensor and the migrate-to-serial-id logic), but nothing read them during config-flow validation. _validate_config now reads them right after the HMI-version check and silently corrects a mistyped serial — hybrid models only, since grid/string inverters don't expose this register range. Never blocks setup if the read fails.
  • Serial number (Cloud): already fine — optional and auto-resolved when the plant has one inverter.
  • Model: not fixed here — register 33003 only decodes to a generic protocol/family description, not a precise match to a SOLIS_INVERTERS catalog entry. Needs a new mapping table seeded from live user reports (same constraint as the existing SolisCloud product-code table). Filed as Auto-detect inverter model from Modbus register 33003 (no mapping table exists yet) #25.

Test plan

  • tests/test_config_flow.py: new test_flow_user_device_serial_overrides_typed_serial and test_flow_user_grid_model_skips_serial_detection; updated the two HMI-version tests to also assert the serial stays untouched when no serial data is available
  • tests/test_cloud_integration.py: fixed a blanket async_read_input_register mock that was incidentally feeding the new serial read garbage data (return_value=[1] decodes to a stray control character)
  • Full suite: 310 passed
  • ruff check / ruff format --check clean

Registers 33004-33019 already held the ASCII serial (used by the
"Serial Number" sensor and the migrate-to-serial-id logic) but
nothing read them during initial config-flow validation. _validate_config
now reads them after the HMI-version check, for hybrid models only
(grid/string inverters don't expose this range), and silently
corrects a mistyped serial the same way model/has_v2 detection
already work - never blocking setup if the read fails.

Filed model auto-detection (register 33003) as a separate issue since
it needs a new byte-code-to-model mapping table with no live data to
seed it yet, unlike this and the already-shipped has_v2 detection.
@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 77606de 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.

1 participant