2020-10-14 13:15:56 +00:00
|
|
|
"""Config flow for Gree."""
|
2021-04-13 09:54:03 +00:00
|
|
|
from greeclimate.discovery import Discovery
|
|
|
|
|
2020-10-14 13:15:56 +00:00
|
|
|
from homeassistant.helpers import config_entry_flow
|
|
|
|
|
2021-04-13 09:54:03 +00:00
|
|
|
from .const import DISCOVERY_TIMEOUT, DOMAIN
|
2020-10-14 13:15:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def _async_has_devices(hass) -> bool:
|
|
|
|
"""Return if there are devices that can be discovered."""
|
2021-04-13 09:54:03 +00:00
|
|
|
gree_discovery = Discovery(DISCOVERY_TIMEOUT)
|
|
|
|
devices = await gree_discovery.scan(wait_for=DISCOVERY_TIMEOUT)
|
2020-10-14 13:15:56 +00:00
|
|
|
return len(devices) > 0
|
|
|
|
|
|
|
|
|
2021-04-29 21:12:58 +00:00
|
|
|
config_entry_flow.register_discovery_flow(DOMAIN, "Gree Climate", _async_has_devices)
|