Skip to content

Commit 79c3bc9

Browse files
authored
Allow ignored snooz devices to be set up from the user flow (home-assistant#155629)
1 parent 10439ee commit 79c3bc9

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

homeassistant/components/snooz/config_flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ async def async_step_user(
9696
self._abort_if_unique_id_configured()
9797
return self._create_snooz_entry(discovered)
9898

99-
configured_addresses = self._async_current_ids()
99+
configured_addresses = self._async_current_ids(include_ignore=False)
100100

101101
for info in async_discovered_service_info(self.hass):
102102
address = info.address

tests/components/snooz/test_config_flow.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from homeassistant import config_entries
99
from homeassistant.components.snooz import DOMAIN
10+
from homeassistant.config_entries import SOURCE_IGNORE
1011
from homeassistant.const import CONF_ADDRESS, CONF_NAME, CONF_TOKEN
1112
from homeassistant.core import HomeAssistant
1213
from homeassistant.data_entry_flow import FlowResultType
@@ -265,6 +266,34 @@ async def test_async_step_user_takes_precedence_over_discovery(
265266
assert not hass.config_entries.flow.async_progress()
266267

267268

269+
async def test_user_setup_replaces_ignored_device(hass: HomeAssistant) -> None:
270+
"""Test the user initiated form can replace an ignored device."""
271+
entry = MockConfigEntry(
272+
domain=DOMAIN,
273+
unique_id=TEST_ADDRESS,
274+
source=SOURCE_IGNORE,
275+
data={},
276+
)
277+
entry.add_to_hass(hass)
278+
279+
with patch(
280+
"homeassistant.components.snooz.config_flow.async_discovered_service_info",
281+
return_value=[SNOOZ_SERVICE_INFO_PAIRING],
282+
):
283+
result = await hass.config_entries.flow.async_init(
284+
DOMAIN, context={"source": config_entries.SOURCE_USER}
285+
)
286+
assert result["type"] is FlowResultType.FORM
287+
assert result["step_id"] == "user"
288+
289+
# Verify the ignored device is in the dropdown
290+
assert result["data_schema"].schema["name"].container == [TEST_SNOOZ_DISPLAY_NAME]
291+
292+
await _test_setup_entry(
293+
hass, result["flow_id"], {CONF_NAME: TEST_SNOOZ_DISPLAY_NAME}
294+
)
295+
296+
268297
async def _test_pairs(
269298
hass: HomeAssistant, flow_id: str, user_input: dict | None = None
270299
) -> None:

0 commit comments

Comments
 (0)