Skip to main content
Glama

Get entity state history

history_get_state_history
Read-onlyIdempotent

Fetch an entity's recorded state history over the last N hours to track changes like temperature trends. Provides raw short-term recorder data, not logbook or statistics.

Instructions

Get an entity's recorded state history over the last N hours.

Calls GET /api/history/period/<start> filtered to entity_id, where start is now - hours; returns whatever the recorder database has kept for that window.

Use when: seeing how one entity's state changed over time, e.g. a temperature trend. Not for: human-readable event descriptions — use history_get_logbook; this is raw, short-term state history, not the recorder's long-term pre-aggregated sum/mean/min/max values — use statistics_get_statistics for those, or statistics_list_statistic_ids to discover which entities have them. Returns: HA's raw history-period payload — a list of state-change records for the entity. Errors: raises httpx.HTTPStatusError if the HA API request fails. Limits: only as far back as the recorder integration has retained data for this entity.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hoursNoHow many hours back from now to fetch, e.g. 24 for one day. Default 24.
entity_idYesFull entity ID to fetch history for, e.g. 'light.kitchen'.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.25.1
    • addedInput schema / properties / entity_id / description
      Added value: +"Full entity ID to fetch history for, e.g. 'light.kitchen'."
    • addedInput schema / properties / hours / description
      Added value: +"How many hours back from now to fetch, e.g. 24 for one day. Default 24."
  2. First observedv0.3.0

TDQS

A4.7/5.0
Behavior5/5

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

Annotations already declare readOnly/idempotent/non-destructive, and the description adds substantial extra context: the raw payload shape returned, the error behavior (raises httpx.HTTPStatusError), and a key limit that only retained recorder data is available. These are meaningful behavioral disclosures beyond the structured fields.

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?

Front-loaded with the core purpose, then cleanly sectioned into Use when / Not for / Returns / Errors / Limits. Every line carries actionable information with no filler.

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?

For a read-only history tool it covers purpose, routing, return shape, error mode, and retention limits. Even though an output schema exists, the extra notes about raw payload and retention make it fully self-sufficient for correct invocation.

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 both parameters are already documented. The description adds the derived mapping ('start' is now - hours), which lightly clarifies the hours parameter, but does not add syntax or format detail beyond the schema, so the baseline 3 applies.

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?

States a specific verb+resource ('Get an entity's recorded state history over the last N hours') and pins the exact endpoint it calls, making scope unambiguous. It explicitly distinguishes itself from siblings like history_get_logbook and statistics_get_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?

Has an explicit 'Use when' (tracking one entity's state over time), an explicit 'Not for' (human-readable events -> history_get_logbook), and names the right alternatives (statistics_get_statistics, statistics_list_statistic_ids) with the condition selecting each.

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

Deploy Server

Other Tools