Home Assistant Ops
Use scripts/ha_ops.ts directly. It uses Bun, the exact mise x -- bun --install=fallback shebang, and Crust subcommands.
Safety workflow
- Inventory the current state.
- Produce an explicit change set.
- Run a dry plan.
- Apply only after review.
- Validate the target behavior.
- Keep a timestamped log and rollback mapping.
Set HA_URL and HA_TOKEN in the environment. Never pass tokens on the command line.
./scripts/ha_ops.ts --help
./scripts/ha_ops.ts doctor
./scripts/ha_ops.ts cleanup --help
./scripts/ha_ops.ts snapshot
./scripts/ha_ops.ts validate-record <snapshot.json>
./scripts/ha_ops.ts rollback <snapshot.json> --dry-run
./scripts/ha_ops.ts find-references --needle switch.bedroom_lights
./scripts/ha_ops.ts traces --help
./scripts/ha_ops.ts tail-events --help
./scripts/ha_ops.ts name-review-from-backup --help
cleanup is dry-run by default. Use --apply to mutate Home Assistant. The existing operation groups preserve their plan/apply/validate behavior: cleanup, snapshot, rollback, find-references, traces, tail-events, and name-review-from-backup.
The script requires Bun, Home Assistant access, and the external API/WebSocket services. Bun fallback installation resolves the CLI framework and shared contract validator dependencies. Offline record validation does not require Home Assistant access.
cleanup --json produces homeassistant-cleanup-plan/v2. Validate saved plans with scripts/ha_ops.ts validate-record <plan.json>. The reader accepts historical unversioned plans without rewriting them. JSON planning never applies changes; a saved plan does not grant approval. See references/contracts.md for fields and compatibility.
Resources
references/api.mdreferences/playbook.mdreferences/id_conventions.md
Record contracts
Before reading saved snapshots, rename maps or JSON reference reports, read record contracts. Use validate-record <file.json> for offline validation. Snapshot and JSON report creation use new output paths. Historical inputs remain unchanged; no content upgrades are declared.