Historical stats broke somewhere

Greetings
I’m troubled. I record accumulated oil usage for my house heating and I just noticed the accumulation broken in the middle of the night on the 17th.

I don’t understand why, I don’t do any upgrades at night and the daily graph is working but both my yearly and monthly accumulations display the same value.


  - platform: history_stats
    name: Burner today
    entity_id: binary_sensor.digitalburnerstatus
    state: "on"
    type: time
    start: "{{ now().replace(hour=0, minute=0, second=0) }}"
    end: "{{ now() }}"
    
  - platform: history_stats
    name: Burner this month
    entity_id: binary_sensor.digitalburnerstatus
    state: "on"
    type: time
    start: '{{ now().replace(day=1).replace(hour=0).replace(minute=0).replace(second=0) }}'
    end: '{{ now() }}'
    
  - platform: history_stats
    name: Burner this year
    entity_id: binary_sensor.digitalburnerstatus
    state: "on"
    type: time
    start: '{{ now().replace(month=1, day=1, hour=0, minute=0, second=0, microsecond=0) }}'

I haven’t got a clue. Please help
Regards
Fredrik

Your database doesn’t have the data going back further than the number of days that you have configured. By default, the database purges information every 10 days, so you’ll only get 10 days of information. You should switch to long term stats.

So either add measurement or total_increasing?

Hi
I usually don’t bump my own posts but I feel there is some extended piece of knowledge I don’t understand here. The documentation regarding history stats is pretty easy to understand.
I have a sensor which goes “on” when the oil is flowing and I’d like to count that flow. Pretty easy, count the amount of “on” using history stats. Profit.
But this only works for daily stats and not monthly or longer where the accumulated amount is truncated at some point.

/Fredrik

Increase the number of days before you purge. As I said before, you only have 10 days of information currently. If you want more, you need to change it to more by adjusting recorder’s purge interval.

You can’t use history stats with long term statistics, but it will give you statistics for long term statistics if you set it up. I don’t know what it will do if you’re trying to count, and I do not know if you need measurement or total_increasing for that. That’s where you’ll have to play around, and it may not work.

I don’t understand, in the same HA there is this graph generated by the Energy module where I added my electricity monitor.

That uses long term statistics. History stats does not. I don’t know how to make this any more clear. You’re not recording enough information for history stats. You need to adjust the recorder integrations purge setting to larger than 10 days for the history stats integration to see more than 10 days of information. This is a limitation of history stats.

history stats uses recorder.
history uses recorder.
logbook uses recorder.

history stats is an integration.
recorder is an integration.
history is an integration.
logbook is an integration.

You can search for these integrations in the documentation to read up on them.

long term statistics is 100% separate from the integrations listed above.

Crystal clear!