ha-entity-lifecycle

Installation
SKILL.md

Home Assistant — Entity Lifecycle and Registries

Entity Lifecycle

  1. Platform discovery: async_setup_entry called on platform
  2. Entity creation: Entities instantiated, passed to async_add_entities
  3. Registration: HA assigns entity_id, registers in entity registry
  4. First update: async_added_to_hass called, initial state written
  5. Updates: Coordinator triggers _handle_coordinator_update
  6. Removal: async_will_remove_from_hass for cleanup
class MyEntity(CoordinatorEntity):
    async def async_added_to_hass(self) -> None:
        await super().async_added_to_hass()
        # Restore previous state
        if (last_state := await self.async_get_last_state()) is not None:
            self._attr_native_value = last_state.state
Related skills
Installs
4
GitHub Stars
5
First Seen
Mar 18, 2026