Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions homeassistant/components/tado/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ async def async_step_homekit(self, homekit_info):
# 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):
Expand Down
14 changes: 12 additions & 2 deletions tests/components/tado/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,27 @@ 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"}
)
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"