Sensor value during X time

"Hello everyone,

Lately, I’ve been encountering the problem that I need a virtual sensor which records the values of a real sensor over a defined period of time, calculates them, and outputs the desired value. For example:

My sensor, ‘sensor.popp_z_weather_velocity,’ is essentially a propeller that spins in the wind and indicates its speed in m/s. It could be referred to as a gust sensor. To determine the wind speed, it would require an average over 10 minutes. But how do I do that? (Additionally, it would be helpful to have a sensor that shows me whether this last 10-minute value has risen or fallen in the past 20 minutes, but that’s another topic.)

Anyway, I mentioned that I’ve been confronted with this issue lately. My biggest problem is that it involves all sorts of values, mostly meteorological/climatic, but unfortunately not electrical.

Before any misunderstandings arise: I’m not very familiar with line coding. I could handle templates in YAML or a Node-RED flow. Helpers would also be appreciated, but I haven’t yet seen how I can incorporate the time factor. Any ideas?

You can use this integration to get the average for the last 10 minutes:

To determine if a value is rising or falling use the trend sensor:

1 Like

Hi,
I have done an statistics sensor to give an average value just as you want:

It looks like this:

- platform: statistics
  entity_id: sensor.gw1100a_v2_2_3_wind_speed
  sampling_size: 50
  state_characteristic: mean
  max_age:
    minutes: 10
  name: wind_speed_mean_10min

Hope this is what you are looking for? This is that i know of not possible to create with helpers as of now, so you need to write it.

1 Like

Sorry if my answer took a while. I first had to puzzle and test, but now it works. Thank you.
By the way, I couldn’t use the trend helper because the binary state doesn’t remain constant. It’s also stupid that there are many on/offs in the defined classes but not a single one decreases/increases.
With the Derivative Helper it gets pretty good.