Files
Christian Manivong ed8e58267a
driver / lint (pull_request) Successful in 15s
driver / standard (pull_request) Successful in 19s
driver / lowest (pull_request) Failing after 25s
driver / types (pull_request) Successful in 1m5s
driver / test (3.12) (pull_request) Successful in 1m11s
driver / test (3.13) (pull_request) Successful in 1m3s
driver / build (pull_request) Successful in 30s
driver / security (pull_request) Successful in 1m8s
CI / driver (pull_request) Failing after 1m52s
driver / publish (pull_request) Skipped
feat: Home Assistant OS driver over the WebSocket API (0.1.0)
A driver for Home Assistant OS and Supervised installs. It reaches the
Supervisor through Home Assistant's WebSocket (supervisor/api) with an
administrator's long-lived access token: no add-on, no SSH.

Getters: facts, interfaces and addresses, host status (pending reboot,
data disk), pending updates of Core, OS, Supervisor and add-ons, add-ons
as services, running backups. Actions: apply updates, add-on start/stop/
restart and start at boot, refresh updates, reboot and shutdown.

The fixtures are built from the Supervisor 2026.11.0 API source, not
recorded; they are replaced once the first device is onboarded.
2026-12-03 01:22:18 +01:00

77 lines
3.3 KiB
Markdown

# napalm-homeassistant
NAPALM driver for Home Assistant OS, built on
[napalm-device-types](https://git.netork.io/NAPALM/napalm-device-types) (`OSDriver`).
It talks to Home Assistant's WebSocket API and, through it, to the Supervisor: the
same way Home Assistant's own settings pages do. Nothing is installed on the device,
no add-on and no SSH.
## Tested against
| Install | Versions |
|---|---|
| Home Assistant OS (VM, board `ova`) | OS 18.4, Core 2026.11.3, Supervisor 2026.11.0 — answer shapes from the Supervisor's source; not yet against a device |
The fixtures are built from the Supervisor 2026.11.0 API source and are replaced by
recordings from the first onboarded device (see `tests/fixtures/README.md`).
## Connection
`ws://<host>:8123/api/websocket`, or `wss://` with `use_ssl` (the default on port 443).
The credential is a **long-lived access token of a Home Assistant administrator**
(Profile → Security → Long-lived access tokens): the Supervisor calls are open to
administrators only. It goes in as the password or as `optional_args["token_value"]`;
the username is not used.
```python
from napalm import get_network_driver
driver = get_network_driver("homeassistant")
with driver("192.0.2.21", "", "<long-lived access token>") as device:
print(device.get_facts())
```
| Optional arg | |
|---|---|
| `port` | Home Assistant's port, default 8123 |
| `use_ssl` | `wss://` instead of `ws://`; default on port 443 |
| `ssl_verify` / `verify_ssl` | verify the certificate against the system's CAs (default true) |
| `tls_fingerprints`, `tls_certificate_observer` | certificate pinning as in device-types' `tls_certificates`; a changed certificate is refused before the token is sent |
| `token_value` | the access token, instead of the password |
## Supported
| Getter / action | |
|---|---|
| `get_facts` | vendor, board as model, hostname, OS, uptime, interfaces; without a Supervisor only Core's version |
| `get_interfaces`, `get_interfaces_ip` | the interfaces NetworkManager manages (no speed, no MTU) |
| `get_host_status` | pending reboot (an installed OS waiting for it, or the Supervisor's `reboot_required` issue), data disk usage |
| `get_available_updates` | `core`, `os`, `supervisor` and each add-on by its slug |
| `apply_updates` | add-ons first, then Supervisor, Core (waits until Home Assistant is back) and the OS last (the host restarts); no backup is taken first |
| `refresh_available_updates` | the Supervisor's `/reload_updates` |
| `get_services`, `manage_service` | add-ons by slug: start, stop, restart; enable/disable sets their start at boot |
| `get_running_backups` | the Supervisor's backup jobs in progress |
| `reboot_host`, `shutdown_host` | the host, through the Supervisor |
| Discovery | Home Assistant's web page on port 8123 |
## Not supported
Anything inside Home Assistant itself (entities, automations, integrations), the
Supervisor's health and unsupported reasons, listing or making backups, configuration
changes, Home Assistant Container or Core installs beyond their version (they have
no Supervisor).
## Development
The rules are in [STANDARDS.md](https://git.netork.io/NAPALM/driver-standard/src/branch/main/STANDARDS.md).
```bash
python -m venv .venv && .venv/bin/pip install -e ".[dev]"
.venv/bin/pytest --cov
```
## License
Apache-2.0