Statistics card rolling window long duration

I’m having a problem setting up the statistics card with data from rolling window that’s longer than ~12 days. Specifically, I want data from the last 12 months and whatever I try, it seems to only get a value from the last 12 days. Even though data is there, for example when I set a fixed period in similar statistics card.

Here’s the card config I’m trying right now:

type: statistic
stat_type: change
entity: sensor.fv_today_production
      days: 365

It gives the same value as if I set days to 12. In fact, anything higher than 12 gives the same value.

But for example this gives higher, correct value:

  start: 2024-03-01T00:00:00.000Z

Am I doing something wrong?

I can reproduce the Issue. It also happens when using hours as a rolling window duration. As soon as the duration reaches a certain amount of hours the value no longer changes. The exact amount of hours is varies depending on the sensor.

The issue only occurs when using increasing sensors like energy meters. Sensors with state_class measurement seem to work just fine.

Edit: The thing I said about it also happening with hours is not totally true. Will do further testing

Edit 2: The issue is time dependent. For me it occurs at a window size of 11 days which matches the recorder purge interval. That should not be a problem because we are dealing with long term statistics but who knows. If I specify 11 days as hours: 246 (11*24) then the result is identical

There’s nothing to test here, your database stores 10 days of information. That’s all you’ll get for statistics.

Statistics integration does not use long term stats table in the database. It just uses the normal states table, which is 10 days unless you changed it.

We are talking about the statistics card. It does use the long term stats table. Otherwise why does it support yearly periods?

This works for example

type: statistic
    period: year
stat_type: change
entity: sensor.import_active_energy

OP was talking about how displaying long term statistics for a fixed window works but the rolling windows cuts off at a certain point.

1 Like

Looks like a bug then, write it up

Can confirm, it gives wrong answer.

Thank you for taking the time to check it. So it looks like the issue was not on my side. I’ll see how I can report it, haven’t really done that before.

And done here: