mirror of
https://github.com/home-assistant/core.git
synced 2025-07-12 15:57:06 +00:00
Allow configuring ignored devices from dormakaba_dkey user flow (#140596)
This commit is contained in:
parent
1bd8ff884e
commit
96a6d88dca
@ -57,7 +57,7 @@ class DormkabaConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
self._discovery_info = self._discovered_devices[address]
|
||||
return await self.async_step_associate()
|
||||
|
||||
current_addresses = self._async_current_ids()
|
||||
current_addresses = self._async_current_ids(include_ignore=False)
|
||||
for discovery in async_discovered_service_info(self.hass):
|
||||
if (
|
||||
discovery.address in current_addresses
|
||||
|
@ -9,6 +9,7 @@ import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.dormakaba_dkey.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_IGNORE
|
||||
from homeassistant.const import CONF_ADDRESS
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResult, FlowResultType
|
||||
@ -143,6 +144,43 @@ async def test_async_step_user_takes_precedence_over_discovery(
|
||||
assert not hass.config_entries.flow.async_progress(DOMAIN)
|
||||
|
||||
|
||||
async def test_user_setup_removes_ignored_entry(hass: HomeAssistant) -> None:
|
||||
"""Test the user initiated form can replace an ignored device."""
|
||||
ignored_entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
unique_id=DKEY_DISCOVERY_INFO.address,
|
||||
source=SOURCE_IGNORE,
|
||||
)
|
||||
ignored_entry.add_to_hass(hass)
|
||||
assert hass.config_entries.async_entries(DOMAIN) == [ignored_entry]
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.dormakaba_dkey.config_flow.async_discovered_service_info",
|
||||
return_value=[NOT_DKEY_DISCOVERY_INFO, DKEY_DISCOVERY_INFO],
|
||||
):
|
||||
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"
|
||||
assert result["errors"] == {}
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{
|
||||
CONF_ADDRESS: DKEY_DISCOVERY_INFO.address,
|
||||
},
|
||||
)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "associate"
|
||||
assert result["errors"] is None
|
||||
|
||||
await _test_common_success(hass, result)
|
||||
|
||||
# Check the ignored entry is removed
|
||||
assert ignored_entry not in hass.config_entries.async_entries(DOMAIN)
|
||||
|
||||
|
||||
async def test_bluetooth_step_success(hass: HomeAssistant) -> None:
|
||||
"""Test bluetooth step success path."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
Loading…
x
Reference in New Issue
Block a user