Home Assistant Unofficial Reference 2024.12.1
config_flow.py
Go to the documentation of this file.
1 """Config flow for Fjäråskupan integration."""
2 
3 from __future__ import annotations
4 
5 from fjaraskupan import device_filter
6 
7 from homeassistant.components.bluetooth import async_discovered_service_info
8 from homeassistant.core import HomeAssistant
9 from homeassistant.helpers.config_entry_flow import register_discovery_flow
10 
11 from .const import DOMAIN
12 
13 
14 async def _async_has_devices(hass: HomeAssistant) -> bool:
15  """Return if there are devices that can be discovered."""
16 
17  service_infos = async_discovered_service_info(hass)
18 
19  for service_info in service_infos:
20  if device_filter(service_info.device, service_info.advertisement):
21  return True
22 
23  return False
24 
25 
26 register_discovery_flow(DOMAIN, "Fjäråskupan", _async_has_devices)
Iterable[BluetoothServiceInfoBleak] async_discovered_service_info(HomeAssistant hass, bool connectable=True)
Definition: api.py:72
None register_discovery_flow(str domain, str title, DiscoveryFunctionType[Awaitable[bool]|bool] discovery_function)