INNER CODE UNIT · Python
async_on_home_assistant_started
dummylabs/thewatchman · custom_components/watchman/__init__.py:87
async def async_on_home_assistant_started(event: Event | None) -> None: # pylint: disable=unused-argument
"""Update watchman sensors and start listening to HA events when Home Assistant started."""
# Guard Clause: Check if integration is still loaded
if DOMAIN_DATA not in hass.data or hass.data[DOMAIN_DATA].get("config_entry_id") != config_entry.entry_id:
_LOGGER.debug("Skipping async_on_home_assistant_started: Integration unloaded.")
return
# prime the coordinator with cached data immediately to minimize startup delay
try:
_LOGGER.debug("HA is ready. Prime coordinator with cached data.")
all_items = await hub.async_get_all_items()
parsed_entities = all_items["entities"]
parsed_services = all_items["services"]
initial_data = await coordinator.async_process_parsed_data(
parsed_entities, parsed_services
)
coordinator.async_set_updated_data(initial_data)
except Exception as e: