Statistics helper

Hi, I have this template that stopped working, what’s wrong with it?

Sensor is working.

Then in the code:

  • platform: statistics
    entity_id: sensor.sa_generation_power
    name: “Power Generation Trend Mean 5min”
    unique_id: “power_generation_trend_mean_5min”
    state_characteristic: mean
    max_age:
    minutes: 5
  • platform: statistics
    entity_id: sensor.sa_generation_power
    name: “Power Generation Trend Mean 7min”
    unique_id: “power_generation_trend_mean_7min”
    state_characteristic: mean
    max_age:
    minutes: 7

It used to work but somewhere along the line it stopped working

Why Does it jump in and out? I use it to smooth out solar

In your screens you can see the last update of the source sensor was 26 minutes ago. Since max_age is set to 5 minutes, the helper ignores any samples from before that.

You can try setting keep_last_sample to true, which will ignore the max age for the very last sample, so it will still use the last sample even if it’s older. But keep in mind that this is kind of cheating, as it’s not current data (because the original sensor for whatever reason did not provide current data).

1 Like