ha_history_get_sensor_stats
Calculate statistical summaries (mean, min, max, median, count) from Home Assistant sensor history, with time-series intervals, hourly/daily grouping, and threshold filtering.
Instructions
Computes statistics for one or more instantaneous-value sensors such as temperature, humidity, CO₂, pressure, illuminance, or power in W. Always pass entity_ids as an array. Prefer one multi-entity call over repeated single-entity calls when units match. Use aggregations for several whole-period stats in one call. Use interval for time series and group_by for repeating patterns. Do not use for cumulative consumption in kWh; use ha_history_get_consumption. Do not use for event counting; use ha_history_detect_sessions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| end_time | No | Period end, same formats as start_time. Default: now. | |
| group_by | No | Groups by repeating time unit across the full period: "hour_of_day" or "day_of_week". Cannot be used with interval. | |
| interval | No | "none" for one whole-period summary table; "hour"/"day"/"week"/"month" for time series. Cannot be used with group_by. | |
| entity_ids | Yes | Array of exact entity_ids. Use one item for a single sensor or multiple items for homogeneous comparisons. Resolve IDs first with ha_history_list_entities or ha_history_list_device_entities. | |
| start_time | No | Period start. Formats: relative (7d/30d/24h/2w/1y), named ("last month"/"last week"/"yesterday"/"last summer"/"Q1"), or ISO ("2026-04-01"). Default: 30d. | |
| max_results | No | Applies to interval time series only. Caps rows, not columns. Default: 100. Pass "all" for the full series. | |
| aggregations | No | Statistics to compute, e.g. ["mean"] or ["mean","min","max"]. Default: ["mean"]. median: whole-period only (interval="none", no group_by). count: alone, with group_by + filter — counts readings per slot that satisfy the filter (e.g. "how many days per hour exceeded 21°C?"). | |
| filter_value | No | Threshold for filter_operator. Required when filter_operator is set. | |
| filter_operator | No | Keep only buckets where the aggregated value satisfies the threshold. Requires interval (not "none") or group_by. |