Hi,
I have a raw sensor value which varies over time. In my case it’s a force sensor, but I guess for this question it could be any type of sensor which returns a number within a range.
What I’d like to do is output a metric which represents the volatility of the sensor value over a certain time period (e.g. last minute or last hour). My high-school statistics knowledge is a bit rusty, but I think what I need is a ‘moving standard deviation’. Can anyone suggest how I could calculate this from a sensor value in ESPHome? (Note, I want to do this on the ESPHome device itself and not externally in HA or some other system).
I can see that ESPHome has a filter for a basic moving average, but I don’t see any filter for moving standard deviation. I’m guessing I might be able to use a lambda filter, but I don’t know how I could write one which could perform a calculation on a range of historical values…?
Any advice is much appreciated. Thanks