mirror of
https://github.com/home-assistant/core.git
synced 2026-02-23 19:37:12 +00:00
Allow configuring ignored Steamist devices (#155630)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user