From b3764da9126c750a79d2535a78b2b4b54360d88c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 15 Jan 2021 13:48:19 -1000 Subject: [PATCH] Fix exception when trying to configure an ignored somfy mylink (#45198) --- .../components/somfy_mylink/config_flow.py | 2 +- .../somfy_mylink/test_config_flow.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/somfy_mylink/config_flow.py b/homeassistant/components/somfy_mylink/config_flow.py index 847cadfd0d5..ce69d265b55 100644 --- a/homeassistant/components/somfy_mylink/config_flow.py +++ b/homeassistant/components/somfy_mylink/config_flow.py @@ -118,7 +118,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): def _host_already_configured(self, host): """See if we already have an entry matching the host.""" for entry in self._async_current_entries(): - if entry.data[CONF_HOST] == host: + if entry.data.get(CONF_HOST) == host: return True return False diff --git a/tests/components/somfy_mylink/test_config_flow.py b/tests/components/somfy_mylink/test_config_flow.py index f01309b578e..980a01f318c 100644 --- a/tests/components/somfy_mylink/test_config_flow.py +++ b/tests/components/somfy_mylink/test_config_flow.py @@ -461,6 +461,25 @@ async def test_form_user_already_configured_from_dhcp(hass): assert len(mock_setup_entry.mock_calls) == 0 +async def test_already_configured_with_ignored(hass): + """Test ignored entries do not break checking for existing entries.""" + await setup.async_setup_component(hass, "persistent_notification", {}) + + config_entry = MockConfigEntry(domain=DOMAIN, data={}, source="ignore") + config_entry.add_to_hass(hass) + + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={"source": config_entries.SOURCE_DHCP}, + data={ + IP_ADDRESS: "1.1.1.1", + MAC_ADDRESS: "AA:BB:CC:DD:EE:FF", + HOSTNAME: "somfy_eeff", + }, + ) + assert result["type"] == "form" + + async def test_dhcp_discovery(hass): """Test we can process the discovery from dhcp.""" await setup.async_setup_component(hass, "persistent_notification", {})