History setting to clear values based on elapsed time

I’d like to clear the history of some of my sensors depending on how much time has passed.

For example:

  • from the past two weeks keep all recorded sensor values,
  • from 2 weeks ago till 6 months ago, keep 1 sensor value per day
  • from 6 months ago or longer, keep 1 sensor value per week

Would be great if we could implement a setting for something like this into the history component.

This could help keep my database clean and HomeAssistant responding quickly while allowing a general overview of sensor values in the past (i.e. helpfull for smart meters for energy and gas consumption).

Duplicate post