- added additional logic to handle non-standard ready conditions

This commit is contained in:
Jack Simbach 2023-12-03 19:08:09 -05:00
parent 75ff9243fb
commit c2025f97e7
11 changed files with 96 additions and 32 deletions

View File

@ -35,7 +35,13 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
]
_LOGGER.debug(f'Found {len(entities):d} unregistered binary sensors')
async_add_entities(entities)
# add the ready signal and register the remove callback
coordinator.add_signal_remove_callback(
async_dispatcher_connect(hass, coordinator.signal_ready, async_devices_discovered))
#if we're already initialized at this point, call device
#discovery directly, otherwise add a callback based on the
#ready signal
if coordinator.initialized:
async_devices_discovered(coordinator.appliance_apis.values())
else:
# add the ready signal and register the remove callback
coordinator.add_signal_remove_callback(
async_dispatcher_connect(hass, coordinator.signal_ready, async_devices_discovered))

View File

@ -34,6 +34,12 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
_LOGGER.debug(f'Found {len(entities):d} unregistered buttons ')
async_add_entities(entities)
# add the ready signal and register the remove callback
coordinator.add_signal_remove_callback(
async_dispatcher_connect(hass, coordinator.signal_ready, async_devices_discovered))
#if we're already initialized at this point, call device
#discovery directly, otherwise add a callback based on the
#ready signal
if coordinator.initialized:
async_devices_discovered(coordinator.appliance_apis.values())
else:
# add the ready signal and register the remove callback
coordinator.add_signal_remove_callback(
async_dispatcher_connect(hass, coordinator.signal_ready, async_devices_discovered))

View File

@ -36,6 +36,12 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
_LOGGER.debug(f'Found {len(entities):d} unregistered climate entities')
async_add_entities(entities)
# add the ready signal and register the remove callback
coordinator.add_signal_remove_callback(
async_dispatcher_connect(hass, coordinator.signal_ready, async_devices_discovered))
#if we're already initialized at this point, call device
#discovery directly, otherwise add a callback based on the
#ready signal
if coordinator.initialized:
async_devices_discovered(coordinator.appliance_apis.values())
else:
# add the ready signal and register the remove callback
coordinator.add_signal_remove_callback(
async_dispatcher_connect(hass, coordinator.signal_ready, async_devices_discovered))

View File

@ -33,6 +33,12 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
_LOGGER.debug(f'Found {len(entities):d} unregistered humidifiers')
async_add_entities(entities)
# add the ready signal and register the remove callback
coordinator.add_signal_remove_callback(
async_dispatcher_connect(hass, coordinator.signal_ready, async_devices_discovered))
#if we're already initialized at this point, call device
#discovery directly, otherwise add a callback based on the
#ready signal
if coordinator.initialized:
async_devices_discovered(coordinator.appliance_apis.values())
else:
# add the ready signal and register the remove callback
coordinator.add_signal_remove_callback(
async_dispatcher_connect(hass, coordinator.signal_ready, async_devices_discovered))

View File

@ -37,6 +37,12 @@ async def async_setup_entry(
_LOGGER.debug(f"Found {len(entities):d} unregistered lights")
async_add_entities(entities)
# add the ready signal and register the remove callback
coordinator.add_signal_remove_callback(
async_dispatcher_connect(hass, coordinator.signal_ready, async_devices_discovered))
#if we're already initialized at this point, call device
#discovery directly, otherwise add a callback based on the
#ready signal
if coordinator.initialized:
async_devices_discovered(coordinator.appliance_apis.values())
else:
# add the ready signal and register the remove callback
coordinator.add_signal_remove_callback(
async_dispatcher_connect(hass, coordinator.signal_ready, async_devices_discovered))

View File

@ -34,6 +34,12 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
_LOGGER.debug(f'Found {len(entities):d} unregisterd numbers')
async_add_entities(entities)
# add the ready signal and register the remove callback
coordinator.add_signal_remove_callback(
async_dispatcher_connect(hass, coordinator.signal_ready, async_devices_discovered))
#if we're already initialized at this point, call device
#discovery directly, otherwise add a callback based on the
#ready signal
if coordinator.initialized:
async_devices_discovered(coordinator.appliance_apis.values())
else:
# add the ready signal and register the remove callback
coordinator.add_signal_remove_callback(
async_dispatcher_connect(hass, coordinator.signal_ready, async_devices_discovered))

View File

@ -37,6 +37,12 @@ async def async_setup_entry(
_LOGGER.debug(f"Found {len(entities):d} unregistered selects")
async_add_entities(entities)
# add the ready signal and register the remove callback
coordinator.add_signal_remove_callback(
async_dispatcher_connect(hass, coordinator.signal_ready, async_devices_discovered))
#if we're already initialized at this point, call device
#discovery directly, otherwise add a callback based on the
#ready signal
if coordinator.initialized:
async_devices_discovered(coordinator.appliance_apis.values())
else:
# add the ready signal and register the remove callback
coordinator.add_signal_remove_callback(
async_dispatcher_connect(hass, coordinator.signal_ready, async_devices_discovered))

View File

@ -47,9 +47,15 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
_LOGGER.debug(f'Found {len(entities):d} unregistered sensors')
async_add_entities(entities)
# add the ready signal and register the remove callback
coordinator.add_signal_remove_callback(
async_dispatcher_connect(hass, coordinator.signal_ready, async_devices_discovered))
#if we're already initialized at this point, call device
#discovery directly, otherwise add a callback based on the
#ready signal
if coordinator.initialized:
async_devices_discovered(coordinator.appliance_apis.values())
else:
# add the ready signal and register the remove callback
coordinator.add_signal_remove_callback(
async_dispatcher_connect(hass, coordinator.signal_ready, async_devices_discovered))
# register set_timer entity service
platform.async_register_entity_service(

View File

@ -33,6 +33,12 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
_LOGGER.debug(f'Found {len(entities):d} unregistered switches')
async_add_entities(entities)
# add the ready signal and register the remove callback
coordinator.add_signal_remove_callback(
async_dispatcher_connect(hass, coordinator.signal_ready, async_devices_discovered))
#if we're already initialized at this point, call device
#discovery directly, otherwise add a callback based on the
#ready signal
if coordinator.initialized:
async_devices_discovered(coordinator.appliance_apis.values())
else:
# add the ready signal and register the remove callback
coordinator.add_signal_remove_callback(
async_dispatcher_connect(hass, coordinator.signal_ready, async_devices_discovered))

View File

@ -112,7 +112,11 @@ class GeHomeUpdateCoordinator(DataUpdateCoordinator):
@property
def signal_ready(self) -> str:
"""Event specific per entry to signal readiness"""
return f"{DOMAIN}-ready-{self._config_entry.entry_id}"
return f"{DOMAIN}-ready-{self._config_entry.entry_id}"
@property
def initialized(self) -> bool:
return self._init_done
@property
def online(self) -> bool:

View File

@ -35,6 +35,12 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
_LOGGER.debug(f'Found {len(entities):d} unregistered water heaters')
async_add_entities(entities)
# add the ready signal and register the remove callback
coordinator.add_signal_remove_callback(
async_dispatcher_connect(hass, coordinator.signal_ready, async_devices_discovered))
#if we're already initialized at this point, call device
#discovery directly, otherwise add a callback based on the
#ready signal
if coordinator.initialized:
async_devices_discovered(coordinator.appliance_apis.values())
else:
# add the ready signal and register the remove callback
coordinator.add_signal_remove_callback(
async_dispatcher_connect(hass, coordinator.signal_ready, async_devices_discovered))