diff --git a/homeassistant/components/snooz/config_flow.py b/homeassistant/components/snooz/config_flow.py index 3962a44d8b9..185e875065b 100644 --- a/homeassistant/components/snooz/config_flow.py +++ b/homeassistant/components/snooz/config_flow.py @@ -96,7 +96,7 @@ class SnoozConfigFlow(ConfigFlow, domain=DOMAIN): self._abort_if_unique_id_configured() return self._create_snooz_entry(discovered) - configured_addresses = self._async_current_ids() + configured_addresses = self._async_current_ids(include_ignore=False) for info in async_discovered_service_info(self.hass): address = info.address diff --git a/tests/components/snooz/test_config_flow.py b/tests/components/snooz/test_config_flow.py index 4ed4d6184a7..d326f81d9b6 100644 --- a/tests/components/snooz/test_config_flow.py +++ b/tests/components/snooz/test_config_flow.py @@ -7,6 +7,7 @@ from unittest.mock import patch from homeassistant import config_entries from homeassistant.components.snooz import DOMAIN +from homeassistant.config_entries import SOURCE_IGNORE from homeassistant.const import CONF_ADDRESS, CONF_NAME, CONF_TOKEN from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -265,6 +266,34 @@ async def test_async_step_user_takes_precedence_over_discovery( assert not hass.config_entries.flow.async_progress() +async def test_user_setup_replaces_ignored_device(hass: HomeAssistant) -> None: + """Test the user initiated form can replace an ignored device.""" + entry = MockConfigEntry( + domain=DOMAIN, + unique_id=TEST_ADDRESS, + source=SOURCE_IGNORE, + data={}, + ) + entry.add_to_hass(hass) + + with patch( + "homeassistant.components.snooz.config_flow.async_discovered_service_info", + return_value=[SNOOZ_SERVICE_INFO_PAIRING], + ): + result = await hass.config_entries.flow.async_init( + DOMAIN, context={"source": config_entries.SOURCE_USER} + ) + assert result["type"] is FlowResultType.FORM + assert result["step_id"] == "user" + + # Verify the ignored device is in the dropdown + assert result["data_schema"].schema["name"].container == [TEST_SNOOZ_DISPLAY_NAME] + + await _test_setup_entry( + hass, result["flow_id"], {CONF_NAME: TEST_SNOOZ_DISPLAY_NAME} + ) + + async def _test_pairs( hass: HomeAssistant, flow_id: str, user_input: dict | None = None ) -> None: