mirror of
https://github.com/home-assistant/core.git
synced 2026-07-13 01:27:57 +01:00
Trigger active scan when picking a tilt_ble device in the config flow (#172053)
This commit is contained in:
@@ -5,6 +5,7 @@ from typing import Any
|
||||
from tilt_ble import TiltBluetoothDeviceData 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 TiltConfigFlow(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
|
||||
|
||||
@@ -56,9 +56,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.tilt_ble.config_flow.async_discovered_service_info",
|
||||
return_value=[TILT_GREEN_SERVICE_INFO],
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.tilt_ble.config_flow.async_discovered_service_info",
|
||||
return_value=[TILT_GREEN_SERVICE_INFO],
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.tilt_ble.config_flow.bluetooth.async_request_active_scan"
|
||||
) as mock_request_active_scan,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
@@ -66,6 +71,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.tilt_ble.async_setup_entry", return_value=True
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user