Skip to main content
Glama

get_statistics

Retrieve aggregated statistics (mean, min, max) for a Home Assistant entity over a specified time range. Supports flexible aggregation periods (5min, hour, day, week, month) for efficient historical data analysis 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

TableJSON Schema
NameRequiredDescriptionDefault
entity_idYes
hoursNo
start_timeNo
end_timeNo
periodNohour
Behavior4/5

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

No annotations provided, so description carries full burden. It discloses that it returns mean/min/max, handles any range efficiently, and details parameter interactions. However, it does not explicitly state the operation is read-only or mention any potential limitations.

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?

Well-structured with paragraphs, bullet points, and examples. Every sentence adds value; purpose is front-loaded. No redundant content.

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

Completeness4/5

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

Given 5 parameters and no output schema, the description covers usage thoroughly, including parameter dependencies and examples. It lacks explicit output format details beyond mean/min/max, and error handling is not mentioned.

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

Parameters5/5

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

With 0% schema coverage, the description adds extensive meaning for all 5 parameters, including default behaviors, special values like 'yesterday'/'today' for start_time, and resolution hints for period options. Examples further clarify usage.

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?

The description clearly states 'Get aggregated statistics (mean/min/max) for an entity' and distinguishes itself from sibling tools by noting it is the best tool for historical data with no token limits and suggesting use when get_history hits limits.

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 when to use ('Best tool for historical data — no token limits'), when not to use (implicitly via alternative: 'If get_history hits token limits, use this tool'), and explains the two modes of operation (default hours vs. date range).

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/rmaher001/hass-mcp-plus'

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