Let PAHO MQTT client handle connection to MQTT server#35983
Conversation
|
Hey there @home-assistant/core, mind taking a look at this pull request as its been labeled with a integration ( |
|
Why doesn't the current retry logic work and a restart is required? |
|
@MartinHjelmare The retry logic has already been removed, done in #34556 |
|
Yeah, the latter. |
|
When the config entry is not loaded, calls to subscribe don't work so the subscriptions are not done once the connection to the MQTT server is established. Since we don't unload the MQTT config entry if the connection is severed, I think it's OK to not block it from loading either? |
|
Why doesn't the subscription store work when the entry isn't setup? |
|
The subscription store is reset every time loading the MQTT entry is retried because |
MartinHjelmare
left a comment
There was a problem hiding this comment.
Looks good! Just a small comment.
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
|
/AzurePipelines run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| with patch("paho.mqtt.client.Client") as mock_client: | ||
| mock_client().connect = lambda *args: 1 | ||
| assert not await mqtt.async_setup_entry(hass, entry) | ||
| assert await mqtt.async_setup_entry(hass, entry) |
There was a problem hiding this comment.
It's better to use the core interface, hass.config_entries.async_setup.
* Let PAHO client handle connection to MQTT server
Proposed change
Let PAHO MQTT client handle connection to MQTT server by itself, instead of doing checks when loading the config entry.
The checks prevents the config entry from loading until connection with the MQTT server is established, which breaks MQTT components as reported in #35858 as well as in other issues.
Type of change
Additional information
Checklist
black --fast homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all..coveragerc.The integration reached or maintains the following Integration Quality Scale: