From 8cae33a730c7307225d0fa7741c0c4c2634edd6e Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 17 Sep 2022 12:44:24 -0500 Subject: [PATCH] Fix rachio not being able to be ignored (#78636) Fixes #77272 --- .../components/rachio/config_flow.py | 1 + tests/components/rachio/test_config_flow.py | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/homeassistant/components/rachio/config_flow.py b/homeassistant/components/rachio/config_flow.py index 00f31003ba6..477abcb3694 100644 --- a/homeassistant/components/rachio/config_flow.py +++ b/homeassistant/components/rachio/config_flow.py @@ -90,6 +90,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): await self.async_set_unique_id( discovery_info.properties[zeroconf.ATTR_PROPERTIES_ID] ) + self._abort_if_unique_id_configured() return await self.async_step_user() @staticmethod diff --git a/tests/components/rachio/test_config_flow.py b/tests/components/rachio/test_config_flow.py index 00445f23c01..07965fca693 100644 --- a/tests/components/rachio/test_config_flow.py +++ b/tests/components/rachio/test_config_flow.py @@ -149,3 +149,29 @@ async def test_form_homekit(hass): ) assert result["type"] == "abort" assert result["reason"] == "already_configured" + + +async def test_form_homekit_ignored(hass): + """Test that we abort from homekit if rachio is ignored.""" + entry = MockConfigEntry( + domain=DOMAIN, + unique_id="AA:BB:CC:DD:EE:FF", + source=config_entries.SOURCE_IGNORE, + ) + entry.add_to_hass(hass) + + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={"source": config_entries.SOURCE_HOMEKIT}, + data=zeroconf.ZeroconfServiceInfo( + host="mock_host", + addresses=["mock_host"], + hostname="mock_hostname", + name="mock_name", + port=None, + properties={zeroconf.ATTR_PROPERTIES_ID: "AA:BB:CC:DD:EE:FF"}, + type="mock_type", + ), + ) + assert result["type"] == "abort" + assert result["reason"] == "already_configured"