diff --git a/homeassistant/components/tado/config_flow.py b/homeassistant/components/tado/config_flow.py index c14b4284cf3..fb60b820ab9 100644 --- a/homeassistant/components/tado/config_flow.py +++ b/homeassistant/components/tado/config_flow.py @@ -92,6 +92,10 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): # they already have one configured as they can always # add a new one via "+" return self.async_abort(reason="already_configured") + properties = { + key.lower(): value for (key, value) in homekit_info["properties"].items() + } + await self.async_set_unique_id(properties["id"]) return await self.async_step_user() async def async_step_import(self, user_input): diff --git a/tests/components/tado/test_config_flow.py b/tests/components/tado/test_config_flow.py index fb9156d96d9..0c75eadfb0e 100644 --- a/tests/components/tado/test_config_flow.py +++ b/tests/components/tado/test_config_flow.py @@ -151,10 +151,18 @@ async def test_form_homekit(hass): await setup.async_setup_component(hass, "persistent_notification", {}) result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": "homekit"} + DOMAIN, + context={"source": "homekit"}, + data={"properties": {"id": "AA:BB:CC:DD:EE:FF"}}, ) assert result["type"] == "form" assert result["errors"] == {} + flow = next( + flow + for flow in hass.config_entries.flow.async_progress() + if flow["flow_id"] == result["flow_id"] + ) + assert flow["context"]["unique_id"] == "AA:BB:CC:DD:EE:FF" entry = MockConfigEntry( domain=DOMAIN, data={CONF_USERNAME: "mock", CONF_PASSWORD: "mock"} @@ -162,6 +170,8 @@ async def test_form_homekit(hass): entry.add_to_hass(hass) result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": "homekit"} + DOMAIN, + context={"source": "homekit"}, + data={"properties": {"id": "AA:BB:CC:DD:EE:FF"}}, ) assert result["type"] == "abort"