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", {})