diff --git a/homeassistant/components/hue/config_flow.py b/homeassistant/components/hue/config_flow.py index 9d4bc87889d..a77a2ff101a 100644 --- a/homeassistant/components/hue/config_flow.py +++ b/homeassistant/components/hue/config_flow.py @@ -216,16 +216,17 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): if not url.hostname: return self.async_abort(reason="not_hue_bridge") - bridge = await self._get_bridge( + # abort if we already have exactly this bridge id/host + # reload the integration if the host got updated + bridge_id = normalize_bridge_id(discovery_info.upnp[ssdp.ATTR_UPNP_SERIAL]) + await self.async_set_unique_id(bridge_id) + self._abort_if_unique_id_configured( + updates={CONF_HOST: url.hostname}, reload_on_update=True + ) + + self.bridge = await self._get_bridge( url.hostname, discovery_info.upnp[ssdp.ATTR_UPNP_SERIAL] ) - - await self.async_set_unique_id(bridge.id) - self._abort_if_unique_id_configured( - updates={CONF_HOST: bridge.host}, reload_on_update=False - ) - - self.bridge = bridge return await self.async_step_link() async def async_step_zeroconf( @@ -236,17 +237,18 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): This flow is triggered by the Zeroconf component. It will check if the host is already configured and delegate to the import step if not. """ - bridge = await self._get_bridge( - discovery_info.host, - discovery_info.properties["bridgeid"], - ) - - await self.async_set_unique_id(bridge.id) + # abort if we already have exactly this bridge id/host + # reload the integration if the host got updated + bridge_id = normalize_bridge_id(discovery_info.properties["bridgeid"]) + await self.async_set_unique_id(bridge_id) self._abort_if_unique_id_configured( - updates={CONF_HOST: bridge.host}, reload_on_update=False + updates={CONF_HOST: discovery_info.host}, reload_on_update=True ) - self.bridge = bridge + # we need to query the other capabilities too + self.bridge = await self._get_bridge( + discovery_info.host, discovery_info.properties["bridgeid"] + ) return await self.async_step_link() async def async_step_homekit(