Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 8 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,23 @@ 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"] == {}
flows_in_progress = hass.config_entries.flow.async_progress()
Comment thread
bdraco marked this conversation as resolved.
Outdated
assert flows_in_progress[0]["context"]["unique_id"] == "AA:BB:CC:DD:EE:FF"
Comment thread
bdraco marked this conversation as resolved.
Outdated

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"