Recorder multiple purge_keep_days configuration

Hi all, I need to store certain sensor values for a year to compute some consumption algorithm while for other sensors I need to store them just for a couple of days.
Is it possible? Setting purge_keep_days equal to 365 for all entities is not visible, the db will grow to much

thanks in advance

use influxdb for long time storage.

Beside what Francis says, which allow you to keep all measurements and control on what to keep and how long, HA now automatically enables “Long Term Statistics”, which aggregates all sensors having a state_class of “measurement” with a 1h period (mean/sum/min/max).

Those are not affected by the HA purge.

Hi, I had a look at “Long Term Statistcs”. I set the state_class but it doesn’t seem to work with history_stats and bme280 sensor which are the sensors I need to keep.

The errors are:
Invalid config for [sensor.bme280]: [state_class] is an invalid option
Invalid config for [sensor.history_stats]: [state_class] is an invalid option

I’m using HA 2021.1.5, let me know if this is the problem.