dyfcom
(Tetra)
September 18, 2024, 5:02pm
1
Hello,
I running now the second time in trouble with the history_stats
sensor.
The issue I was having was that the sensor wasn’t resetting exactly at 00:00. It was always a little bit off, starting the new day/week a few seconds in. So the frontend chart_type: bar can’t show the right value for the day/week because it captured the value between 00:00 and when it got reset.
Then I thought about resetting the history_stats before midnight, but the reset is still a bit off after midnight.
There is a old unsolved github issue:
opened 08:45PM - 15 Jan 23 UTC
closed 06:06PM - 20 Jun 23 UTC
integration: history_stats
stale
### The problem
I have a history stat setup to monitor rainfall for 24hours b… etween 9am everyday (to match local weather) however it resets at midnight and then becomes unknown
I have tried a number of different time period settings using ed and duration 24 but it still seems to reset/stop recording at midnight
![3](https://user-images.githubusercontent.com/38182386/212566171-8c53e270-b6b4-428b-b7f9-c359b4160954.png)
![2](https://user-images.githubusercontent.com/38182386/212566178-1c1615da-175d-4fbb-8e47-f6991357020a.png)
![1](https://user-images.githubusercontent.com/38182386/212566181-74b7f284-4488-4c51-82c9-e5e1797476b8.png)
### What version of Home Assistant Core has the issue?
2023.1.4
### What was the last working version of Home Assistant Core?
_No response_
### What type of installation are you running?
Home Assistant Container
### Integration causing the issue
History_stats
### Link to integration documentation on our website
https://www.home-assistant.io/integrations/history_stats/
### Diagnostics information
_No response_
### Example YAML snippet
```yaml
- platform: history_stats
name: Raingauge tips
entity_id: binary_sensor.rain_gauge
state: 'on'
type: count
start: '{{ now().replace(hour=9, minute=0, second=0, microsecond=0) }}'
duration:
hours: 24
- platform: template
sensors:
rainfall_today:
friendly_name: Rainfall today
device_class: precipitation
unit_of_measurement: mm
value_template: >-
{% set count = states('sensor.raingauge_tips') | int(0) %}
{% set mm_per_pulse = 0.30303 %}
{% set mm = count * mm_per_pulse %}
{{ mm|round(1, 'floor') }}
```
### Anything in the logs that might be useful for us?
```txt
Nothing is shown in the logs to indicate this issue
```
### Additional information
_No response_
example:
- platform: history_stats
name: Fitnessstudio Woche
entity_id: binary_sensor.fitnessstudio_status
state: "on"
type: count
start: "{{ today_at('00:00') - timedelta(days=now().weekday(), minutes=60) }}"
end: "{{ now() }}"
Greeting