Skip to content

Improve GX device config flow - #483

Merged
tomer-w merged 5 commits into
tomer-w:mainfrom
philipptrenz:main
Aug 14, 2026
Merged

Improve GX device config flow#483
tomer-w merged 5 commits into
tomer-w:mainfrom
philipptrenz:main

Conversation

@philipptrenz

Copy link
Copy Markdown
Contributor
  • Add SSDP detection of X_MqttTokenPairing from GX device discovery
  • Add automatic token pairing flow: when a GX device advertises token pairing support, retrieve MQTT credentials via HTTPS POST to /auth/generate-token/ instead of prompting for manual password entry
  • Show pairing instructions in the UI, prompting the user to enable pairing mode on the GX device before submitting
  • Try SSL (port 8883) first during SSDP discovery, fall back to plain MQTT (port 1883) if unavailable
  • Simplify SSDP auth form: hardcode username to remoteconsole, rename password field to "GX Password", default SSL to on
  • Add second SSDP matcher for X_MqttTokenPairing=1 so discovery triggers even when X_MqttOnLan is disabled; issuing a token automatically enables "Paired devices only" access on the GX
  • Add PairingError exception and pairing_failed error string
  • Add CONF_MQTT_TOKEN_PAIRING constant, stored in config entry data when token pairing is used
  • Add translations for all new UI elements in en, de, fr, ca, sk
  • Add tests for token pairing success, HTTP error, connection error, MQTT validation failure, and fallback to manual auth

Note: The translations for fr, ca, and sk were generated automatically and should be reviewed.

Comment thread custom_components/victron_mqtt/config_flow.py Outdated
Comment thread custom_components/victron_mqtt/config_flow.py Outdated
@philipptrenz
philipptrenz marked this pull request as draft August 13, 2026 13:30
@philipptrenz
philipptrenz force-pushed the main branch 2 times, most recently from 331b6d4 to 1b211a0 Compare August 13, 2026 16:05
@philipptrenz
philipptrenz marked this pull request as ready for review August 13, 2026 16:06
Comment thread custom_components/victron_mqtt/config_flow.py Outdated
- Add SSDP detection of X_MqttTokenPairing from GX device discovery
- Add automatic token pairing flow: when a GX device advertises token pairing support, retrieve MQTT credentials via HTTPS POST to /auth/generate-token/ instead of prompting for manual password entry
- Show pairing instructions in the UI, prompting the user to enable pairing mode on the GX device before submitting
- Try SSL (port 8883) first during SSDP discovery, fall back to plain MQTT (port 1883) if unavailable
- Simplify SSDP auth form: hardcode username to remoteconsole, rename password field to "GX Password", default SSL to on
- Add second SSDP matcher for X_MqttTokenPairing=1 so discovery triggers even when X_MqttOnLan is disabled; issuing a token automatically enables "Paired devices only" access on the GX
- Add PairingError exception and pairing_failed error string
- Add CONF_MQTT_TOKEN_PAIRING constant, stored in config entry data when token pairing is used
- Add translations for all new UI elements in en, de, fr, ca, sk
- Add tests for token pairing success, HTTP error, connection error, MQTT validation failure, and fallback to manual auth
Comment thread custom_components/victron_mqtt/config_flow.py Outdated
@tomer-w
tomer-w merged commit e742a40 into tomer-w:main Aug 14, 2026
6 checks passed
@tomer-w

tomer-w commented Aug 14, 2026

Copy link
Copy Markdown
Owner

If you want to allow better granularity of the error handling, it should be vmby defining different exceptions in the library or by better text for the current exceptions. It should "leak" the http exceptions outside if the library call.

Also, you should probably improve the README.md here as well.

I'm approving this PR but feel free to continue improving this.

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.

2 participants