Skip to content

Commit cd62bd8

Browse files
authored
Allow configuring ignored Steamist devices (home-assistant#155630)
1 parent 79c3bc9 commit cd62bd8

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

homeassistant/components/steamist/config_flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ async def async_step_pick_device(
137137
device = self._discovered_devices[mac]
138138
return self._async_create_entry_from_device(device)
139139

140-
current_unique_ids = self._async_current_ids()
140+
current_unique_ids = self._async_current_ids(include_ignore=False)
141141
current_hosts = {
142142
entry.data[CONF_HOST]
143143
for entry in self._async_current_entries(include_ignore=False)

tests/components/steamist/test_config_flow.py

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

77
from homeassistant import config_entries
88
from homeassistant.components.steamist.const import DOMAIN
9+
from homeassistant.config_entries import SOURCE_IGNORE
910
from homeassistant.const import CONF_DEVICE, CONF_HOST
1011
from homeassistant.core import HomeAssistant
1112
from homeassistant.data_entry_flow import FlowResultType
@@ -413,3 +414,48 @@ async def test_discovered_by_dhcp_or_discovery_existing_unique_id_does_not_reloa
413414
assert result["reason"] == "already_configured"
414415
assert not mock_setup.called
415416
assert not mock_setup_entry.called
417+
418+
419+
async def test_pick_device_replaces_ignored_device(hass: HomeAssistant) -> None:
420+
"""Test the pick device step can replace an ignored device."""
421+
entry = MockConfigEntry(
422+
domain=DOMAIN,
423+
unique_id=FORMATTED_MAC_ADDRESS,
424+
source=SOURCE_IGNORE,
425+
data={},
426+
)
427+
entry.add_to_hass(hass)
428+
429+
with _patch_discovery(), _patch_status(MOCK_ASYNC_GET_STATUS_INACTIVE):
430+
result = await hass.config_entries.flow.async_init(
431+
DOMAIN, context={"source": config_entries.SOURCE_USER}
432+
)
433+
await hass.async_block_till_done()
434+
assert result["type"] is FlowResultType.FORM
435+
assert result["step_id"] == "user"
436+
437+
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
438+
await hass.async_block_till_done()
439+
440+
assert result2["type"] is FlowResultType.FORM
441+
assert result2["step_id"] == "pick_device"
442+
443+
# Verify the ignored device is in the dropdown
444+
assert FORMATTED_MAC_ADDRESS in result2["data_schema"].schema[CONF_DEVICE].container
445+
446+
with (
447+
_patch_discovery(),
448+
_patch_status(MOCK_ASYNC_GET_STATUS_INACTIVE),
449+
patch(f"{MODULE}.async_setup", return_value=True),
450+
patch(f"{MODULE}.async_setup_entry", return_value=True),
451+
):
452+
result3 = await hass.config_entries.flow.async_configure(
453+
result2["flow_id"],
454+
{CONF_DEVICE: FORMATTED_MAC_ADDRESS},
455+
)
456+
await hass.async_block_till_done()
457+
458+
assert result3["type"] is FlowResultType.CREATE_ENTRY
459+
assert result3["title"] == DEVICE_NAME
460+
assert result3["data"] == DEFAULT_ENTRY_DATA
461+
assert result3["result"].unique_id == FORMATTED_MAC_ADDRESS

0 commit comments

Comments
 (0)