Service call

From markusleben/ha-nova · View interactive version

Service call is an AI agent skill from the GitHub repository markusleben/ha-nova. Use when the user wants to control something in Home Assistant right now — turn lights, switches, modes ("guest mode"), covers, climate, vacuums, or any device on, off, up, down, open, or closed; run a scene, script, or automation; call any service by name; operate alarm panels and locks — through H

How to use this skill

Skill file

HA NOVA Service Call

Scope

Run Home Assistant services now. No config mutations (ha-nova:write, ha-nova:helper, ha-nova:scene).

Bootstrap (once per session)

Read and follow ../ha-nova/session-bootstrap.md. No health probe; exit 1 RELAY_ERROR → ha-nova setup or ha-nova:onboarding. Multi-server: --server <name> on every command but apply; name a non-default server once per response.

Relay Contract

Entity service calls run only through the typed verbs:

--set values are JSON-typed; --data-file takes a JSON object. The CLI sends exactly one POST /api/services/{domain}/{service} and verifies via /api/states/{entity_id}. Raw ha-nova relay core|ws: only the routes in ../service-call/raw-routes.md.

Owning-Skill Deferrals (Critical)

"Call any service" never overrides a stricter owning skill. A call bounded by a duration ("for 30 minutes") whose service has NO duration field goes to ha-nova:write; timer.start/timer.change and siren.turn_on with their own duration stay here. The CLI refuses every other owned service (exit 4, OWNED_SERVICE) and names the owner: STOP and continue there. Full table: raw-routes.md.

Read-only response services stay here (raw-routes.md → Response services), as do scene.turn_on/scene.apply (ha-nova:scene owns scene CRUD, not activation), automation.trigger, and script.*.

Flow

  1. Target. Entity services need a target (exit 4 TARGET_REQUIRED). An exact entity_id when known; otherwise --match "<the entity phrase only>" (every word must match). A room, area, or device phrase always uses --area <area_id>/--device <device_id> (they expand to concrete entities and preview, except room lights or one entity of the service's domain) — never expand it into entity ids yourself; explicit ids (up to 10) are only for entities the USER named. A whole-domain request ("all lights off"): the ids from ha-nova find --domain light --state on --limit 200 (narrow first if returned < total) → one plan call preview, no pre-question; none: say so. A room request: ask one clarifying question before using area_id only when the user names ONE device by a type ("the lamp in the kitchen") that several entities there match, then use the narrower confirmed target; no second blocking ambiguity question this turn. Direct floor_id and label_id selectors are unsupported — ask for an entity, area, or device instead. A capability the entity lacks (restart, identify, …): run ha-nova:entity-discovery → Device-sibling capability discovery before concluding the capability does not exist.
  2. Data. When unsure of a field, its unit, or a feature bit, read the section for the domain you are calling in ../service-call/domain-fields.md. /api/services gives field NAMES (list them via raw-routes.md); valid effect, mode, and preset values come from the target's own attributes (ha-nova get <entity_id>). Never carry a value over from another device; unsupported parameters are dropped silently rather than rejected. Relative asks ("a bit brighter") and any input_number value change: read domain-fields.md → Relative Asks And Helper Values first; a helper with threshold consumers goes through ha-nova plan call (plan.confirm: none: apply now), never call.
  3. Run ha-nova call … once and act on its exit code; before homeassistant.restart, reload_all, or hassio.host_reboot|shutdown: raw-routes.md → Config Check First:

| Exit | Meaning | Do |

|---|---|---|

| 0 | tier: ordinary — sent once and checked | Relay say. |

| 3 | plan.confirm: natural | Show the preview; after the user confirms it, run ha-nova apply --plan <id> — apply IS the confirmation step. |

| 3 | plan.confirm: code | Show the preview ending with say; only after a reply that is only that code, run ha-nova apply --confirm <the user's text> --plan <id>. No plan.code (a form, window, or phone asks): follow next_step. |

| 2 | drift since the preview, nothing sent | Show the new preview (typed: new code) and ask again; a relative ask re-derives its value and runs a fresh call. |

| 4 | refused | reasons[] (an owner skill wins over hassio): owner skill; TARGET_REQUIRED → resolve targets first; SERVICE_NOT_FOUND → offer error.next's candidates; SERVICE_LIST_UNREAD → plan again; CODE_REQUIRED → finish the action in the Home Assistant UI; missing feature → the device cannot do it; hassio or response-only → raw-routes.md. error from apply: CODE_REQUIRED/CODE_MISMATCH → ask for the code again; any other → follow error.next, never a re-call; PLAN_NOT_FOUND/PLAN_CLAIMED: outcome unknown, never re-plan. |

| 5 | ambiguous or not found | One question listing error.candidates (max 10, else narrow) with each match basis; re-run with the choice. No candidates: say nothing matched; follow error.next. |

| 6 | sent; unverified or failed | Relay say (none: the error, per Verb Results); never retry automatically, resend, or swap the target; a new attempt needs the user's request. |

| 7 | outcome unknown | Relay say, then read the state (ha-nova get) and name it; still unknown even if it matches; never retry. |

| 1 | operational error, nothing sent | say if any; else what failed, why, next step. |

  1. Confirm (exit 3). The CLI decides the tier; never lower it, split a call to dodge it, or replay it through ha-nova relay.
  1. A grouped change set (../ha-nova/grouped-change-set.md) plans each call with ha-nova plan call and, after the set's one confirmation, runs ha-nova apply --plan <id> per plan; a typed-tier plan leaves the set, and any exit 2 stops the set for a fresh preview.
  2. A user's physical action never verifies a service call this skill sent: read the baseline BEFORE the instruction, give one exact "act now" instruction, then attribute the result to the user's action, not to the call.
  3. After a VERIFIED multi-entity call likely to repeat, offer once to save it as a scene (ha-nova:scene, create-from-current-state) or script (ha-nova:write). After a single decline, stay silent about it for the session.

Automation And Script Runtime Calls

automation.trigger, direct script execution (script.<script_id>), and script.turn_on run sequences the CLI previews.

Error Handling

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.

Results (exit 0, 6, 7, and after apply) use its Verb Results rule. After apply, read the members[] the preview named that say doesn't (the door a mode unlocks) and say their state; a delayed step may still change it. A preview (exit 2 or 3) closes with say (names, a single target's arrow one-liner, warnings, an explicit not-executed-yet line); with several targets, more become the Field | Before | After mini table, warnings kept; on the typed tier only say's ask — no menu. A grouped set or Test Plan Card asks once instead of say's last sentence, except on the typed tier.

Safety

Guardrails

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.