History Stats Duration Not Working

Hi,

I have a couple of history stats that I use to calculate how long my wifes blood glucose levels have been in range over 24 hrs, 7 days, 14 days and 30 days however when i set a duration of say 7 days it seems to reset back to 0 at midnight each day rather than sum the cumulative total.

When i go to check the values they are all the same

now I only started yesterday so surely the week one value should be yesterdays total plus that of todays ? It appears at midnight the value is going back down to zero

image

what am I doing wrong as this should be a cumulative total for the last 7 days

Can you please share your history stats sensor config?

In the days of YAML was much easier to just paste the code, however please see setup screenshots below from GUI

Try changing it to:

End: {{ now() }}

Duration: 7:0:00:00

This will not retroactively fix all your data up to now, but going forward should work.

I note you have a month sensor too. Have you increased your recorder purge_keep_days to cover a period this long?

If not, it won’t work. By default you only have 10 days state data for the history stats integration to use.

I have made the changes … lets see what happens

#Historical Stats
recorder:
  purge_keep_days: 90

and changed the end …

1 Like