-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not unsubscribe mqtt integration discovery if entry is already configured #126907
Conversation
Hey there @emontnemery, @bdraco, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code change looks good, just a question about tests
@@ -1454,7 +1454,7 @@ class TestFlow(config_entries.ConfigFlow): | |||
|
|||
async def async_step_mqtt(self, discovery_info: MqttServiceInfo) -> FlowResult: | |||
"""Test mqtt step.""" | |||
return self.async_abort(reason="already_configured") | |||
return self.async_abort(reason="single_instance_allowed") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have other tests which checks we don't abort if the abort reason is different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not yet, we only had a test for already_configured
which I adjusted.
I'll add a test for the already_configured
to prove the subscription remains.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameterized the tests now, and added some cases where we do not unsubscribe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @jbouwh 👍
…figured (#126907) * Do not unsubscribe mqtt integration discovery if entry is already configured * Test cases without unsubscribe
Proposed change
Integrations that support mqtt discovery use an integration discovery topic for discovery of a device. When am entry is discovered once it should not be set up again if the discovery message is send again. In that case the config flow is aborted. The MQTT integration used to unsubscribe to the integration discovery topic after such a flow was aborted with
already_configured
orsingle_instance_allowed
. When multyple entries are supported by an integration this will cause an issue as when the integration discovery topic is unsubscribed to, no new discovery is possible.This PR will fix this issue by no longer unsubscribe the integration discovery topic when an
already_configured
abort flow happened. In case of asingle_instance_abort
flow the integration discovery topic will still be unsubscribed to.Type of change
Additional information
Checklist
ruff format 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
.To help with the load of incoming pull requests: