History Statistics Sensor reports incorrect data

I want to count the hours/minutes a device is ON since 5 am on the same day.
So if the device worked for 1 hour yesterday and I query the sensor at 10 am today, I should get 0.
However, it looks like the sensor isn’t ‘zeroed’ at 5 am as I would expect and I get ‘1 hour’ unless I use the device today and the counts reset to the time of use today.
Here is my sensor configuration:

    entity_id: switch.some_name
    state: 'on'
    type: time
    start: '{{ now().replace(hour=5).replace(minute=0).replace(second=0) }}'
    end: '{{ now() }}'

This is what the graph looks like:
54
Here you can see the device worked yesterday around 6pm, then it was off until today at 9 am.
But if I query the sensor value at 6 am for example, I would get the value of it yesterday instead of 0.
Any ideas ?