Time Simple Moving Average not working properly

Simple time moving average helpers stop updating when the underlying sensor stops updating, like when its a power measurement from a socket that is off and remains at zero:

Ive read some ways to force updates in Z2M, but that feels like the wrong solution and apparently is going to get depreciated. A time based moving average should update every time, Id call this a bug, but Im open to work arounds.

Same thing here. I tried filtering the UV index to get rid of some weird, sometimes extreme 1-minute peaks that are obviously wrong:

  - platform: filter
    name: "Filtered UV Index"
    unique_id: filtered_uv_index
    entity_id: sensor.ecowitt_uv_index
    filters:
      - filter: time_simple_moving_average
        window_size: "00:03"
        precision: 0

This is what I get:

Simply does not return to zero no matter how long I wait. Only reloading all YAML config forces the sensor to update and it snaps back to where it should be.

Problem seems to be that this sensor I want to filter only updates upon change and the filter only seems to recalculate when it gets a new input - no matter how old that last input is!

…I too would consider this a bug, but I’m no expert.

Another “simple time moving average” filter that has an underlying sensor that constantly updates works perfectly fine.

Any ideas / solutions anyone?

The issue has been discussed quite some times:

even in 2021:

and here in 2023:

I’ going to try this one out:

I have sent the corresponding bugreport.

While the PR was in progress, I rewrote the original integration code and fixed the issue in the custom HACS integration: