Skip to main content

hassstuff

Home Assistant over REST and WebSocket: thin typed clients (somestuff.hassstuff.client) and a CLI (hass-api, or python -m somestuff.hassstuff). The WebSocket API covers what REST does not expose: entity/device/area registry, helpers, Lovelace dashboards, traces.

hass-api --help
hass-api <command> --help

Connection

Option Env Default
--url HASS_URL content of homeassistant_url.local.txt, otherwise http://homeassistant.local:8123
--token HASS_TOKEN –
--token-file HASS_TOKEN_FILE homeassistant_token.local.txt
--insecure – TLS is verified
--timeout – 30 seconds

Both *.local.txt files are searched in the current directory and every parent directory, each also under secrets.local/. --token wins over --token-file. Global options go before the command: hass-api --url https://… --token abc states.

Commands

Command API Purpose
info REST + WS Version, user, admin flag
states [PATTERN] [--domain D] [--json] REST States, pattern = substring or glob on ID/name
state ENTITY [--yaml] REST Full state object
call DOMAIN.SERVICE [k=v …] [--data JSON] REST Service call, --return-response for responses
template 'JINJA' REST Render a template server-side, - = stdin
history ENTITY … [--hours N] [--attributes] REST State history
logbook [ENTITY] [--hours N] REST Logbook including trigger (user, service, automation)
areas / devices [PATTERN] WS Areas, devices with area and model
entities [PATTERN] [--area A] [--platform P] WS Entity registry, area also inherited from the device
entity-update ENTITY [--name …] [--area …] … WS Name, icon, area, ID, enable/hide, labels
helper list|create|update|delete TYPE … WS input_*, counter, timer, schedule
automation list|get|put|delete REST UI automations, put shows a diff first
script list|get|put|delete REST UI scripts, as above
trace list [REF] / trace get REF [RUN_ID] REST + WS Run traces, without RUN_ID the latest run
dashboard list|get [URL_PATH]|save FILE [URL_PATH] WS Lovelace dashboards in storage mode
ws TYPE [k=v …] [--data JSON] WS Any WebSocket command

k=v values are parsed as JSON where possible (max=300, options='["a","b"]'), otherwise as text.

REF for automations/scripts: entity ID (automation.foo) or config ID. The config ID of an automation is its id attribute, not the part after automation.; automation list shows both.

Examples

hass-api entities --area Kitchen
hass-api logbook light.kitchen --hours 2          # who switched it?
hass-api trace get automation.morning_lights --yaml
hass-api automation get morning_lights --yaml > /tmp/a.yaml
hass-api automation put morning_lights /tmp/a.yaml --dry-run
hass-api helper create input_number name="Target" min=0 max=300 step=5 unit_of_measurement=°C
hass-api entity-update sensor.foo --area Kitchen --name "Kitchen temperature"
hass-api call logger.set_level homeassistant.components.mqtt=debug
hass-api dashboard get my-dashboard --yaml > /tmp/d.yaml
hass-api dashboard save /tmp/d.yaml my-dashboard --dry-run
hass-api ws config/label_registry/list

Library

from somestuff.hassstuff.client import HassConfig, HassRest, HassWebSocket, default_token_file, default_url, load_token

config = HassConfig(url=default_url(), token=load_token(None, default_token_file()))

Limits

  • put/save replace the whole object. First get, then edit, then put (without --dry-run).
  • delete asks for confirmation, --yes skips it.
  • Helpers created through config flows (template, utility meter, threshold, group …) do not go through helper, only through config_entries/flow (possible via ws, but multi-step).
  • YAML dashboards and hand-written automations in automations.yaml without id are not writable.

Metadata

Release files for somestuff-hassstuff 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for somestuff-hassstuff 0.1.0
File Size Uploaded Provenance Actions
somestuff_hassstuff-0.1.0.tar.gz 21.1 kB Without provenance Details for somestuff_hassstuff-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for somestuff-hassstuff 0.1.0
File Interpreter ABI Platform Actions
somestuff_hassstuff-0.1.0-py3-none-any.whl Python 3 none any Details for somestuff_hassstuff-0.1.0-py3-none-any.whl

Total release size: 41.1 kB

Release files / somestuff_hassstuff-0.1.0.tar.gz

Download URL somestuff_hassstuff-0.1.0.tar.gz
Size 21.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f1437f50e666b588c4e7736a5cf0b5178d3f9b3018eb0435cc1c021ace28e749
BLAKE2b-256 checksum
How to use checksums
fce9a862f78119e03d1a577b8fc63cb0c8c2245f3e95007e6ce75b847e0ece89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.18.2 {"ci":null,"cpu":"x86_64","distro":{"id":"resolute","libc":{"lib":"glibc","version":"2.43"},"name":"Ubuntu","version":"26.04"},"implementation":{"name":"CPython","version":"3.14.4"},"installer":{"name":"hatch","version":"1.18.2"},"openssl_version":"OpenSSL 3.5.5 27 Jan 2026","python":"3.14.4","system":{"name":"Linux","release":"7.3.4-custom"}} HTTPX2/2.16.0

Release files / somestuff_hassstuff-0.1.0-py3-none-any.whl

Download URL somestuff_hassstuff-0.1.0-py3-none-any.whl
Size 20.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
14665c9361fad6dcb7b394af78a05b9dc57baa3b24ae7d4a58077631dc1f198e
BLAKE2b-256 checksum
How to use checksums
fade2c44336157748a08e5a81417d856ae304f80f0e7a1275822ba65766caad9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.18.2 {"ci":null,"cpu":"x86_64","distro":{"id":"resolute","libc":{"lib":"glibc","version":"2.43"},"name":"Ubuntu","version":"26.04"},"implementation":{"name":"CPython","version":"3.14.4"},"installer":{"name":"hatch","version":"1.18.2"},"openssl_version":"OpenSSL 3.5.5 27 Jan 2026","python":"3.14.4","system":{"name":"Linux","release":"7.3.4-custom"}} HTTPX2/2.16.0

Security for somestuff-hassstuff 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page