plugins/home-assistant-dev/skills/ha-entity-lifecycle/SKILL.md
Entity lifecycle and device/entity registries in Home Assistant. Use when asking about entity registration, async_added_to_hass, async_will_remove_from_hass, device_info, identifiers, or restoring previous state.
npx skillsauth add l3digitalnet/claude-code-plugins ha-entity-lifecycleInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
async_setup_entry called on platformasync_add_entitiesentity_id, registers in entity registryasync_added_to_hass called, initial state written_handle_coordinator_updateasync_will_remove_from_hass for cleanupclass 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
async def async_will_remove_from_hass(self) -> None:
await super().async_will_remove_from_hass()
# Cleanup resources
Device registry groups entities under physical/logical devices:
from homeassistant.helpers.device_registry import DeviceInfo
@property
def device_info(self) -> DeviceInfo:
return DeviceInfo(
identifiers={(DOMAIN, self._serial)}, # Stable, unique tuple
name="My Device",
manufacturer="Acme",
model="Widget Pro",
sw_version="1.2.3",
configuration_url="http://192.168.1.100",
)
identifiers must be stable across restarts — this is how HA knows entities belong together and avoids creating duplicate device entries.
development
Use when you're stuck or missing current information mid-task - the same command/API/approach failed twice, an error looks like a changed or deprecated API, or you need the current version of something, a fact from after your training cutoff, or to verify something you cannot confirm from the code in context. Starts with a cheap inline lookup and only escalates to a full research sweep if that fails. Do not use for routine pre-emptive checks before ordinary library work - for deliberate research, use /qdev:research.
documentation
Update Outline wiki documentation with implementation-level details from the current session by dispatching the up-docs-propagate-wiki sub-agent. This skill should be used when the user runs /up-docs:wiki.
documentation
Update repository documentation (README.md, docs/, CLAUDE.md) based on session changes by dispatching the up-docs-propagate-repo sub-agent. This skill should be used when the user runs /up-docs:repo.
documentation
Update Notion pages with strategic and organizational context from the current session by dispatching the up-docs-propagate-notion sub-agent. This skill should be used when the user runs /up-docs:notion.