Ha States

Read Home Assistant entity states and recent history with hass-cli. Use to answer 'is the light on', 'what's the temperature', 'list all sensors', 'what changed recently', or to inspect any entity's current state and attributes. Covers state list/get, table shaping (--columns/--sort-by), and history/logbook reads.

beclab 8e397f0 1.4 KB Updated

File contents

ha-states

Read entity state. Prerequisite: read ../ha-shared/SKILL.md for connection/auth.

Commands

hass-cli state list                                  # every entity
hass-cli state list -o json | jq '.[] | select(.entity_id|startswith("light."))'
hass-cli state get sensor.kitchen_temperature
hass-cli state get light.kitchen -o yaml             # full attributes

Shape tables. state list already defaults to ENTITY=entity_id,STATE=state,NAME=attributes.friendly_name in table mode; pass --columns to override:

hass-cli state list --columns ENTITY=entity_id,STATE=state --sort-by entity_id

History and logbook

hass-cli system history --start 2026-01-01T00:00:00+00:00 --entities light.kitchen,sensor.temp
hass-cli system logbook --entity automation.demo

Notes

  • state set overwrites the state object in the state machine; it does NOT drive a device. To actually change a device, use service call (see ../ha-services/SKILL.md).
  • Filtering/aggregation is client-side: pipe -o json to jq.

beclab/hass-cli/tree/main/skills/ha-states commit 8e397f0d38

Frequently asked questions

npx skillmds@latest add beclab/ha-states