Skip to main content
Glama

get_history

Retrieve raw state change history for Home Assistant entities to analyze exact timestamps and transitions, ideal for infrequently-changing devices like doors and switches over short periods.

Instructions

Get raw state changes for an entity. For aggregated trends, use get_statistics instead.

By default returns last N hours. Provide start_time to query a specific date range instead. Best for: exact state change timestamps, infrequently-changing entities (doors, switches), short time periods. NOT for: long ranges on frequently-updating sensors — use get_statistics.

Args: entity_id: Entity ID to get history for hours: Hours of history (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. limit: Max records (1-500, default: 100) sample_strategy: 'recent' (default), 'first', or 'even' — how to sample if over limit minimal_response: Reduce response size in range mode (default: true)

Examples: get_history("binary_sensor.front_door") get_history("sensor.temperature", hours=1, limit=50) get_history("sensor.temp", start_time="2025-10-28T10:00:00Z", end_time="2025-10-28T11:00:00Z") get_history("light.living_room", start_time="yesterday", end_time="today")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entity_idYes
hoursNo
start_timeNo
end_timeNo
limitNo
sample_strategyNorecent
minimal_responseNo

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