Skip to content

Add MQTT token pairing for GX device - #126

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

Add MQTT token pairing for GX device#126
tomer-w merged 5 commits into
tomer-w:mainfrom
philipptrenz:main

Conversation

@philipptrenz

Copy link
Copy Markdown
Contributor

@tomer-w

tomer-w commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Can you add some tests for this new function? It will also help to show what is the GX device expended output.

@tomer-w

tomer-w commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Also, it will be nice to update the README.md file with the new functionaility + sample code.

Comment thread victron_mqtt/pairing.py
Comment thread tests/test_pairing.py Outdated
@tomer-w

tomer-w commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Looks good. Just fix the failed check.

@philipptrenz

Copy link
Copy Markdown
Contributor Author

That should work now.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Static Tests passed

============================= 248 passed in 40.93s =============================

@tomer-w
tomer-w merged commit 5266759 into tomer-w:main Aug 13, 2026
5 checks passed
@tomer-w

tomer-w commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Thanks @philipptrenz !!

philipptrenz added a commit to philipptrenz/ha-victron-mqtt that referenced this pull request Aug 13, 2026
philipptrenz added a commit to philipptrenz/ha-victron-mqtt that referenced this pull request Aug 13, 2026
philipptrenz added a commit to philipptrenz/ha-victron-mqtt that referenced this pull request Aug 14, 2026
tomer-w pushed a commit to tomer-w/ha-victron-mqtt that referenced this pull request Aug 14, 2026
* Improve GX device config flow

- 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

* Move request_pairing_token function to victron_mqtt package; depends on tomer-w/victron_mqtt#126

* Refactor config_flow: make mqtt_token_pairing transient flow state

* Refactor: move HTTP session creation into request_pairing_token; depends on tomer-w/victron_mqtt#127

* Refactor: remove aiohttp import from config_flow
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