get_statistics
Retrieve aggregated statistics (mean/min/max) for Home Assistant entities over specified time ranges, handling historical data efficiently without token limits.
Instructions
Get aggregated statistics (mean/min/max) for an entity. Best tool for historical data — no token limits.
By default returns last N hours. Provide start_time to query a specific date range instead. Handles any range efficiently (days, months, years). If get_history hits token limits, use this tool with the same time range instead.
Args: entity_id: Entity ID to get statistics for hours: Hours of data (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. period: Aggregation period (default: 'hour'): '5minute' (~12 points/hr), 'hour' (24/day), 'day' (monthly views), 'week' (quarterly), 'month' (yearly). Match period to time range.
Examples: get_statistics("sensor.temperature", hours=24, period="hour") get_statistics("sensor.power_usage", hours=168, period="day") get_statistics("sensor.temperature", start_time="2024-10-01", end_time="2024-10-31", period="day") get_statistics("sensor.humidity", start_time="yesterday", period="5minute")
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entity_id | Yes | ||
| hours | No | ||
| start_time | No | ||
| end_time | No | ||
| period | No | hour |