mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 13:47:35 +00:00
Allow ignored switchbot devices to be set up from the user flow (#137056)
This commit is contained in:
parent
84e15e10ef
commit
64d2f84c0d
@ -272,7 +272,7 @@ class SwitchbotConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
@callback
|
||||
def _async_discover_devices(self) -> None:
|
||||
current_addresses = self._async_current_ids()
|
||||
current_addresses = self._async_current_ids(include_ignore=False)
|
||||
for connectable in (True, False):
|
||||
for discovery_info in async_discovered_service_info(self.hass, connectable):
|
||||
address = discovery_info.address
|
||||
|
@ -10,7 +10,7 @@ from homeassistant.components.switchbot.const import (
|
||||
CONF_LOCK_NIGHTLATCH,
|
||||
CONF_RETRY_COUNT,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_BLUETOOTH, SOURCE_USER
|
||||
from homeassistant.config_entries import SOURCE_BLUETOOTH, SOURCE_IGNORE, SOURCE_USER
|
||||
from homeassistant.const import (
|
||||
CONF_ADDRESS,
|
||||
CONF_NAME,
|
||||
@ -303,6 +303,39 @@ async def test_user_setup_wohand_already_configured(hass: HomeAssistant) -> None
|
||||
assert result["reason"] == "no_devices_found"
|
||||
|
||||
|
||||
async def test_user_setup_wohand_replaces_ignored(hass: HomeAssistant) -> None:
|
||||
"""Test setting up a switchbot replaces an ignored entry."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN, data={}, unique_id="aabbccddeeff", source=SOURCE_IGNORE
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
with patch(
|
||||
"homeassistant.components.switchbot.config_flow.async_discovered_service_info",
|
||||
return_value=[WOHAND_SERVICE_INFO],
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "confirm"
|
||||
|
||||
with patch_async_setup_entry() as mock_setup_entry:
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "Bot EEFF"
|
||||
assert result["data"] == {
|
||||
CONF_ADDRESS: "AA:BB:CC:DD:EE:FF",
|
||||
CONF_SENSOR_TYPE: "bot",
|
||||
}
|
||||
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_user_setup_wocurtain(hass: HomeAssistant) -> None:
|
||||
"""Test the user initiated form with password and valid mac."""
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user