1
0
mirror of https://github.com/home-assistant/core.git synced 2026-07-13 01:27:57 +01:00

Trigger active scan when picking a rapt_ble device in the config flow (#172054)

This commit is contained in:
J. Nick Koston
2026-05-24 12:27:07 -05:00
committed by GitHub
parent 31c9cdf742
commit 057eac7fb6
2 changed files with 11 additions and 3 deletions
@@ -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
@@ -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
):