diff --git a/homeassistant/components/elkm1/config_flow.py b/homeassistant/components/elkm1/config_flow.py index d68fce268a2..05ae860d273 100644 --- a/homeassistant/components/elkm1/config_flow.py +++ b/homeassistant/components/elkm1/config_flow.py @@ -166,6 +166,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): for progress in self._async_in_progress(): if progress.get("context", {}).get(CONF_HOST) == host: return self.async_abort(reason="already_in_progress") + # Handled ignored case since _async_current_entries + # is called with include_ignore=False + self._abort_if_unique_id_configured() if not device.port: if discovered_device := await async_discover_device(self.hass, host): self._discovered_device = discovered_device diff --git a/tests/components/elkm1/test_config_flow.py b/tests/components/elkm1/test_config_flow.py index 183ab90086c..a1ec9eeff8e 100644 --- a/tests/components/elkm1/test_config_flow.py +++ b/tests/components/elkm1/test_config_flow.py @@ -27,6 +27,27 @@ ELK_DISCOVERY_INFO = asdict(ELK_DISCOVERY) MODULE = "homeassistant.components.elkm1" +async def test_discovery_ignored_entry(hass): + """Test we abort on ignored entry.""" + config_entry = MockConfigEntry( + domain=DOMAIN, + data={CONF_HOST: f"elks://{MOCK_IP_ADDRESS}"}, + unique_id="aa:bb:cc:dd:ee:ff", + source=config_entries.SOURCE_IGNORE, + ) + config_entry.add_to_hass(hass) + + with _patch_discovery(), _patch_elk(): + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={"source": config_entries.SOURCE_INTEGRATION_DISCOVERY}, + data=ELK_DISCOVERY_INFO, + ) + await hass.async_block_till_done() + assert result["type"] == RESULT_TYPE_ABORT + assert result["reason"] == "already_configured" + + async def test_form_user_with_secure_elk_no_discovery(hass): """Test we can setup a secure elk."""