query_recorder_db
Run read-only SQL SELECT queries against the Home Assistant recorder database to inspect state history, events, and statistics.
Instructions
Run a read-only SQL SELECT against the Home Assistant recorder (MariaDB).
Use this for ad-hoc queries against the recorder database — e.g. fetching Zigbee action events, checking state history, or inspecting statistics.
Only SELECT statements are allowed. Key tables:
states— entity state changes (joined tostates_metafor entity_id)states_meta— mapsmetadata_id->entity_idevents— HA events (joined toevent_typesfor event name)event_types— mapsevent_type_id->event_typeevent_data— JSON payload blobs (joined viadata_id)statistics— hourly aggregatesstatistics_short_term— 5-minute aggregates
Timestamps are stored as DATETIME in UTC (last_updated_ts / time_fired_ts
are FLOAT unix epoch seconds; the older last_updated / time_fired DATETIME
columns may be NULL in recent HA versions — use the _ts columns instead).
Args: sql: A SELECT statement to execute.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |