mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 02:07:09 +00:00
Resolve race condition in powerview when discovered by zeroconf and dhcp (#50908)
Set the host in the context before checking to ensure that the second discovery aborts. Seen when testing on a very fast system only
This commit is contained in:
parent
d9769900bb
commit
19aee19efd
@ -113,6 +113,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
"""Confirm dhcp or homekit discovery."""
|
"""Confirm dhcp or homekit discovery."""
|
||||||
# If we already have the host configured do
|
# If we already have the host configured do
|
||||||
# not open connections to it if we can avoid it.
|
# not open connections to it if we can avoid it.
|
||||||
|
self.context[CONF_HOST] = self.discovered_ip
|
||||||
for progress in self._async_in_progress():
|
for progress in self._async_in_progress():
|
||||||
if progress.get("context", {}).get(CONF_HOST) == self.discovered_ip:
|
if progress.get("context", {}).get(CONF_HOST) == self.discovered_ip:
|
||||||
return self.async_abort(reason="already_in_progress")
|
return self.async_abort(reason="already_in_progress")
|
||||||
@ -140,8 +141,8 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
data={CONF_HOST: self.powerview_config[CONF_HOST]},
|
data={CONF_HOST: self.powerview_config[CONF_HOST]},
|
||||||
)
|
)
|
||||||
|
|
||||||
self.context[CONF_HOST] = self.discovered_ip
|
|
||||||
self._set_confirm_only()
|
self._set_confirm_only()
|
||||||
|
self.context["title_placeholders"] = self.powerview_config
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="link", description_placeholders=self.powerview_config
|
step_id="link", description_placeholders=self.powerview_config
|
||||||
)
|
)
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
"description": "Do you want to setup {name} ({host})?"
|
"description": "Do you want to setup {name} ({host})?"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"flow_title": "{name} ({host})",
|
||||||
"error": {
|
"error": {
|
||||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
||||||
"unknown": "[%key:common::config_flow::error::unknown%]"
|
"unknown": "[%key:common::config_flow::error::unknown%]"
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
"cannot_connect": "Failed to connect",
|
"cannot_connect": "Failed to connect",
|
||||||
"unknown": "Unexpected error"
|
"unknown": "Unexpected error"
|
||||||
},
|
},
|
||||||
|
"flow_title": "{name} ({host})",
|
||||||
"step": {
|
"step": {
|
||||||
"link": {
|
"link": {
|
||||||
"description": "Do you want to setup {name} ({host})?",
|
"description": "Do you want to setup {name} ({host})?",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user