Subsampling of sensors with templating?

My DSMR (smart energy meter) is spitting out sensor measurements every second. Is it possible to sample the value of the gas/power consumption every 5 minutes so I can only store that in the database? (I already excluded the current values for history).
Sensor templates only seem to trigger on changes in the sensor and it doesn’t seem possible to create an automation that triggers writing a sensor state every 5 minutes, or is it?

The only thing that comes to mind is to create an automation that runs every five minutes, that invokes a python_script that reads the state of the existing sensor and writes the value to another “sensor” state in the state machine. Or the automation could be triggered on a state change of the existing sensor, and in the actions both calls the python_script and starts a five minute timer. The automation would also have a condition that the timer is idle. That way it will update the new “sensor” when the existing sensor changes, but not any more frequently than every five minutes.

I think you want the throttle filter of the filter sensor

1 Like

I want to thank you both for thinking along. The filter sensor seems to be exactly what I need. But as I’m new to home assistant it’s good to know about python_script as well.

I just found out I have to exclude the dmsr sensors from the recorder (not history - i’m purging my 1.2 GB database right now).

1 Like