Compare commits

...

2 Commits

Author SHA1 Message Date
J. Nick Koston 985eb11551 Test active scan trigger in switchbot select_device step 2026-05-24 10:01:28 -05:00
J. Nick Koston cea6be33c5 Trigger active scan when picking a switchbot device in the config flow 2026-05-24 09:51:21 -05:00
2 changed files with 11 additions and 3 deletions
@@ -14,6 +14,7 @@ from switchbot import (
)
import voluptuous as vol
from homeassistant.components import bluetooth
from homeassistant.components.bluetooth import (
BluetoothServiceInfoBleak,
async_discovered_service_info,
@@ -424,6 +425,7 @@ class SwitchbotConfigFlow(ConfigFlow, domain=DOMAIN):
return await self.async_step_password()
return await self._async_create_entry_from_discovery(user_input)
await bluetooth.async_request_active_scan(self.hass)
self._async_discover_devices()
if len(self._discovered_advs) == 1:
# If there is only one device we can ask for a password
@@ -411,9 +411,14 @@ async def test_user_setup_wohand(hass: HomeAssistant) -> None:
assert result["type"] is FlowResultType.MENU
assert result["step_id"] == "user"
with patch(
"homeassistant.components.switchbot.config_flow.async_discovered_service_info",
return_value=[WOHAND_SERVICE_INFO],
with (
patch(
"homeassistant.components.switchbot.config_flow.async_discovered_service_info",
return_value=[WOHAND_SERVICE_INFO],
),
patch(
"homeassistant.components.switchbot.config_flow.bluetooth.async_request_active_scan"
) as mock_request_active_scan,
):
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
@@ -422,6 +427,7 @@ async def test_user_setup_wohand(hass: HomeAssistant) -> None:
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
assert result["errors"] is None
mock_request_active_scan.assert_awaited_once_with(hass)
with patch_async_setup_entry() as mock_setup_entry:
result = await hass.config_entries.flow.async_configure(