Skip to main content
Glama
ffleurey

ha-analytics-mcp

by ffleurey

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

TableJSON Schema
NameRequiredDescriptionDefault
end_timeNoPeriod end, same formats as start_time. Default: now.
group_byNoGroups by repeating time unit across the full period: "hour_of_day" or "day_of_week". Cannot be used with interval.
intervalNo"none" for one whole-period summary table; "hour"/"day"/"week"/"month" for time series. Cannot be used with group_by.
entity_idsYesArray 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_timeNoPeriod 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_resultsNoApplies to interval time series only. Caps rows, not columns. Default: 100. Pass "all" for the full series.
aggregationsNoStatistics 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_valueNoThreshold for filter_operator. Required when filter_operator is set.
filter_operatorNoKeep only buckets where the aggregated value satisfies the threshold. Requires interval (not "none") or group_by.
Behavior4/5

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

With no annotations provided, the description carries the full burden. It discloses the tool's scope (instantaneous-value sensors), the requirement to pass entity_ids as an array, and the intended usage patterns for aggregations/interval/group_by. It does not mention return value structure or error handling, but the absence of an output schema and the tool's statistical nature make this a minor gap. The description adds useful context about sensor types and unit matching, which goes beyond the schema.

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?

The description is six sentences, each earning its place: purpose, array requirement, multi-entity preference, parameter usage, and two explicit exclusions. It is front-loaded with the core function and avoids redundancy. Nothing is wasted, and it remains concise despite covering multiple usage dimensions.

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 the tool's complexity (9 params, no annotations, no output schema), the description is very complete. It explains the core behavior, parameter selection strategies, and alternatives. The only missing element is a description of the return format (e.g., a table of aggregates per sensor), but the schema's aggregations enum and the tool name imply this. This is a minor gap in an otherwise comprehensive description.

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 coverage is 100%, so parameters are already well-documented. The description enriches this by explaining when to use which parameter ('Use aggregations for several whole-period stats,' 'Use interval for time series'), and adds guidance on entity_ids ('Always pass entity_ids as an array,' 'Prefer one multi-entity call...'). This adds practical semantics beyond the schema's field-level descriptions.

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 opens with 'Computes statistics for one or more instantaneous-value sensors' followed by concrete examples (temperature, humidity, CO₂, pressure, illuminance, power). It explicitly distinguishes from siblings by stating 'Do not use for cumulative consumption in kWh; use ha_history_get_consumption' and 'Do not use for event counting; use ha_history_detect_sessions.' This clearly identifies the tool's scope and differentiates it from probable alternatives.

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?

The description provides explicit usage rules: 'Always pass entity_ids as an array,' 'Prefer one multi-entity call over repeated single-entity calls when units match,' and directs parameter selection: 'Use aggregations for several whole-period stats in one call. Use interval for time series and group_by for repeating patterns.' It also gives clear when-not-to-use guidance with named alternatives, covering exclusions and edge cases.

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/ffleurey/ha-analytics-mcp'

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