Skip to main content
Glama

get_statistics

Retrieve long-term aggregated statistics (mean, min, max) for a Home Assistant entity over the last N hours, useful for historical analysis of high-frequency sensors.

Instructions

Get long-term aggregated statistics for an entity over the last N hours.

Uses HA's recorder statistics (over WebSocket) — aggregated buckets (mean / min / max per period) that survive the short-term retention window. Use this instead of get_history when: - You want data older than the recorder's default 10-day window. - You want aggregated values rather than every individual change. - The entity is a high-frequency sensor (temperature, power) and raw history would be too many tokens.

Args: entity_id: The entity (must have a state_class HA records as statistics — measurement, total, total_increasing). hours: How far back from now. Defaults to 24. period: Bucket size — 5minute, hour, day, week, month. Defaults to hour.

Returns: entity_id, period, start_time, end_time, statistics (list of {start, end, mean, min, max, ...} points).

Examples: get_statistics("sensor.power_usage", hours=168, period="day") get_statistics("sensor.temperature", hours=24)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hoursNo
periodNohour
entity_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Describes that it uses HA's recorder statistics and returns aggregated buckets (mean/min/max). Discloses that it survives short-term retention window. Does not explicitly state read-only nature, but purpose implies no modification. No annotations to contradict.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Concise yet informative. Front-loaded with main purpose, then structured bullet points for usage, Args, Returns, Examples. Every sentence adds value. No unnecessary repetition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given output schema exists, the description still provides a summary of return structure (entity_id, period, start_time, end_time, statistics). Covers all needed context: what it does, when to use, parameters, and returns. No gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema has 0% description coverage, but the description compensates by explaining each parameter: entity_id requires a state_class, hours defaults to 24, period with allowed bucket sizes. Provides examples. Adds meaning beyond schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states it gets long-term aggregated statistics for an entity over the last N hours. Distinguishes from sibling get_history by specifying use cases for older data or aggregated values. Includes examples and mentions HA recorder statistics.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly provides three conditions when to use instead of get_history: for data older than 10-day window, for aggregated values, and for high-frequency sensors. Also implies when not to use (short-term or raw history).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/voska/hass-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server