From cd62bd86fd8908faa13eaeea97028aa1e6904b56 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 1 Nov 2025 11:33:22 -0500 Subject: [PATCH] Allow configuring ignored Steamist devices (#155630) --- .../components/steamist/config_flow.py | 2 +- tests/components/steamist/test_config_flow.py | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/steamist/config_flow.py b/homeassistant/components/steamist/config_flow.py index cadcba118a1..ee4b412cbbd 100644 --- a/homeassistant/components/steamist/config_flow.py +++ b/homeassistant/components/steamist/config_flow.py @@ -137,7 +137,7 @@ class SteamistConfigFlow(ConfigFlow, domain=DOMAIN): device = self._discovered_devices[mac] return self._async_create_entry_from_device(device) - current_unique_ids = self._async_current_ids() + current_unique_ids = self._async_current_ids(include_ignore=False) current_hosts = { entry.data[CONF_HOST] for entry in self._async_current_entries(include_ignore=False) diff --git a/tests/components/steamist/test_config_flow.py b/tests/components/steamist/test_config_flow.py index 5e963f77a2b..940205be91f 100644 --- a/tests/components/steamist/test_config_flow.py +++ b/tests/components/steamist/test_config_flow.py @@ -6,6 +6,7 @@ import pytest from homeassistant import config_entries from homeassistant.components.steamist.const import DOMAIN +from homeassistant.config_entries import SOURCE_IGNORE from homeassistant.const import CONF_DEVICE, CONF_HOST from homeassistant.core import HomeAssistant 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 assert result["reason"] == "already_configured" assert not mock_setup.called assert not mock_setup_entry.called + + +async def test_pick_device_replaces_ignored_device(hass: HomeAssistant) -> None: + """Test the pick device step can replace an ignored device.""" + entry = MockConfigEntry( + domain=DOMAIN, + unique_id=FORMATTED_MAC_ADDRESS, + source=SOURCE_IGNORE, + data={}, + ) + entry.add_to_hass(hass) + + with _patch_discovery(), _patch_status(MOCK_ASYNC_GET_STATUS_INACTIVE): + result = await hass.config_entries.flow.async_init( + DOMAIN, context={"source": config_entries.SOURCE_USER} + ) + await hass.async_block_till_done() + assert result["type"] is FlowResultType.FORM + assert result["step_id"] == "user" + + result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) + await hass.async_block_till_done() + + assert result2["type"] is FlowResultType.FORM + assert result2["step_id"] == "pick_device" + + # Verify the ignored device is in the dropdown + assert FORMATTED_MAC_ADDRESS in result2["data_schema"].schema[CONF_DEVICE].container + + with ( + _patch_discovery(), + _patch_status(MOCK_ASYNC_GET_STATUS_INACTIVE), + patch(f"{MODULE}.async_setup", return_value=True), + patch(f"{MODULE}.async_setup_entry", return_value=True), + ): + result3 = await hass.config_entries.flow.async_configure( + result2["flow_id"], + {CONF_DEVICE: FORMATTED_MAC_ADDRESS}, + ) + await hass.async_block_till_done() + + assert result3["type"] is FlowResultType.CREATE_ENTRY + assert result3["title"] == DEVICE_NAME + assert result3["data"] == DEFAULT_ENTRY_DATA + assert result3["result"].unique_id == FORMATTED_MAC_ADDRESS