2020-05-12 22:26:44 +00:00
|
|
|
"""Config flow for Zerproc."""
|
|
|
|
import logging
|
|
|
|
|
|
|
|
import pyzerproc
|
|
|
|
|
2022-02-14 17:10:50 +00:00
|
|
|
from homeassistant.core import HomeAssistant
|
2020-05-12 22:26:44 +00:00
|
|
|
from homeassistant.helpers import config_entry_flow
|
|
|
|
|
|
|
|
from .const import DOMAIN
|
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
2022-02-14 17:10:50 +00:00
|
|
|
async def _async_has_devices(hass: HomeAssistant) -> bool:
|
2020-05-12 22:26:44 +00:00
|
|
|
"""Return if there are devices that can be discovered."""
|
|
|
|
try:
|
2020-12-19 15:35:47 +00:00
|
|
|
devices = await pyzerproc.discover()
|
2020-05-12 22:26:44 +00:00
|
|
|
return len(devices) > 0
|
|
|
|
except pyzerproc.ZerprocException:
|
|
|
|
_LOGGER.error("Unable to discover nearby Zerproc devices", exc_info=True)
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
2021-04-29 21:12:58 +00:00
|
|
|
config_entry_flow.register_discovery_flow(DOMAIN, "Zerproc", _async_has_devices)
|