Do sensor update every second, but only record every 10

Hi,

I have a sensor that I could update every second and get a more real-time measurement, but doing this will write so much info to the recorder, that when I’ll retrieve this, it will take ages and even slow down the browser massively.

Is there any way that I can make a sensor show a update every second, but only record it every 10 seconds (or similar)?

I would be extremely grateful!

There’s no way to specify this for the recorder. You might be able to do this:

Exclude your 1 second sensor from the recorder. You won’t be able to graph this but it will show updates to the numeric value every second.
Create a template sensor that follows the 1 second sensor but which uses sensor.time as the update rate (every 1 minute). Do not exclude this from the recorder. You will be able to graph it.

e.g.

sensor:
  - platform: template
    sensors:
      slow_sensor:
        friendly_name: "Slow Sensor"
        entity_id: sensor.time # only updates template every minute
        unit_of_measurement: 'whatever'
        value_template: "{{ states('sensor.1sec_update_sensor_here') }}"
2 Likes

I like that solution. However, home assistant has changed the way template sensors are updated depending on time. This solution does not throttle the update rate anymore, as far as I can see. There might be another way, will try to figure it out.

Would it be possible not to record the original sensor to history but set it up in statistics(or just template as second sensor) to record the readings at an interval of your choice.

Indeed this two year old post is no longer a viable solution.

You should use a triggered template sensor instead.

I use the following workaround:

  • exclude the high frequency sensor from logging, history and recorder
  • set up an input_number for a low frequent representation
  • use an automation to copy the fast sensor to the input number on a timed interval.

not pretty, but works.
Setting up a template second sensor does not help at the time of 2021-12. The template gets updated whenever a referenced source gets updatet. Esphome has a throttle filter for that. Would help here too, especially as database has no averaging, just purge. With the 1000+ entities I have the db gets slow.

It does if you use a triggered sensor.

yepp, just found it. Thanks
Rate limiting on template sensors.