Use when searching or resolving Home Assistant entities by name, room, or domain through HA NOVA Relay, and live state snapshots across a domain — what is open, on, running, locked, who is home, averages and totals right now.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Entity Discovery?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/markusleben-entity-discovery)
---
name: entity-discovery
description: Use when searching or resolving Home Assistant entities by name, room, or domain through HA NOVA Relay, and live state snapshots across a domain — what is open, on, running, locked, who is home, averages and totals right now.
license: MIT
compatibility: Requires the ha-nova CLI (run 'ha-nova setup' first) and the HA NOVA Relay in Home Assistant (App, or standalone container on Container/Core).
---
# HA NOVA Entity Discovery
## Scope
Use for:
- listing entities by domain
- searching entities by user phrase
- bulk inventory by `prefix`, `domain`, `area`, or `label`
- resolving likely targets before writes
Read-only behavior.
- No `POST`, `PUT`, `PATCH`, or `DELETE` relay writes. A `POST /api/template` render is a read.
- When the user asks for a change with one clear target: hand off to the write-capable skill in the same turn; ask only what that skill requires.
## Bootstrap (once per session)
Read and follow `../ha-nova/session-bootstrap.md`.
## Relay Contract
Use file-based relay requests by default:
- `ha-nova relay ws --data-file <payload-file>`
- `ha-nova relay core --method <METHOD> --path <PATH> --body-file <payload-file>` when a body is needed
- `--jq-file <filter-file>` for non-trivial filters; keep inline `--jq` for short selectors only
- `--out <result-file>` for large reads
- On Windows PowerShell, never chain commands with `&&` or `||`.
- Never call external `jq`; use relay-native filters or `ha-nova relay jq --file <result-file> ...`.
## Flow
### Step 1: Resolve a name — `ha-nova find`
```text
ha-nova find "<the user's phrase>" [--domain <d>] [--area <area_id>] [--state <s>] [--limit 20]
ha-nova find --domain <d> [--area <area_id>] [--state <s>]
```
Every word of the phrase must match the entity_id, name, or area,
case- and accent-insensitive; aliases are read automatically when names miss.
The result carries `total` (exact), `returned`, and `matches[]` with each
match basis (`by`: `name`, `alias`, or `state` for unregistered).
- **If the match does not resolve a suitable target** — no results, or only matches the user rejects or that plainly are not what they meant — re-run ONCE with `--aliases` (aliases searched even when a name matched): households keep their everyday names there. Only then try synonyms, alternative terms, or shorter words, one `find` each. When a resolved entity had no matching alias and the user's word was clearly their habitual name, offer once to store it as an alias via `ha-nova:organize`.
- `--include-disabled` when a disabled entity may be the target (it reads the full registry).
- Multi-server: `--server <name>` on every command but `apply`; name a non-default server once per response.
- A room, area, or device request handed to `ha-nova:service-call` travels as its `area_id`/`device_id` (`--area`/`--device`), never as a list of entity ids you expanded. A device target also reaches its direct child devices (`parent_device_id`): a named parent qualifies even when only its children act; a named child is targeted alone.
- **Fail closed on truncation:** while `returned` is below `total` the result proves neither absence nor uniqueness — narrow (`--domain`, `--area`, more words) until `total` fits before concluding either; report total/shown/omitted with the rows.
### Step 1b: Bulk inventory — raw relay
`find` matches phrases; `prefix`, `label`, and domain-count inventories use the
relay. For bulk selectors, follow `../ha-nova/bulk-patterns.md`.
- `prefix`: case-insensitive prefix match on the entity_id suffix and display name
- `domain`: exact domain filter
- `area`: resolve the area, then use `search/related` as the primary shortlist source; use `ai` only as optional extra evidence when present
- `label`: escalate to the full registry only when label evidence is required; `config/entity_registry/list` returns the entity array directly in `.data`
- `helper` + `area`: not a first-class bulk selector contract; do not imply room-owned helper discovery unless live helper-area semantics are explicitly defined
For domain counts or domain shortlists:
- count only the requested domain unless the user explicitly asks for heuristics or related domains
- use `--jq-file <filter-file>` for the count filter
- if you need a follow-up count from a saved file, use `ha-nova relay jq --file <result-file> length`
Entity registry uses compact abbreviated keys: `ei`=entity_id, `en`=name, `ai`=area_id.
Create `<payload-file>` with `{"type":"config/entity_registry/list_for_display"}`, then run:
```text
ha-nova relay ws --data-file <payload-file> --jq-file <filter-file>
```
Write `<filter-file>` by copying the canonical `../ha-nova/discovery-filter.jq`
and replacing `KEYWORD` with the pattern; if the canonical file is unavailable
(flat-copy installs), recreate it with exactly:
```jq
[.data.entities[] | select((.ei + " " + (.en // "")) | test("KEYWORD";"i")) | {entity_id: .ei, name: .en, area_id: .ai}]
| {total: length, shown: (.[0:20] | length), omitted: ([length - 20, 0] | max), truncated: (length > 20), matches: .[0:20]}
```
It returns `{total, shown, omitted, truncated, matches}` — the 20-row cap
applies to `matches` only; the counts are exact. This generic filter is for free-text search, not explicit `prefix` matching;
an explicit prefix selector matches the suffix and display name with `startswith(...)`.
**Fail closed on truncation:** while `truncated` is true the result proves neither absence nor uniqueness — narrow until `truncated` is false before concluding either.
**Never** dump entire domains without a user-intent keyword, and never show an unfiltered full-registry dump.
When the task is multi-target inventory:
- save the shortlist with `--out <result-file>`
- do not trim to 20 inside the initial selector filter
- dedupe first, then sort deterministically, then compute the exact matched count, then apply the 20-row display cap
- keep ordering deterministic: domain, then entity_id
- return the exact matched count separately from the displayed rows
### Step 2: Get state or config — `ha-nova get`
```text
ha-nova get <entity_id> # state and attributes
ha-nova get <entity_id> --config # automation/script/scene config, resolved by unique_id, never the slug
ha-nova get <entity_id> --related # search/related for the entity
ha-nova history <entity_id> [--since 24h] [--logbook] # recent changes, summarized
```
### Step 3: Find automations related to a device or area
Automations rarely have reliable direct `area_id` data in the compact registry. When user asks "automations for X in room Y":
1. Resolve room name to area_id:
`ha-nova relay ws --data-file <payload-file>` then filter by name with `--jq`
2. Query the area directly:
`{"type":"search/related","item_type":"area","item_id":"<area_id>"}`
3. Treat the response as a keyed object, not an array:
- automation discovery uses `.data.automation`
- script discovery uses `.data.script`
- entity discovery uses `.data.entity`
4. If automation/script keys are absent and only area entities are present, use `search/related` on those entities to derive the automation/script shortlist:
```text
ha-nova relay ws --data-file <payload-file>
```
### Step 4: Return shortlist
- the name as Home Assistant shows it (verbatim), `state` (if fetched), short relevance reason; `entity_id` only for a missing or clashing name
- for bulk inventory: matched count, displayed rows
- do not fetch full YAML for every matched item in one response
### Device-sibling capability discovery
A capability-oriented request (restart, identify, calibrate, reset, siren, ...) on a resolved entity or device, where the capability is not on the resolved entity itself, is answered by the device's OTHER entities — not by "the entity cannot do that":
1. Resolve the physical device: for an entity target, read its registry row (WS `config/entity_registry/get`) and take its `device_id`; a target already resolved AS a device (a device-registry row or config-entry device) supplies its `device_id` directly — no entity row is required to proceed.
2. List ALL registry entities of that device from the FULL registry (`config/entity_registry/list`, filter by `device_id`) — `list_for_display` omits disabled entities, and the registry row's `disabled_by` decides enabled/disabled status. NEVER validate a disabled candidate through `/api/states`: it has no state there, and its absence proves nothing about the capability. The 20-row display envelope does NOT apply: capping could hide the one capability past the cap.
3. Select by domain, `device_class`, `translation_key`, and entity_id semantics on the SAME device. An entity on another device never qualifies merely because its name matches.
4. Prefer an enabled exact match. Multiple plausible candidates → ONE bounded clarification listing each candidate by name, device, and whether it is disabled (entity ID only on a name clash).
5. Report a disabled candidate as available-but-disabled WITH its `disabled_by` source and offer the matching enable flow via `ha-nova:organize` (a `"device"`-disabled sibling needs its parent DEVICE re-enabled, not the entity alone; `"integration"` (off by default) enables like `"user"`; `"config_entry"` follows its integration (`ha-nova:integration-setup`)). Never enable anything automatically, and never press or execute from discovery — hand off to the owning skill.
This contract is generic — never hard-coded to a brand, to cameras, or to restart buttons.
## State Snapshot Queries
"is everything closed?", "who is home?", "what is running right now?" — these ask
about STATE across many entities, not about finding one. They are reads and
belong here; `ha-nova:health` answers what is broken, not what is on.
An average, total, or highest value right now: `computed-answers.md` (one template render, read-only).
By domain and state: `ha-nova find --domain light --state on` (rows carry the current
`state`); a second `find` with `--state unavailable` (and
`unknown`) fills the third bucket. A
`device_class` filter needs one raw read, `ha-nova relay core --method GET --path /api/states --out <result-file>`,
filtered by domain, `device_class`, and state:
```jq
[.data.body[]
| select(.attributes.device_class == "window" and .state == "on")
| {e: .entity_id, n: .attributes.friendly_name}]
```
Three answers, not two: **yes / no / could not tell**. An entity that is
`unknown` or `unavailable`, and one that is readable but does not report the
thing being asked, both go in the third bucket and get named. "Everything is
closed" with three sensors offline is false reassurance — "none open, 3 could
not be read" is the honest form.
Count group helpers separately: a Light Group is a real `light.*` entity
beside its members, so it double-counts. `find` marks one `group: true`; raw reads
show an `attributes.entity_id` array.
(`switch_as_x` mirrors double-count too and carry no such marker; say so if
the count looks high.)
- **open windows/doors** — `binary_sensor` with `device_class`
`window`/`door`/`garage_door`/`opening` (the generic contact class) in state
`on`, AND `cover.*` in `open`/`opening`/`closing` (mid-close is still open)
with the COVER classes, which are named differently: `garage` — not the
binary sensor's `garage_door` — plus `door`, `window`, `gate`. A motorized
window is a cover, not a binary_sensor, so checking one family answers the
question wrong. A cover in those states whose `device_class` is absent or
outside that list is not evidence of closed: report it as "N open, class
unknown". Do NOT do the same for unclassed binary sensors — one is
indistinguishable from a motion sensor and would manufacture false alarms.
- **who is home** — `person.*` in state `home`. Anything else that is not
`unknown`/`unavailable` is away, including a named zone like `work`: those
are zone names, not errors. `unknown` means no tracker had usable data —
third bucket, because "nobody is home" from a dropped phone is how an alarm
gets armed on someone. (This skill owns person STATE reads; `ha-nova:admin`
owns creating and editing them.)
- **unlocked doors** — `lock.*` in any state that is not `locked` and not
`unavailable`/`unknown`, AND `binary_sensor` with `device_class: lock` in
state `on`, which reports `on` for UNLOCKED — the reverse of every other
class here. Name the state each one is in rather than flattening them to
"unlocked": jammed and mid-travel are not secured, and they are what a user
needs to hear.
- **is everything OFF** — `light`/`switch`/`fan`/`siren`/`remote` in `on`
(a Harmony-style `remote` in `on` means an AV activity is live);
`media_player` in anything but `off`/`standby`/`unavailable`/`unknown`
(paused and idle are not off; `standby` IS — Home Assistant core deprecates
it as meaning off-or-idle, and users call that TV off);
`binary_sensor` with `device_class` `running` or `moving` in `on`;
`script` in `on` and `automation` with `attributes.current > 0` — both are
actually executing, and the RUNNING list counts them, so leaving them out
here would let "is everything off?" say yes to something "what is running?"
names in the same breath;
`climate`/`water_heater`/`humidifier` in any state but
`off`/`unavailable`/`unknown` — an unreachable one is not off, it goes in
the third bucket;
`vacuum` and `lawn_mower` in `cleaning`/`mowing`/`returning`/`paused`/`error`
— `error` means stranded mid-floor, not put away, and it is readable so the
unavailable rule never catches it; `valve` in `open`/`opening`/`closing`;
`cover` only in `opening`/`closing` — a cover left open is answered by the
open-windows question above, not by this one, because it consumes nothing.
- **what is RUNNING** — narrower, and everything in it is also in OFF above;
keep that invariant when either list changes. Same lights, switches, fans,
sirens and `binary_sensor` `running`, plus `device_class: moving`; but
`media_player` only in `playing`/`buffering`; `vacuum`/`lawn_mower` only in
`cleaning`/`mowing`/`returning` (report `error` as stuck, not as running);
`valve` in `open`/`opening`/`closing`; `cover` in `opening`/`closing` only —
a motor turning is running, a cover left open is not.
- `climate` runs when `hvac_action` is PRESENT and not `off`/`idle`
(heating, cooling, drying, fan, preheating, defrosting).
- `humidifier` has the same shape under a different key: `attributes.action`
PRESENT and not `off`/`idle`.
- `water_heater` has NO action attribute at all — its state is an operation
mode (`eco`, `performance`, `heat_pump`, ...), which reports enablement and
never activity. It can never be proven running: enabled goes in the third
bucket, never in "nothing is running".
- An ABSENT action attribute is the third bucket too, not a no. Most simple
thermostats never publish one, and "nothing is running" while the heat pump
runs is the failure this whole section exists to prevent.
- `automation` in `on` means ENABLED, not running — exclude it, or the answer
is "47 things are running". Its real running signal is
`attributes.current > 0`. `script` in `on` does mean running.
Answer count-first ("2 windows open: kitchen, bathroom"), then the names, in the List
Frame. This is a summary, not the banned domain dump. A follow-up "and which are
closed?" is a fresh read, not a cached list.
## Matching Rules
- area-first bulk discovery by room/area uses `search/related` on the resolved area before keyword heuristics
- exact `entity_id` match wins
- keyword match on entity_id + name second; rank whole-word and name matches above bare substring hits
If ambiguity remains: present top candidates (max 10) and state the match basis for each (name, alias, area; the id only if it alone matched) — the user must see WHY a candidate matched; then ask one selection question.
## Output Format
Apply `../ha-nova/output-rules.md`: plain words, HA names verbatim; unless asked or names clash, no ids, "entity", modes, Relay/HA URLs, snapshots, raw JSON.
Render the Step 4 shortlist as the List Frame (output-cards.md). Never dump raw states.
## Safety
- Read-only skill: never issue mutating relay or service calls.
- For write intent, hand off to the owning skill; unfamiliar writes go through `ha-nova:fallback` first.
- All communication with Home Assistant goes through `ha-nova relay` exclusively.
## Guardrails
- never guess entity IDs
- cap displayed shortlist rows at 20 only after exact matched-count computation for bulk inventory
- no proactive doctor before real failure