#How to smooth data for a static sensor

1 messages · Page 1 of 1 (latest)

toxic arrow
#

I have an automation that I want to trigger off a fluctuating sensor (amps). I would like to smooth the data - a running average of 5 samples would be quite adequate. However, the sensor I am monitoring doesn't report if the value doesn't change. I've set up a statistical sensor and tried using a mean and several of the average methods, but all of them cease to update if the target entity doesn't update. As a result, if the target entity goes from 20 amps to zero then stops reporting, the average sensor remains high. Am I missing something? Any suggestions on how to handle this?

forest perch
#

Are you running the latest version of HA? There was a PR a few months ago that should have addressed this, as long as the sensor does actually repeatedly report zero instead of reporting one zero and then not reporting again.

https://github.com/home-assistant/core/pull/129211

GitHub

Breaking change

Some of the statistics functions will return different values than before, because repeating values will
be entered into the buffer. This affects functions like the time-based aver...

toxic arrow
mortal star
#

While this is ugly, if you really must have this, you can make a template sensor that applies a small "fuzz" to the source, to keep a stream of new data flowing.

#

Like during even-numbered minutes return the raw value, and in odd numbered minutes, return the raw value + 0.00001

#

Kind of a bad limitation of sample based calculations. =\

forest perch
#

I haven’t tried this since the updates to the statistics integration but you might not need the fuzz workaround any more, if a time-pattern-based template sensor fires state_reported events. I don’t know if it does though.