Skip to content

Commit fd339be

Browse files
bdracoctalkington
andauthored
Add ability to ignore myq discovery (#34652)
* Add ability to ignore myq discovery * update test * Update tests/components/myq/test_config_flow.py Co-Authored-By: Chris Talkington <[email protected]> * Update tests/components/myq/test_config_flow.py Co-Authored-By: Chris Talkington <[email protected]> * reset ci Co-authored-by: Chris Talkington <[email protected]>
1 parent 29383f9 commit fd339be

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

homeassistant/components/myq/config_flow.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ async def async_step_homekit(self, homekit_info):
7575
# they already have one configured as they can always
7676
# add a new one via "+"
7777
return self.async_abort(reason="already_configured")
78+
properties = {
79+
key.lower(): value for (key, value) in homekit_info["properties"].items()
80+
}
81+
await self.async_set_unique_id(properties["id"])
7882
return await self.async_step_user()
7983

8084
async def async_step_import(self, user_input):

tests/components/myq/test_config_flow.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,27 @@ async def test_form_homekit(hass):
111111
await setup.async_setup_component(hass, "persistent_notification", {})
112112

113113
result = await hass.config_entries.flow.async_init(
114-
DOMAIN, context={"source": "homekit"}
114+
DOMAIN,
115+
context={"source": "homekit"},
116+
data={"properties": {"id": "AA:BB:CC:DD:EE:FF"}},
115117
)
116118
assert result["type"] == "form"
117119
assert result["errors"] == {}
120+
flow = next(
121+
flow
122+
for flow in hass.config_entries.flow.async_progress()
123+
if flow["flow_id"] == result["flow_id"]
124+
)
125+
assert flow["context"]["unique_id"] == "AA:BB:CC:DD:EE:FF"
118126

119127
entry = MockConfigEntry(
120128
domain=DOMAIN, data={CONF_USERNAME: "mock", CONF_PASSWORD: "mock"}
121129
)
122130
entry.add_to_hass(hass)
123131

124132
result = await hass.config_entries.flow.async_init(
125-
DOMAIN, context={"source": "homekit"}
133+
DOMAIN,
134+
context={"source": "homekit"},
135+
data={"properties": {"id": "AA:BB:CC:DD:EE:FF"}},
126136
)
127137
assert result["type"] == "abort"

0 commit comments

Comments
 (0)