From 19aee19efd3fb5cae0e81d0b4fbce34ab8a485ec Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 21 May 2021 00:40:55 -0500 Subject: [PATCH] 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 --- .../components/hunterdouglas_powerview/config_flow.py | 3 ++- homeassistant/components/hunterdouglas_powerview/strings.json | 1 + .../components/hunterdouglas_powerview/translations/en.json | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/hunterdouglas_powerview/config_flow.py b/homeassistant/components/hunterdouglas_powerview/config_flow.py index 3ae60d5e62e..8dbe21eb10e 100644 --- a/homeassistant/components/hunterdouglas_powerview/config_flow.py +++ b/homeassistant/components/hunterdouglas_powerview/config_flow.py @@ -113,6 +113,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): """Confirm dhcp or homekit discovery.""" # If we already have the host configured do # not open connections to it if we can avoid it. + self.context[CONF_HOST] = self.discovered_ip for progress in self._async_in_progress(): if progress.get("context", {}).get(CONF_HOST) == self.discovered_ip: 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]}, ) - self.context[CONF_HOST] = self.discovered_ip self._set_confirm_only() + self.context["title_placeholders"] = self.powerview_config return self.async_show_form( step_id="link", description_placeholders=self.powerview_config ) diff --git a/homeassistant/components/hunterdouglas_powerview/strings.json b/homeassistant/components/hunterdouglas_powerview/strings.json index a1c91cd2ed4..e78cc105db6 100644 --- a/homeassistant/components/hunterdouglas_powerview/strings.json +++ b/homeassistant/components/hunterdouglas_powerview/strings.json @@ -12,6 +12,7 @@ "description": "Do you want to setup {name} ({host})?" } }, + "flow_title": "{name} ({host})", "error": { "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]", "unknown": "[%key:common::config_flow::error::unknown%]" diff --git a/homeassistant/components/hunterdouglas_powerview/translations/en.json b/homeassistant/components/hunterdouglas_powerview/translations/en.json index b2d09aac12c..d95d7451b1a 100644 --- a/homeassistant/components/hunterdouglas_powerview/translations/en.json +++ b/homeassistant/components/hunterdouglas_powerview/translations/en.json @@ -7,6 +7,7 @@ "cannot_connect": "Failed to connect", "unknown": "Unexpected error" }, + "flow_title": "{name} ({host})", "step": { "link": { "description": "Do you want to setup {name} ({host})?",