Home Assistant Unofficial Reference 2024.12.1
config_flow.py
Go to the documentation of this file.
1 """Config flow for Zerproc."""
2 
3 import logging
4 
5 import pyzerproc
6 
7 from homeassistant.core import HomeAssistant
8 from homeassistant.helpers import config_entry_flow
9 
10 from .const import DOMAIN
11 
12 _LOGGER = logging.getLogger(__name__)
13 
14 
15 async def _async_has_devices(hass: HomeAssistant) -> bool:
16  """Return if there are devices that can be discovered."""
17  try:
18  devices = await pyzerproc.discover()
19  return len(devices) > 0
20  except pyzerproc.ZerprocException:
21  _LOGGER.exception("Unable to discover nearby Zerproc devices")
22  return False
23 
24 
25 config_entry_flow.register_discovery_flow(DOMAIN, "Zerproc", _async_has_devices)
bool _async_has_devices(HomeAssistant hass)
Definition: config_flow.py:15