Skip to main content

History

The hub records every entity state change (and availability change) in TimescaleDB for years, so the web UI and MCP can answer "what did this sensor read" and "how much energy today". The database is a required step of the setup wizard, because the hub keeps its settings there too: the Docker install starts a TimescaleDB for you and pre-fills the step. To point the hub at another one, use Settings → Database (host, port, database, user, password) and Test connection, which also prepares the tables. The password is write-only, and changing the host or port needs it entered again. Saving restarts the hub. See the Settings reference.

The hub keeps up to 100000 states in memory while the database is down (the history_buffer_rows field of the advanced settings, changed through PUT /api/v1/settings/advanced or set_settings).

Any TimescaleDB 2.17+ on Postgres 17 works, as long as the role can log in and CREATE EXTENSION timescaledb has been run inside the target database (the extension itself must be in shared_preload_libraries on the server). The hub applies its own schema migrations on first connect, writes every state change inline from Hub::ingest (never on the hot MQTT path — the writer runs in a bounded, try-send queue) and rolls each hour up into history_hourly every five minutes. A down database never blocks the house: up to 100000 states wait, past that the oldest are dropped with one warning per outage.

Querying​

Routes under /api/v1/history/* (see the HTTP API): series for charts (range is 1h, 6h, 24h, 7d, 30d or 1y), fields for every value of an entity over the same ranges (battery, brightness …, one track each), daily for kWh per day over 7, 30 or 365 days, today for kWh since local midnight (daily and today take kind=counter or kind=power), last_change for 1 to 50 entities, and grid_day for what crossed the grid meter on one day in half hours (bought off-peak and peak, sold; date=YYYY-MM-DD, today when left out; with an off-peak device the split follows its recorded readings, so keep history on for it). Errors are 400 bad_request, 404 not_recorded (the entity has no rows) and 503 history_unavailable (the database is not connected, or is down). MCP exposes the same through get_history and get_grid_day; grid_day also answers 404 no_grid_meter when no entity with the grid role has an energy counter.

In the web UI​

Every entity sheet has a View history → link to /history/<id>, a full-screen chart with range chips (Last hour, Last 6 hours, Last 24 hours, Last 7 days, Last 30 days, Last year; the range is kept in the URL as ?range=). A sensor draws a smooth line you can hover for the value, with the min and max band on the 7-day and longer ranges. An energy counter (kWh and similar) draws its paired power sensor over the short ranges, or kWh bars per day over 7, 30 or 365 days (a single day's bar when there is no power sensor). An entity with no rows shows "No data recorded for this entity yet", and a database that is down shows "History is unavailable right now".

Under the range chips, a row of value chips lists everything the entity reports: a vacuum's Activité, Batterie and Vitesse d'aspiration, a light's brightness and colour temperature, a thermostat's target, fan mode and action. Tap a chip to show or hide that value on the one chart; the choice is kept in the URL as ?show=. At most one number and one word are shown at a time, so a new pick of the same kind replaces the old one. A vacuum opens on Activité and Batterie. A number draws a line you can hover. A word draws shaded periods behind the line, one colour per value: the value held longest (a vacuum's "À la base") stays unshaded and the others (Nettoyage, Retour…) stand out, even a few seconds long. A legend under the chart names each value, and hovering shows the time, the number and the word in force. A word picked alone fills the chart with its periods. An entity with a single value shows no chips. The values read the states already recorded, so they cover the past too.

Compare several sensors​

History (/history) draws up to 8 entities on one time axis, so you can see how they move together. Open it from History in the sidebar, under Home after Energy, or from Compare with other sensors on an entity's history page. That opens it with the entity already picked and the same period.

Pick the entities with the picker. Each one becomes a chip, and its ✕ removes it. The period bar is the one of the single page (1 h, 6 h, day, week, month, year, custom, ‹ and ›, back to now), without comparing with another year.

The chart has one panel per unit, stacked on the same time axis: °C together, W together, % together, and so on. Lights, switches and binary sensors share one on/off panel, and numbers without a unit share one panel. Each entity has its own colour, shown in its panel's key. A climate entity is drawn by its current temperature. Energy counters (kWh) are not offered; pick their power sensor instead. Text-only entities are not offered either.

Hover or touch any panel to get one line across all the panels, with a tooltip giving each value at that time.

The address keeps the picked entities and the period, so you can bookmark or share it. For example, to see why the living room warms at night, pick the living-room thermometer, its air conditioner and the AC power meter, and set the period to the night.

Retention​

Nothing is deleted by age, except the system health sensors (system_*) and the hub's restart log, which are kept 90 days. The rest of the history is kept as long as you keep the database.

Backup​

The history is part of the hub's backup, with your settings and flows. See Backup and restore.