mirror of
https://github.com/Electric-Special/ha-core.git
synced 2026-03-21 04:05:20 +01:00
Allow ignored snooz devices to be set up from the user flow (#155629)
This commit is contained in:
@@ -96,7 +96,7 @@ class SnoozConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
self._abort_if_unique_id_configured()
|
||||
return self._create_snooz_entry(discovered)
|
||||
|
||||
configured_addresses = self._async_current_ids()
|
||||
configured_addresses = self._async_current_ids(include_ignore=False)
|
||||
|
||||
for info in async_discovered_service_info(self.hass):
|
||||
address = info.address
|
||||
|
||||
@@ -7,6 +7,7 @@ from unittest.mock import patch
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.snooz import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_IGNORE
|
||||
from homeassistant.const import CONF_ADDRESS, CONF_NAME, CONF_TOKEN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
@@ -265,6 +266,34 @@ async def test_async_step_user_takes_precedence_over_discovery(
|
||||
assert not hass.config_entries.flow.async_progress()
|
||||
|
||||
|
||||
async def test_user_setup_replaces_ignored_device(hass: HomeAssistant) -> None:
|
||||
"""Test the user initiated form can replace an ignored device."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
unique_id=TEST_ADDRESS,
|
||||
source=SOURCE_IGNORE,
|
||||
data={},
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.snooz.config_flow.async_discovered_service_info",
|
||||
return_value=[SNOOZ_SERVICE_INFO_PAIRING],
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
# Verify the ignored device is in the dropdown
|
||||
assert result["data_schema"].schema["name"].container == [TEST_SNOOZ_DISPLAY_NAME]
|
||||
|
||||
await _test_setup_entry(
|
||||
hass, result["flow_id"], {CONF_NAME: TEST_SNOOZ_DISPLAY_NAME}
|
||||
)
|
||||
|
||||
|
||||
async def _test_pairs(
|
||||
hass: HomeAssistant, flow_id: str, user_input: dict | None = None
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user