Filter time_simple_moving_average stopped working correctly recently

I’m using a sensor with a filter:time_simple_moving_average to tell whether my power-saving washing machine is finally done with its cycle. It had worked perfectly for several months, but a few weeks ago it’s started thinking the thing is always on. I haven’t changed the code, and from what the graph looks like, it should be turning off. Did something in the code change recently with an update that would have affected this? Have I been doing it wrong all along? Is there a better way to do this? Here are screenshots of the graphs of what it’s filtering, what it’s reporting, and then the code of the filter itself. I’m baffled.


## WASHING MACHINE ##
## Makes the washing machine on/off sensor work with the power saving thing ##
  - platform: filter
    name: "filtered washer power 2"
    entity_id: sensor.sonoff_10012f02d4_current
    filters:
      - filter: time_simple_moving_average
        window_size: 0:05
## END WASHING MACHINE ##
1 Like

Recently I implemented new sensor using this filter and I observed exactly the same behaviour. Seems that average filter recalculates only when the source sensor changes value (diregards time). In your case seems that your washing machines stops and current sensor is no longer updated (being constant 0), causing lack of subsequent recalculations of average. In my case I tried to average/smooth the light level sensor that changes infrequently (once every minute at most, once every few hours at least), causing average not being updated when long period of unchanged source value is encountered.
Did you found any solution to this problem?

If the source sensor is a MQTT sensor you can use ‘force_update’ which will send updates even if there is no change to the value.