hactl 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +70 -10
  2. package/dist/cli.js +2615 -871
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,16 +1,22 @@
1
1
  # hactl
2
2
 
3
- Manage Home Assistant instances from the command line. Built to be run by people and by AI agents.
3
+ Manage Home Assistant instances from the command line. Designed for AI agents and for
4
+ running commands directly, with machine-readable results and built-in help.
4
5
 
5
6
  ## Install
6
7
 
7
- A standalone binary for macOS (Apple silicon) and Linux (x64, arm64; needs `libatomic1`). Installs to `~/.local/bin`, or to `HACTL_INSTALL_DIR`.
8
+ The standalone binary does not require Node.js. It is available for macOS (Apple silicon)
9
+ and Linux (x64 and arm64; requires libatomic, packaged as `libatomic1` on Debian and Ubuntu).
8
10
 
9
11
  ```bash
10
12
  curl -fsSL https://raw.githubusercontent.com/houfio/hactl/main/install.sh | sh
11
13
  ```
12
14
 
13
- Set `HACTL_VERSION` to install a specific version. To update, run `hactl upgrade`.
15
+ The installer checks the download against the SHA-256 digest published by GitHub and installs
16
+ to `~/.local/bin` by default. Add that directory to your `PATH` if needed.
17
+ Set `HACTL_INSTALL_DIR` on the `sh` side of the pipe to install elsewhere, or set
18
+ `HACTL_VERSION` there to install a specific release (for example, `| HACTL_VERSION=0.9.0 sh`).
19
+ To update the standalone binary, run `hactl upgrade`.
14
20
 
15
21
  To check that a binary was built by this repository's release workflow, use the GitHub CLI:
16
22
 
@@ -18,26 +24,80 @@ To check that a binary was built by this repository's release workflow, use the
18
24
  gh attestation verify ~/.local/bin/hactl --repo houfio/hactl
19
25
  ```
20
26
 
21
- With Node 26 or later, on macOS or Linux, you can install from npm instead. Update that with the same command.
27
+ On macOS or Linux with Node.js 26 or later, you can install from npm instead. Use the
28
+ same npm command to update it; `hactl upgrade` only updates standalone release binaries.
22
29
 
23
30
  ```bash
24
31
  npm install -g hactl@latest
25
32
  ```
26
33
 
27
- ## Usage
34
+ ## Quick start
28
35
 
29
- `hactl` reads entities, devices, areas, floors, labels and services from Home Assistant, queries and calls services, with JSON output, renders Jinja templates, and reads logs as plain text. It works on contexts, one per instance, with tokens kept in the OS keychain.
36
+ Create a long-lived access token in your Home Assistant profile. Use an admin user's token
37
+ if you want to read logs or check the YAML configuration. For the keychain setup below,
38
+ Linux needs a running Secret Service and `secret-tool` (`libsecret-tools` on Debian and Ubuntu).
39
+
40
+ Create a named connection profile (context), paste the token at the hidden prompt, then
41
+ select and verify the context:
30
42
 
31
43
  ```bash
32
44
  hactl ctx set home --url https://ha.example.ts.net --install haos
33
45
  hactl ctx token-set home
34
46
  hactl ctx use home
47
+ hactl ctx verify
48
+ ```
35
49
 
36
- hactl get entities --domain light
50
+ Replace the example URL with your own. For a Home Assistant Container installation, use
51
+ `--install docker --container <name>` instead of `--install haos`.
52
+ A non-empty `HACTL_CONTEXT` takes precedence over the nearest `.hactl.json`, which can override
53
+ the global choice. Use `hactl ctx list` to see the active context and how it was selected.
54
+
55
+ `ctx verify` checks the HTTP connection and install type, WebSocket authentication, and SSH
56
+ if configured. Use `overview` for the instance's version, state, and resource counts.
57
+ Use `search` to find resource IDs and pass an ID to `related` to see its relationships.
58
+
59
+ ```bash
60
+ hactl overview
61
+ hactl search kitchen --type entity
62
+ hactl related entity light.kitchen
63
+ hactl get entities --domain light --limit 5
37
64
  hactl query todo.get_items --entity todo.shopping
38
65
  hactl template "{{ states('light.kitchen') }}"
39
- hactl call light.turn_on --entity light.kitchen
40
- hactl logs --follow
66
+ hactl call light.turn_on --entity light.kitchen --dry-run
67
+ ```
68
+
69
+ Replace the example entity IDs with ones from your instance. `call --dry-run` previews
70
+ targets without running the service. `query` runs only services that Home Assistant marks
71
+ as requiring a response; whether a service makes changes depends on its integration.
72
+ Results are JSON, except logs and string results from templates, which are plain text.
73
+
74
+ ### Troubleshoot
75
+
76
+ ```bash
77
+ hactl get integrations --status setup_error
78
+ hactl get repairs --severity critical
79
+ hactl diagnose
80
+ hactl check
81
+ ```
82
+
83
+ `get integrations` lists config entries; `get repairs` lists issues reported by Repairs.
84
+ `diagnose` summarizes instance health, or accepts an entity ID, `--device` or `--integration`
85
+ for a targeted bundle. `check` validates YAML without applying it. To stream Core logs,
86
+ run `hactl logs --follow` and press Ctrl+C to stop.
87
+
88
+ ### Headless runs
89
+
90
+ Create the context with `hactl ctx set` first. Instead of `ctx token-set` and `ctx use`,
91
+ provide the context name and token through the environment. A non-empty `HACTL_TOKEN`
92
+ applies only to the context named by `HACTL_CONTEXT` and bypasses the keychain for that
93
+ context. In CI, inject the token from the secret store rather than putting it in a script;
94
+ anything that can read the process environment can read the token.
95
+
96
+ ```bash
97
+ export HACTL_CONTEXT=home
98
+ export HACTL_TOKEN="$HA_TOKEN" # HA_TOKEN is supplied by the secret store.
99
+
100
+ hactl get entities --domain light
41
101
  ```
42
102
 
43
- Everything else is in the CLI: start with `hactl --help`, and add `--help` to any command.
103
+ Start with `hactl --help`, or add `--help` to any command or command group for details.