get_history
Retrieve raw state change timestamps for any Home Assistant entity. Specify hours or a date range, set a record limit, and choose sampling strategy (recent, first, or even) to manage results. Ideal for doors, switches, and short periods.
Instructions
Get raw state changes for an entity. For aggregated trends, use get_statistics instead.
By default returns last N hours. Provide start_time to query a specific date range instead. Best for: exact state change timestamps, infrequently-changing entities (doors, switches), short time periods. NOT for: long ranges on frequently-updating sensors — use get_statistics.
Args: entity_id: Entity ID to get history for hours: Hours of history (default: 24). Ignored if start_time is provided. start_time: ISO 8601, date only, or 'yesterday'/'today'. If set, uses range mode instead of hours. end_time: End of range (default: 'now'). Only used with start_time. limit: Max records (1-500, default: 100) sample_strategy: 'recent' (default), 'first', or 'even' — how to sample if over limit minimal_response: Reduce response size in range mode (default: true)
Examples: get_history("binary_sensor.front_door") get_history("sensor.temperature", hours=1, limit=50) get_history("sensor.temp", start_time="2025-10-28T10:00:00Z", end_time="2025-10-28T11:00:00Z") get_history("light.living_room", start_time="yesterday", end_time="today")
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entity_id | Yes | ||
| hours | No | ||
| start_time | No | ||
| end_time | No | ||
| limit | No | ||
| sample_strategy | No | recent | |
| minimal_response | No |