Skip to content

Commit 1ef0754

Browse files
authored
Fix for ignored devices issue home-assistant#137114 (home-assistant#146562)
1 parent ed4a23d commit 1ef0754

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

homeassistant/components/wiz/config_flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ async def async_step_pick_device(
124124
data={CONF_HOST: device.ip_address},
125125
)
126126

127-
current_unique_ids = self._async_current_ids()
127+
current_unique_ids = self._async_current_ids(include_ignore=False)
128128
current_hosts = {
129129
entry.data[CONF_HOST]
130130
for entry in self._async_current_entries(include_ignore=False)

tests/components/wiz/test_config_flow.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,3 +572,46 @@ async def test_discovered_during_onboarding(hass: HomeAssistant, source, data) -
572572
}
573573
assert len(mock_setup.mock_calls) == 1
574574
assert len(mock_setup_entry.mock_calls) == 1
575+
576+
577+
async def test_flow_replace_ignored_device(hass: HomeAssistant) -> None:
578+
"""Test we can replace an ignored device via discovery."""
579+
# Add ignored entry to simulate previously ignored device
580+
entry = MockConfigEntry(
581+
domain=DOMAIN,
582+
unique_id=FAKE_MAC,
583+
source=config_entries.SOURCE_IGNORE,
584+
)
585+
entry.add_to_hass(hass)
586+
# Patch discovery to find the same ignored device
587+
with _patch_discovery(), _patch_wizlight():
588+
result = await hass.config_entries.flow.async_init(
589+
DOMAIN, context={"source": config_entries.SOURCE_USER}
590+
)
591+
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
592+
await hass.async_block_till_done()
593+
assert result["type"] is FlowResultType.FORM
594+
assert result["step_id"] == "pick_device"
595+
# Proceed with selecting the device — previously ignored
596+
with (
597+
_patch_wizlight(),
598+
patch(
599+
"homeassistant.components.wiz.async_setup_entry",
600+
return_value=True,
601+
) as mock_setup_entry,
602+
patch(
603+
"homeassistant.components.wiz.async_setup",
604+
return_value=True,
605+
) as mock_setup,
606+
):
607+
result = await hass.config_entries.flow.async_configure(
608+
result["flow_id"], user_input={CONF_DEVICE: FAKE_MAC}
609+
)
610+
await hass.async_block_till_done()
611+
assert result["type"] is FlowResultType.CREATE_ENTRY
612+
assert result["title"] == "WiZ Dimmable White ABCABC"
613+
assert result["data"] == {
614+
CONF_HOST: "1.1.1.1",
615+
}
616+
assert len(mock_setup.mock_calls) == 1
617+
assert len(mock_setup_entry.mock_calls) == 1

0 commit comments

Comments
 (0)