Statistics missing values

Hey HA Community,

I’m trying to use the statistics sensor to compute an average of humidity. Gaps are appearing in the data, and I think it is due to the source value not changing and the statistics sensor not recognizing that the value is the same. I’ve tried to use mean and averge step with the same result. Is this a bug? Should I be using different characteristic?

EDIT:
It seems that once the max_age has been reached, there are no values to base the statistics sensor off of. The value of the source sensor is not being carried forward because there is no change. Is there a way to force a sensor update at least once per period?

Configuration is below for these sensors:

sensor:
  - platform: statistics
    name: "Thermostat Humidity Mean"
    entity_id: sensor.thermostat_current_humidity
    state_characteristic: mean
    # sampling_size: 50
    max_age:
      hours: 1
  - platform: statistics
    name: "Thermostat Humidity Average Step"
    entity_id: sensor.thermostat_current_humidity
    state_characteristic: average_step
    # sampling_size: 60
    max_age:
      hours: 1

I have exactly the same problem.
You would like something like “max age, but at least one value”

1 Like

Any news on that? I’m stuckw ith the same issue and my solution was to add ANOTHER sensor (B) with a template, which wraps the statistics sensor (A) in a way, that it B ist set to A if A is a number or else it is set to the last value of B itself. This works, but it would be nice to have the option in statistics to either force it to update on at least N values, or keep the last valid value.