Statistics sensor (average linear) provides implausible values

Hello all,

Under certain conditions, I get implausible values from statistics sensors (average linear) after I restart Homeassistant. Implausible means that the values of the statistic sensor suddenly show very high or low temperatures of up to +1000 °C or -1000 °C, although the underlying entity is determined by the outside temperature. My outdoor temperatures tend to range between -10 °C and +42 °C :upside_down_face:.

One of the problematic sensors looks like this:

platform: statistics
name: temperature_forecast_all_next_5d_minimum_average_linear
entity_id: sensor.temperature_forecast_all_next_5d_minimum
state_characteristic: average_linear
precision: 1
sampling_size: 999
max_age:
  hours: 168

The temperature_forecast_all_next_5d_minimum_average_linear sensor to which I want to apply the average linear statistic is itself a minimum sensor, which uses values from weather forecast entities.

However, I observe the same problems of extremely high or low temperatures from the statistics sensors (average linear) also when I use actual temperatures from weather integrations as the underlying entity. I tested this for a few weather services and for each sensor there were problems:

  • OpenWeatherMap
  • Weatherbit
  • AccuWeather
  • German weather service
  • Meteorologisk institutt (Met.no)

My guess is that the statistics sensor (average linear) starts calculating before the internet-based temperature entities have loaded reasonable values. Unfortunately, I do not have the skills to investigate this further.

Does anyone else also observe corresponding problems?

It is perhaps worth mentioning: I also have analogue statistic sensors that are problem-free after restarts. The sensors that work well are based on readings of the temperature that I get via aqara temperature sensors via z2m.

I know it’s been a year but wondering if you found the issue? I am having the exact same issue where using average_linear gives weird values to sensors, even though I have a stable temperature sensor. I do see the average_linear going to super high or super low values in comparison to the data it is supposed to do the linear average of.