Home Assistant Unofficial Reference 2024.12.1
config_flow.py
Go to the documentation of this file.
1 """Config flow for deako."""
2 
3 from pydeako import DeakoDiscoverer, DevicesNotFoundException
4 
5 from homeassistant.components import zeroconf
6 from homeassistant.core import HomeAssistant
7 from homeassistant.helpers import config_entry_flow
8 
9 from .const import DOMAIN, NAME
10 
11 
12 async def _async_has_devices(hass: HomeAssistant) -> bool:
13  """Return if there are devices that can be discovered."""
14  _zc = await zeroconf.async_get_instance(hass)
15  discoverer = DeakoDiscoverer(_zc)
16 
17  try:
18  await discoverer.get_address()
19  except DevicesNotFoundException:
20  return False
21  else:
22  # address exists, there's at least one device
23  return True
24 
25 
26 config_entry_flow.register_discovery_flow(DOMAIN, NAME, _async_has_devices)
bool _async_has_devices(HomeAssistant hass)
Definition: config_flow.py:12