core/homeassistant/components/zerproc/config_flow.py

25 lines
651 B
Python
Raw Normal View History

2020-05-12 22:26:44 +00:00
"""Config flow for Zerproc."""
import logging
import pyzerproc
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__)
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:
devices = await pyzerproc.discover()
2020-05-12 22:26:44 +00:00
return len(devices) > 0
except pyzerproc.ZerprocException:
2023-08-19 12:17:17 +00:00
_LOGGER.exception("Unable to discover nearby Zerproc devices")
2020-05-12 22:26:44 +00:00
return False
config_entry_flow.register_discovery_flow(DOMAIN, "Zerproc", _async_has_devices)