Get energy sum statistics for recent days
statistics_get_energy_statisticsFetch summed energy statistics for all energy sensors over the last N days. Auto-discovers energy statistic IDs and returns consumption totals by day, week, or month.
Instructions
Get sum statistics for every energy-related sensor over the last N days.
Auto-discovers 'sum' statistic IDs via WS recorder/list_statistic_ids,
keeps only those whose unit is an energy/volume unit (kWh, MWh, Wh, m³,
ft³, L, gal — instantaneous power sensors in 'W' are excluded since a
'sum' statistic on a power sensor is not a meaningful energy value),
then fetches sum/change via WS recorder/statistics_during_period
for the requested window. This is a convenience wrapper around
statistics_get_statistics.
Use when: a quick overview of overall energy consumption trends is
needed without first listing statistic IDs by hand.
Not for: a hand-picked set of statistic IDs or non-energy sensors — use
statistics_get_statistics directly.
Returns: {"days", "period", "statistic_count", "data": {statistic_id: {"unit": ..., "rows": [{"start": <date>, "change": ..., "sum": ...}, ...]}}}, or {"message": "..."} when no energy statistic IDs are
found.
Errors: {"error": "days must be between 1 and 365"} for an
out-of-range days; {"error": "..."} when either WS call raises or
returns an unexpected shape.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| days | No | Number of days back from now to include, between 1 and 365. | |
| period | No | Aggregation bucket size passed to the underlying statistics query, e.g. 'day', 'week', 'month'. | day |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||