Izone component (#24550)
* iZone component * Rename constants to const. * Changes as per code review. * Stop listening if discovery times out. * Unload properly * Changes as per code review * Climate 1.0 * Use dispatcher instead of listener * Free air settings * Test case for config flow. * Changes as per code review * Fix error on shutdown * Changes as per code review * Lint fix * Black formatting * Black on test * Fix test * Lint fix * Formatting * Updated requirements * Remaining patches * Per code r/v
This commit is contained in:
1 parent
c8fb7ce98b
commit
b68b8430a4
16 files changed
+894
No files matched your search
@@ -0,0 +1,45 @@
|
||||
"""Config flow for izone."""
|
||||
|
||||
import logging
|
||||
import asyncio
|
||||
|
||||
from async_timeout import timeout
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.helpers import config_entry_flow
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
||||
from .const import IZONE, TIMEOUT_DISCOVERY, DISPATCH_CONTROLLER_DISCOVERED
|
||||
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def _async_has_devices(hass):
|
||||
from .discovery import async_start_discovery_service, async_stop_discovery_service
|
||||
|
||||
controller_ready = asyncio.Event()
|
||||
async_dispatcher_connect(
|
||||
hass, DISPATCH_CONTROLLER_DISCOVERED, lambda x: controller_ready.set()
|
||||
)
|
||||
|
||||
disco = await async_start_discovery_service(hass)
|
||||
|
||||
try:
|
||||
async with timeout(TIMEOUT_DISCOVERY):
|
||||
await controller_ready.wait()
|
||||
except asyncio.TimeoutError:
|
||||
pass
|
||||
|
||||
if not disco.pi_disco.controllers:
|
||||
await async_stop_discovery_service(hass)
|
||||
_LOGGER.debug("No controllers found")
|
||||
return False
|
||||
|
||||
_LOGGER.debug("Controllers %s", disco.pi_disco.controllers)
|
||||
return True
|
||||
|
||||
|
||||
config_entry_flow.register_discovery_flow(
|
||||
IZONE, "iZone Aircon", _async_has_devices, config_entries.CONN_CLASS_LOCAL_POLL
|
||||
)
|
||||
Reference in new issue
Block a user