Sensor heartbeat documentation

Hello, I have trouble understanding the heartbeat documentation. Specifically this sentence:

If the sensor value changes during the interval the interval will not reset.

I would like my sensor to report a value to HA not only when it changes, but also periodically when it remains constant. Essentially, to report the value at least “once per hour”. My understanding is that I can add - heartbeat: 1h at the end of filters of my sensor. But I do not get what that documentation is trying to tell me :smiley: Can anybody phrase it more clearly? Thanks!

It basically means that whatever happens at sensor value, it’ll always send update every heartbeat time. Let’s say you setup at 1h as you plan to do, you’ll get an update of your sensor only once per hour (whatever sensor values change or not :wink: More clear ?

But it will still send updates whenever the value changes as well, right?

Update 2022-10-19: It looks like this does not happen. It only sends the value in the heartbeat frequency…

I’m seeing the same problem:
when using heartbeat: 15s in the filters, the sensor only publishes updates every 15s, even though my sensor changes it’s value every 500ms when the device is active (I’m using it for power measurements of a hlw8012 sensor)

I think I found the solution, you need to nest it below an or “filter” - see Sensor Component — ESPHome
e.g.:

  sensor:
    - platform: ...
      ...
      filters:
        - exponential_moving_average: { send_every: 50 }
        - or:
          - delta: 0.1
          - heartbeat: 15s
3 Likes