Problem with the the time_throttle filter with repeated values

I’m trying to use the filter integration on some rapidly reporting sensors to reduce the volume of data sent to a database. I still want the sensor to report rapidly so I can have the dashboard update close to real time.

An example:

  - platform: filter
    name: "filtered sensor.coffee_machine_energy_power"
    entity_id: sensor.coffee_machine_energy_power
    filters:
      - filter: time_simple_moving_average
        window_size: "00:01"
      - filter: time_throttle
        window_size: "00:01"

The problem occurs when the coffee machine is turned off - after that point, the unfiltered sensor stops updating (because it isn’t changing, as it is always 0). However, from what I can see once that happens, the time_throttle filter never gets triggered, so it ‘sticks’ on whatever the last value it emitted happened to be - and never goes to 0. Am I doing something wrong here? How do I work around it?

No. Filters only update on state changes.

Hmm. That pretty much renders the throttle filters useless for sensors which have long periods on one value, which is a bit unfortunate.

The throttle filter reduces the number of changes. It cannot increase them.

https://www.home-assistant.io/integrations/filter/#throttle

This filter is relevant when you have a sensor which produces states at a very high-rate, which you might want to throttle down for storing or visualization purposes.

Yeah, the problem here is I have a high rate of change while the device is active, which I would like to filter, and then it goes to 0 and stays that way for a long period of time - and if that 0 gets dropped, it stays at the last value that got past the filter, which is kind of bad for doing statistics on.
In this particular case I suppose I want some way of exempting 0 values from being throttled, but that isn’t really a general solution.
Or alternatively have another thing which checks periodically if the unfiltered value is 0, and then updates the filtered value if it is.

This is the way I throttle my bed occupancy sensor:

    filters:
      - sliding_window_moving_average:
          window_size: 10
          send_every: 1
      - or:
          - throttle: 180s
          - delta: 0.02

It sends the moving average every 3 minutes unless there has been a significant change (delta is set just above the average noise floor) in which case it sends it immediately.

Maybe you could use something like that?