Average_linear over short time is "unavailable" but long term works

So I seem to either do not understand platform statistics (which is fully possible) or there is some sort of gremlin I am fighting…

In my configuration.yaml I have created a few statistics sensors:
If I use “mean” everything works.
If I use “average_linear” it kind of works, however from time to time I loose a few hours of data, if the max_age is 6h
If I on the other hand use “average_linear” with a max age of 72h - it works.

If I choose to look on the graph on the sensor that is used for the statistic sensor, the “sensor.ljussensor_sovrum_air_temperature” it shows data for all time, there are no visible gaps of data.

But for max_age = 6h and average_linera, there are drop outs from time to time for a hour or two - I find no reason for the drop outs. I simply fail to understand why it from time to time is unavaible statistic sensor data… From my point of view the data is in the original sensor - it is just when I set max_age to 6h it seems to fail for me?

Am I doing something wrong here?

I have started seeing the same behaviour. Is this something new? A regression?
Screenshot below shows the source sensor and the average linear statistic sensor.

sensor.yaml is:

- platform: statistics
  name: "powerwall_solar_average_10min"
  entity_id: sensor.powerwall_solar_now
  state_characteristic: average_linear
    minutes: 10

I have decided to not use platform: statistics - since it IS broken.

Hi I have the same problem but depending on the intgration I might have a solution for you.

it seems this happens when the value of the entity_id sensor was not changed during the scan period. In rest there is the possibilty to define a scan interval and force an update even with unchanged sensor value. So if you powerwall_solar_now is defined in the rest integration you might adapt your code according to the example below.

      - unique_id: Temperature
        name: Outside Temperature
        force_update: true
        value_template: '{{ value.split(";")[6]|int }}'
        unit_of_measurement: "%"

Now I am wondering if there is a way to do the same for the modbus integration?



I found that the filter integration does not have this issue and presents relaiable results.

    - platform: filter
      name: "temperature_avg_15m_filter"
      unique_id: temperature_avg_15m_filter
      entity_id: sensor.temperature
       - filter: time_simple_moving_average
         window_size: "00:15"
         precision: 2

I hope that is helps …