Strange history statistics

I’ve started to use history_stats sensors to keep track of how long time I heat my pool, fill water etc. Introduced this a couple of days ago and I’ve been happy with what I’ve seen until this morning.

Right now my sensor.poolheating_daily shows more than 7hours, but the heating has not been on since midnight. As far as I understand, history_stats just sums up history date for the entity used as the base for the measurement.

- platform: history_stats
    name: Poolheating daily
    entity_id: switch.poolheating
    state: "on"
    type: time
    start: "{{ now().replace(hour=0, minute=0, second=0) }}"
    end: "{{ now() }}"

The history graph of switch.poolheating looks like this:

How do I end up with +7hr as my daily figure of pool heating?

I can mention my other history_stats sensors present correct values.

What version of Home Assistant are you on?

There were a bunch of fixes applied recently.

I’m on 2022.6.6. I’ll make a try with 2022.6.7 and see if it helps.

2022.6.7 fixed the problem! Thanks!

1 Like

Unfortunately it seems like my problem is back again. I’m on 2022.6.7 and I have not made any changes in my definition of my history_stat sensors. But all of a sudden my sensor that keeps track of pool water circulation presents 0 this morning, even if the circulation was on for 4hr this night.

History gives the pump turned on 00:00:14 and off at 04:00:15. On/off is triggered by energy price, but as far as I understand history_stat just sums up historic data. So it should not really matter what triggers on/off of the actual sensor historic_stat looks at.

It is just this historic_stat sensor that fails. My others are just fine. Could it be related to the on time happens very close to midnight?

Unfortunately history statistics keeps bothering me. It seems like data for daily usage becomes wrong if the measured entity is “on” over midnight. Exactly the same problem as I reported in my first post in this thread. But now this happens for another sensor measuring how long time the switch controlling the pool water filling is on each day.

I have a this sensor defined:

 - platform: history_stats
    name: Waterfill daily
    entity_id: switch.poolwater
    state: "on"
    type: time
    start: "{{ now().replace(hour=0, minute=0, second=0) }}"
    end: "{{ now() }}" 

Tonight, the switch was open less than 5 minutes aroung midnight:

image

I expect my history statistics should present 3m14s for July 27th and 22s for July 28th. But it continues to count all day ( today) even if the switch turned of 22s after midnight. Right now it looks like this:

image

Am I doing something wrong here, or is there a bug in history stats?

I’m on 2022.7.5, but I can’t see any correction made in 2022.7.6 or 2022.7.7 in this area, so I doubt an update will solve this.

Nope. That looks broken.

If this issue does not match your issue, open a new one with exactly the info you have posted in your last post:

Ok, your proposed filter in the github link does not seem to work. Gives a huge amount of issues. However, I found this issue that seems to be very close to what I have observed. However, this issue is closed and I think it should be reopened instead of creating a new one. This is the issue I refer to:

I can’t reopen this issue, so if someone can help out and include a reference to what I write above, it would be nice. Many thanks in advance!

Edit: A new issue reported!