1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-31 12:44:04 +01:00

Trigger active scan when picking a snooz device in the config flow (#172073)

This commit is contained in:
J. Nick Koston
2026-05-24 12:16:28 -05:00
committed by GitHub
parent 74a7102cf6
commit 7bad27c412
2 changed files with 11 additions and 3 deletions
@@ -7,6 +7,7 @@ from typing import Any
from pysnooz.advertisement import SnoozAdvertisementData
import voluptuous as vol
from homeassistant.components import bluetooth
from homeassistant.components.bluetooth import (
BluetoothScanningMode,
BluetoothServiceInfo,
@@ -94,6 +95,7 @@ class SnoozConfigFlow(ConfigFlow, domain=DOMAIN):
self._abort_if_unique_id_configured()
return self._create_snooz_entry(discovered)
await bluetooth.async_request_active_scan(self.hass)
configured_addresses = self._async_current_ids(include_ignore=False)
for info in async_discovered_service_info(self.hass):
+9 -3
View File
@@ -88,9 +88,14 @@ async def test_async_step_user_no_devices_found(hass: HomeAssistant) -> None:
async def test_async_step_user_with_found_devices(hass: HomeAssistant) -> None:
"""Test setup from service info cache with devices found."""
with patch(
"homeassistant.components.snooz.config_flow.async_discovered_service_info",
return_value=[SNOOZ_SERVICE_INFO_PAIRING],
with (
patch(
"homeassistant.components.snooz.config_flow.async_discovered_service_info",
return_value=[SNOOZ_SERVICE_INFO_PAIRING],
),
patch(
"homeassistant.components.snooz.config_flow.bluetooth.async_request_active_scan"
) as mock_request_active_scan,
):
result = await hass.config_entries.flow.async_init(
DOMAIN,
@@ -101,6 +106,7 @@ async def test_async_step_user_with_found_devices(hass: HomeAssistant) -> None:
assert result["data_schema"]
# ensure discovered devices are listed as options
assert result["data_schema"].schema["name"].container == [TEST_SNOOZ_DISPLAY_NAME]
mock_request_active_scan.assert_awaited_once_with(hass)
await _test_setup_entry(
hass, result["flow_id"], {CONF_NAME: TEST_SNOOZ_DISPLAY_NAME}
)