Skip to main content
Glama
ffleurey

ha-analytics-mcp

by ffleurey

ha_history_detect_sessions

Detect activity sessions from numeric sensors using a threshold to reveal appliance runs, charging sessions, or heating cycles. Returns event counts, total duration, and session lists or daily summaries.

Instructions

Detects activity sessions from a numeric sensor using a power/value threshold. Use for threshold-based activity questions such as charging sessions, appliance runs, or heating cycles. Uses long-term hourly statistics → full date range, no retention limit, ±1h precision. For binary sensors or person/zone state history, use ha_history_get_state_history instead. Returns event count, total duration, a compact session list, or a daily summary with group_by="day".

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
end_timeNoPeriod end, same formats as start_time. Default: now.
group_byNo"day" returns one row per day (date | count | first start | last end | total active) instead of individual sessions. Use for daily patterns ("how many runs per day?"). Summary stats always cover the full dataset.
entity_idYesExact entity_id resolved earlier, e.g. "sensor.car_charger_power". Do not guess.
thresholdYesMinimum value to count as "active", in the sensor's own unit. Example: 100 for a Watt sensor (EV charger, heater, washing machine).
comparisonNoCompare session count and duration to the immediately preceding equal-length period, or to the same calendar period 12 months ago.
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. Special: "overnight" = 22:00 yesterday → 06:00 today.
max_resultsNoMax rows (sessions, or days with group_by). Default: 20. Pass "all" to list all. Summary stats always cover the full dataset regardless.
day_start_hourNoOnly with group_by="day". Shifts the day boundary from midnight to this hour (0-23). E.g. 6 → a day runs 06:00-05:59, so 01:30 activity counts on the previous evening's date.
max_gap_minutesNoBridge inactive gaps shorter than this into one session (minutes). Default: 0 (no merging). E.g. 120 for a washing machine pausing between cycles. Hourly statistics → use multiples of 60; values below 60 have no effect.
min_duration_minutesNoDiscard sessions shorter than this (minutes). Default: 1. Hourly statistics → values below 60 have no additional effect.
Behavior4/5

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

With no annotations, the description carries the full burden. It discloses key behavioral traits: 'Uses long-term hourly statistics → full date range, no retention limit, ±1h precision.' This is valuable context beyond a simple read operation. It also states what the tool returns (event count, total duration, session list, daily summary). Missing is an explicit statement that the operation is read-only, but the nature of the tool implies it. The precision limitation and data source disclosure earn a strong score.

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 four sentences, front-loaded with the core purpose, followed by use cases, a critical behavioral note, an alternative tool pointer, and output types. Each sentence adds distinct value without repetition. It is concise and well-structured for quick comprehension.

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?

For a tool with 10 parameters and no output schema, the description covers the essential context: what it does, when to use, key limitations (precision), and the four output modes. It does not mention the 'comparison' feature (e.g., 'previous_period'), which is a notable capability, but the schema handles parameter-level details. Overall, it is complete enough for selection and basic invocation guidance.

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

Parameters3/5

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

Schema description coverage is 100%, so the baseline is 3. The description adds a small amount of parameter context by mentioning 'group_by="day"' and 'compact session list' and 'daily summary,' but the schema already documents each parameter in detail. The description does not explain parameter interactions beyond what the schema provides, so it adds limited value beyond the baseline.

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 identifies the tool's purpose: 'Detects activity sessions from a numeric sensor using a power/value threshold.' It provides concrete use-case examples ('charging sessions, appliance runs, or heating cycles') and distinguishes from a sibling by stating 'For binary sensors or person/zone state history, use ha_history_get_state_history instead.' This is specific, actionable, and differentiates the tool from 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?

Explicit usage guidance is provided: 'Use for threshold-based activity questions' and a clear alternative for binary sensors/person/zone state history. It also implies when not to use (when the sensor is not numeric or threshold-based). The behavioral note about hourly statistics and precision helps set expectations for appropriate queries.

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