From 00afcffbf92fda61d56f571822b3132fab950b0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 22 Nov 2022 16:12:33 +0100 Subject: [PATCH] Abort before trying to connect in QNAP QSW DHCP discovery when already configured (#82362) --- homeassistant/components/qnap_qsw/config_flow.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/qnap_qsw/config_flow.py b/homeassistant/components/qnap_qsw/config_flow.py index 794e8c67baa..e0d4a1f78cd 100644 --- a/homeassistant/components/qnap_qsw/config_flow.py +++ b/homeassistant/components/qnap_qsw/config_flow.py @@ -78,6 +78,13 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): _LOGGER.debug("DHCP discovery detected QSW: %s", self._discovered_mac) + await self.async_set_unique_id(format_mac(self._discovered_mac)) + self._abort_if_unique_id_configured( + updates={ + CONF_URL: self._discovered_url, + } + ) + options = ConnectionOptions(self._discovered_url, "", "") qsw = QnapQswApi(aiohttp_client.async_get_clientsession(self.hass), options) @@ -86,9 +93,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): except QswError as err: raise AbortFlow("cannot_connect") from err - await self.async_set_unique_id(format_mac(self._discovered_mac)) - self._abort_if_unique_id_configured() - return await self.async_step_discovered_connection() async def async_step_discovered_connection(