casita
The missing Home Assistant CLI for your agent.
casita lets an AI agent ask your Home Assistant what's on, what needs attention and why something changed, and get short, structured answers back. It reads the state of only what you've exposed to Assist, and runs only the scripts you allow.
$ casita find "porch light" # find things by name, area or alias
$ casita find --device-class battery --below 20 # which batteries are dying?
$ casita log light.front_porch --since 24 # why did the porch light come on at 2 a.m.?
$ casita stats --device-class power # is this reading unusual for this hour?
$ casita view @on-by-area.sql --param min=5 # your own view, in SQL
$ casita run casita_porch_on --set /brightness=40 # run a script you allowed; previews first
$ casita view :maintenance # what needs attention?
{ "ha": { "catalog_age_s": 49, "state_age_s": 0, "state_stale": false, … },
"result": { "count": 2, "rows": [
{ "entity_id": "sensor.hallway_motion_battery", "state": "14", "unit": "%", "issue": "low_battery", … },
{ "entity_id": "sensor.smoke_detector_battery", "state": "9", "unit": "%", "issue": "low_battery", … } ], … } }
Quickstart · What it can reach · For agents
What it does
Find and read
casita find kitchen # full text over name, id, alias, area
casita find --domain lock --state unlocked # by domain and live state
casita find --area Office --device-class temperature --above 25 # filters combine
casita state sensor.kitchen_temperature # one entity with attributes
casita area "Kitchen" # everything in a room
casita overview # per-area rollup
Search runs against a local SQLite mirror, so a warm find makes no call to Home Assistant.
Built-in views
casita view :<name> runs a built-in view. Three of them return exceptions only and make up a sweep; each catches a failure the others can't see:
| View | Surfaces |
|---|
:maintenance | Low batteries, unavailable devices, pending updates |
:health | Devices whose own connectivity sensor says they're offline |
:stale | Sensors that should be streaming and have gone silent, while their device still looks fine |
:stale is keyed on Home Assistant's last_reported heartbeat, not on the value changing, so a temperature that has been 21.5° all day is healthy and a probe that stopped reporting is not.
Also included: :active (what is on, open or running), :rollup (per-area counts), :sensors (readings for a device class), :consumables (refill, replace, swap), :comfort (climate drift from setpoint) and :air (air quality by metric). Three more need a specific integration: :energy (Emporia Vue), :fleet (Tesla Fleet) and :grounds (Rain Bird, Plant). casita view with no argument lists them all with their parameters.
Some devices report a state that looks like a fault and isn't, such as a printer that sleeps. Tell casita once and the views stop raising it; casita view :muted lists what is currently suppressed. See Teaching it what normal looks like.
Why did that happen
casita log light.front_porch --since 24 # one entity: state transitions and logbook
casita log --since 6 # house-wide recent activity
Is this number unusual
casita stats reads Home Assistant's long-term statistics and reports facts, not verdicts.
casita stats --device-class power # now vs the same hour of day over the last week
casita stats --device-class temperature --trend # this week vs last, with each entity's share of the change
The hour-of-day baseline matters: a circuit can sit at its daily average and still be far out of line for 3 a.m.
Your own views
casita view "<SELECT …>" runs read-only SQL over the mirror, one row per entity, for whatever the built-in views don't cover. Results are capped at 500 rows.
casita view "SELECT area, COUNT(*) AS n FROM entities WHERE exposed=1 AND state='on' GROUP BY area"
Keep a view in a file and give it parameters with defaults:
-- on-by-area.sql: how many things are on, per area.
-- @param min=1
SELECT area, COUNT(*) AS n FROM entities
WHERE exposed = 1 AND state = 'on'
GROUP BY area HAVING n >= :min ORDER BY n DESC
casita view @on-by-area.sql --param min=5
Running a script
Off by default. To let casita run scripts, name them in ~/.casita/config.yaml:
policy:
write:
allow_prefixes: ["script.casita_"]
A script can then be run if it matches a prefix, is exposed to Assist, and matches no deny rule. casita checks all three against Home Assistant at the moment of the call, so un-exposing a script takes effect immediately.