A little help with statistics sensor

Hi all
I just updated HA to 2021.12.7 version
I have the following sensor which I don’t understand how I should update correctly according to the new demands (state_characteristic:)

  • the sensor.wind_speed is an anemometer which shows the wind speed every 10 seconds.
  - platform: statistics
    entity_id: sensor.wind_speed
    name: wind speed ss 90 m4
    sampling_size: 90
    max_age:
      minutes: 4

I thought that the following should do but it doesn’t calculate the values as before.

  - platform: statistics
    entity_id: sensor.wind_speed
    name: wind speed ss 90 m4
    state_characteristic: value_max
    sampling_size: 90
    max_age:
      minutes: 4

Can someone help-explain please?

edit: I think I have to add

state_characteristic: mean

but if someone could confirm it would help.
Thanks

nothing from the above works as before. I don’t know what I should change

Shouldn’t the name be surrounded by quotes?

Before I can say mean or value_max need to know, do you want 4 minute mean or max wind speed?
if mean, then yes state characteristic should be mean.

Hi and Happy New Year.
To be honest I think that the mean is what i need. Do you know what the below sensor calculates? (mean?)

Regarding the quotes I am not sure. I have it withoutt quotes and it doesn’t produce any problem.

- platform: statistics
    entity_id: sensor.wind_speed
    name: wind speed ss 90 m4
    sampling_size: 90
    max_age:
      minutes: 4

[/quote]

It should calculate the mean based on 4 minutes of data or 90 data points whichever is smaller.

From here:

The statistics sensor updates with every source sensor update. The value of the sensor represents one statistical characteristic, with mean being the default. The time period and/or number of recent state that should be considered is an important factor here. Check the configuration section below for options.

state_characteristic string (Optional, default: mean / count)

The characteristic that should be used as the state of the statistics sensor (see table above). Beware that this parameter will become mandatory in a future version. Include in your configuration. If currently omitted, the default characteristic for a sensor source sensor is “mean”, for a binary_sensor “count”.

If it is going to become mandatory it is a good idea to explicitly name it.

1 Like

I think that mean is working fine now. It need more time to calculate the values correct. Thanks!