History_stats, does this reset every day?

Hi everyone,
I want to collect below stats from 22:00 - 06:00 using the history_stats platform. I want it to reset every night though, not sure if it does that and i can’t figure it out from the docs.

Thanks for looking.

    name: stats_turn
    entity_id: binary_sensor.sensor_1_contact
    state: 'off'
    type: count
    start: "{{ now().replace(hour=22, minute=0, second=0) }}"
    duration:
      hours: 8```

What do you mean by this?

If you want it to reset at midnight that is going to be in the middle of your collecting interval.

Fortunately (or unfortunately) that is what it is actually doing:

At the moment it shows data from 10pm to midnight.

As once you cross the midnight boundary the start date in now() changes to the new day. So it will then be measuring from 10pm today to 6am tomorrow (which you don’t have data for as it is in the future).

A better time interval would be:

    end: "{{ now().replace(hour=6, minute=0, second=0) }}"
    duration:
      hours: 8

This will show data from 6am on the current day back 8 hours to 10pm the day before.

I meant that i want the value to be 0 and start every night collecting the stats again.

So, it seems the better way for me currently is to collect all the history, and reset the history_stats sensor by automation (i want the data to be available throughout the day).

Not sure how to set a sensor (as i would for example in developer tools) in the action part of a automation though.

Yes and you still have not said what you mean by “every night”, 6pm? 10pm? Midnight?

The range I specified above counts off events of your contact sensor from 10pm to 6am. And it “resets” every night at 10pm.

I haven’t decided on the value yet, it could be anything. Let’s say it would be 10pm.

The problem is if i do it this way the data actually becomes unavailable from the history recorder, which i didn’t realise, i thought it would just stop recording (i guess it does, but if i refer to the sensor i just get a nice N/A in my graph).

I have no idea what you are talking about.