Skip to content

Rewrite integration on DataUpdateCoordinator with typed regulation setters#5

Open
patrickweh wants to merge 3 commits into
mainfrom
refactor/datacoordinator-rewrite
Open

Rewrite integration on DataUpdateCoordinator with typed regulation setters#5
patrickweh wants to merge 3 commits into
mainfrom
refactor/datacoordinator-rewrite

Conversation

@patrickweh

Copy link
Copy Markdown
Owner

Summary

  • Replace the inline polling hub with a PowerDogClient + DataUpdateCoordinator architecture so HA owns the update lifecycle and can mark the integration unavailable when the device is offline.
  • Parse the regulation Setable field and route writes through the correct parameter: ManualValue regulations are toggled via onoff, ManualSwitch/ManualAutoSwitch via manual. Switch state is read from OnOff or SwitchMode accordingly.
  • Read Min/Max for setable regulations so non-percent controls such as the PV surplus threshold (0-7000 W) work as numbers.
  • Keep non-setable regulations as read-only sensors so previously registered sensor.* entity ids survive the rewrite. unique_id patterns (powerdog_<key>, powerdog_switch_<key>, powerdog_number_<key>) are preserved.
  • Surface failures: the coordinator raises UpdateFailed and entity writes raise HomeAssistantError instead of silently logging. The client retries with a timeout, resets the XML-RPC connection on transport errors, and verifies set calls.
  • Drop the obsolete select platform; switches and numbers now cover ManualAutoSwitch regulations directly.

…tters

- Replace inline polling hub with PowerDogClient + DataUpdateCoordinator
- Parse Setable string and expose ManualValue (onoff) vs ManualSwitch / ManualAutoSwitch (manual) regulations as switches and numbers with the correct toggle parameter
- Honor regulation Min/Max so non-percent setables (e.g. PV surplus threshold) work
- Restore non-setable regulations as read-only sensors so existing entity ids survive
- Raise UpdateFailed and HomeAssistantError on API failures instead of silent fallbacks; client retries with timeout and resets the connection
- Drop obsolete select platform; preserve unique_id pattern (powerdog_{switch,number}_<key>)
…ch and number platforms

- Pure unit tests for the XML-RPC client (Setable parser, retry/backoff, typed setters)
- Integration tests via pytest-homeassistant-custom-component for entity registration, ManualValue (onoff) and ManualAutoSwitch (manual) toggle paths, number Min/Max wiring, and coordinator unavailability on PowerDogError
- Config flow happy path and connection-error rendering
- GitHub Actions workflow runs the suite on push and pull requests
PowerDog reports nan for calculated regulations such as 'Anforderung WP'
when idle. HA's numeric sensor rejects non-finite values, so the previous
implementation propagated a ValueError out of every coordinator update —
that bubbled up through async_request_refresh and turned every number set
service call into a 500 for the caller (e.g. EVCC). Map nan/inf to None so
the entity renders as unknown instead of crashing.
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