ha-device-registry-augment¶
Wires the device-registry hierarchy — DeviceInfo, via_device hub-to-child links, runtime device add, and stale-device removal — so entities group into proper devices.
Wire the device-registry hierarchy of an existing Home Assistant Custom Integration so entities group into proper devices — DeviceInfo with identifiers / manufacturer / model / name, a via_device hub-to-child parent link, runtime addition of newly discovered devices, and removal of stale devices via async_remove_config_entry_device. Optionally adds async_get_device_diagnostics. Targets the Gold devices, stale-devices, dynamic-devices rules. Non-destructive to existing entities. Activate on phrasings like "group these entities into a device", "add a hub device with child devices via_device", "remove stale devices when they disappear", "gruppiere die Entitäten zu einem Gerät", "füge ein Hub-Gerät mit Kindgeräten hinzu". Do not activate for creating entity platforms (ha-entity-platform-add), config-entry diagnostics (ha-diagnostics-augment), device trigger/condition/action automations (ha-device-automation-add), greenfield scaffolding (ha-integration-scaffold), or deploying to a live HA instance.
- Plugin:
claude-home-assistant - Phase: 3 Design (
design) - Tags:
home-assistant,custom-integration,device-registry - Source: skills/ha-device-registry-augment/SKILL.md
Use when¶
- you want to group entities into a device
- you want a hub device with via_device child devices
- you want stale devices removed when they disappear
Don't use when¶
- You are creating the entity platform itself →
ha-entity-platform-add - You want config-entry diagnostics, not device wiring →
ha-diagnostics-augment - You want device trigger/condition/action automations →
ha-device-automation-add - You are scaffolding a brand-new integration from scratch →
ha-integration-scaffold
See also¶
ha-entity-platform-addha-entity-description-mapperha-diagnostics-augmentha-device-automation-addha-coordinator-add
Referenced by¶
HA Device Registry Augment¶
Spec: https://github.com/nolte/claude-home-assistant/blob/develop/spec/claude/ha-device-registry-augment/de.md (DE canonical) / en.md.
This skill owns the device-registry hierarchy — DeviceInfo, via_device, dynamic device add, and stale device removal — that ha/entity-architecture describes but no skill wires. It lifts an integration from flat entities toward the Gold devices / stale-devices / dynamic-devices rules.
Why this is a skill, not an agent¶
- Human-visible augmentation surface — the user describes the device topology and reads back the
DeviceInfowiring, thevia_devicelink, and the removal path; a skill keeps this on the visible command surface, like the sibling augment skills. - Mid-flow interactivity — the device topology (one device, a hub with children, per-datapoint devices), the identifier source, and whether stale-device removal applies are per-run dialogues the user confirms.
- Bounded, inline generation — the
DeviceInfoconstruction plus the removal hook fits inline; no isolated agent context is needed. - Counter-dimension considered: the draft→validate loop could be an agent, but the topology decision and the report belong in the user's working context; skill wins.
When this skill activates¶
Use this skill when an existing integration's entities should group into one or more devices — a single device, a hub with via_device children, or per-physical-device grouping — and when devices that disappear from the backend must be removed from the registry.
When NOT to activate¶
- creating the entity platform itself →
ha-entity-platform-add/ha-entity-description-mapper - config-entry diagnostics (the JSON dump) →
ha-diagnostics-augment - device trigger / condition / action automation platforms →
ha-device-automation-add - greenfield integration setup →
ha-integration-scaffold - deploying/importing into a running HA instance → out of scope (generation only)
Hard rules¶
- Non-destructive. Do not rewrite entity logic; add or complete the
DeviceInfo/ registry wiring only. Existingunique_ids stay unchanged so entities keep their registry entries. DeviceInfocarries the identity. Every device setsidentifiers={(DOMAIN, <stable_device_id>)}plusmanufacturer,model,name, andsw_version/hw_versionwhen known. Entities attach via the entity's_attr_device_info(ordevice_infoproperty) — never by manually creating a device the entity does not reference.via_devicefor a hierarchy. A child device attached to a hub setsvia_device=(DOMAIN, <hub_device_id>); the hub device is registered first (via a hub entity ordevice_registry.async_get_or_create). Never invent avia_devicelink to a device outside this integration.- Dynamic devices. When the backend can gain devices at runtime, add them from the coordinator update (create the new entities/devices on discovery) rather than only at setup — the Gold
dynamic-devicesrule. - Stale device removal. Implement
async_remove_config_entry_device(hass, config_entry, device_entry) -> boolreturningTruewhen the device is no longer present in the integration's data, so HA lets the user delete it (the Goldstale-devicesrule). Do not auto-delete a device that is merely temporarily unavailable. - Device diagnostics are optional. Add
async_get_device_diagnostics(hass, entry, device)only on request; route its data throughasync_redact_dataperha/diagnostics/ha/security-hardening. - Name per
ha/naming-conventions, followha/device-registryandha/entity-architecture, and verify HA internals against the official docs (seeha/upstream-docs-verification).
Inputs¶
| Field | Required | Default | Notes |
|---|---|---|---|
target_dir |
yes | — | repo root of the existing integration |
topology |
yes | — | single / hub-and-children / per-device |
identifier_source |
yes | — | the stable per-device id from the backend (serial, id, MAC, …) |
stale_removal |
no | inferred + confirmed | whether devices can disappear and must be removable |
device_diagnostics |
no | false |
add async_get_device_diagnostics |
Pre-flight (in order — abort on first failure)¶
git -C <target_dir> rev-parse --is-inside-work-treeand a clean working tree.custom_components/<domain>/carries at least one entity platform; readdomainand the coordinator/entity shape.- Resolve the
topology, theidentifier_source, and whetherstale_removalapplies.
Workflow¶
1) Resolve and confirm¶
State domain, the topology, the identifier source, whether stale removal and device diagnostics apply, in one paragraph. Wait for confirmation.
2) Apply¶
entity.py(or the base entity) — set_attr_device_info = DeviceInfo(identifiers=…, manufacturer=…, model=…, name=…, via_device=…)__init__.py—async_remove_config_entry_devicewhenstale_removal; hubdevice_registry.async_get_or_createwhen a hub has no own entity- the coordinator / setup — dynamic-device add on discovery when the backend can gain devices
diagnostics.py—async_get_device_diagnostics(redacted) whendevice_diagnosticstests/— a device-registry test asserting the device(s), thevia_devicelink, and (when applicable) the stale-removal predicate
3) Validate & report¶
Validate offline (DeviceInfo identifiers/manufacturer/model/name present; via_device points inside the integration; async_remove_config_entry_device present when stale_removal; device diagnostics redacted when present) and emit a CONFORMANT / NEEDS-WORK report keyed to the acceptance criteria plus the changed file paths and the quality-scale marker (Gold — devices, stale-devices, dynamic-devices).
Boundaries¶
- Entity platform creation →
ha-entity-platform-add/ha-entity-description-mapper - Config-entry diagnostics dump →
ha-diagnostics-augment - Device trigger/condition/action automations →
ha-device-automation-add