Summary
Allow configuring the recorder history retention period (purge_keep_days) on a per-entity or per-device basis, instead of only globally.
Current behavior
Currently, purge_keep_days in the recorder configuration only accepts a single global value that applies to all entities equally. There is no way to define different retention periods for individual entities or devices.
Proposed change
Add support for per-entity and per-device retention in the recorder configuration, for example:
recorder:
purge_keep_days: 10 # global default
customize:
sensor.outdoor_temperature:
purge_keep_days: 30
binary_sensor.motion_hallway:
purge_keep_days: 3
domain:device_tracker:
purge_keep_days: 1
Alternatively, this could be configurable via the UI in Settings → Devices & Services → Entities, similar to how entity names and icons can already be customized.
Why this is useful
- High-frequency sensors (e.g. power meters, CPU usage) generate a lot of data and may only need short retention (1–3 days)
- Important sensors (e.g. temperature history, energy statistics) benefit from longer retention (30–90 days)
- Reduces database size significantly without losing important historical data
- Gives users fine-grained control over storage usage
Alternatives considered
- Using
excludeto completely remove entities from the recorder — but this loses all history, which is not always desired - Using InfluxDB for long-term storage — works, but adds complexity and requires an external service
Additional context
This feature is particularly valuable for installations with many devices (sensors, cameras, trackers) where a one-size-fits-all retention period leads to either too much data or lost history for important entities.