From 057eac7fb68eef34fd64f7bfc5be04b384a93039 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 24 May 2026 12:27:07 -0500 Subject: [PATCH] Trigger active scan when picking a rapt_ble device in the config flow (#172054) --- homeassistant/components/rapt_ble/config_flow.py | 2 ++ tests/components/rapt_ble/test_config_flow.py | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/rapt_ble/config_flow.py b/homeassistant/components/rapt_ble/config_flow.py index 326be35b9b56..03eb4e4f62e9 100644 --- a/homeassistant/components/rapt_ble/config_flow.py +++ b/homeassistant/components/rapt_ble/config_flow.py @@ -5,6 +5,7 @@ from typing import Any from rapt_ble import RAPTPillBluetoothDeviceData as DeviceData import voluptuous as vol +from homeassistant.components import bluetooth from homeassistant.components.bluetooth import ( BluetoothServiceInfoBleak, async_discovered_service_info, @@ -70,6 +71,7 @@ class RAPTPillConfigFlow(ConfigFlow, domain=DOMAIN): title=self._discovered_devices[address], data={} ) + await bluetooth.async_request_active_scan(self.hass) current_addresses = self._async_current_ids(include_ignore=False) for discovery_info in async_discovered_service_info(self.hass, False): address = discovery_info.address diff --git a/tests/components/rapt_ble/test_config_flow.py b/tests/components/rapt_ble/test_config_flow.py index ef93622bd600..d2cf7a23edff 100644 --- a/tests/components/rapt_ble/test_config_flow.py +++ b/tests/components/rapt_ble/test_config_flow.py @@ -88,9 +88,14 @@ async def test_async_step_user_replaces_ignored(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.rapt_ble.config_flow.async_discovered_service_info", - return_value=[COMPLETE_SERVICE_INFO], + with ( + patch( + "homeassistant.components.rapt_ble.config_flow.async_discovered_service_info", + return_value=[COMPLETE_SERVICE_INFO], + ), + patch( + "homeassistant.components.rapt_ble.config_flow.bluetooth.async_request_active_scan" + ) as mock_request_active_scan, ): result = await hass.config_entries.flow.async_init( DOMAIN, @@ -98,6 +103,7 @@ async def test_async_step_user_with_found_devices(hass: HomeAssistant) -> None: ) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" + mock_request_active_scan.assert_awaited_once_with(hass) with patch( "homeassistant.components.rapt_ble.async_setup_entry", return_value=True ):