Home Assistant Unofficial Reference 2024.12.1
config_flow.py
Go to the documentation of this file.
1 """Config flow for Kuler Sky."""
2 
3 import logging
4 
5 import pykulersky
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  # Check if there are any devices that can be discovered in the network.
18  try:
19  devices = await pykulersky.discover()
20  except pykulersky.PykulerskyException as exc:
21  _LOGGER.error("Unable to discover nearby Kuler Sky devices: %s", exc)
22  return False
23  return len(devices) > 0
24 
25 
26 config_entry_flow.register_discovery_flow(DOMAIN, "Kuler Sky", _async_has_devices)
bool _async_has_devices(HomeAssistant hass)
Definition: config_flow.py:15