Open Loader23 opened 1 month ago
I have the same problem after upgrading to 2024.10.2
After some experimenting with my own configuration, this seems to happen:
start: '{{ 0 }}'
(= Stats Start)start: '{{ 0 }}'
) = 1/1/1970 to Source Start.
To test, set start: '{{ }}'
to a value after Stats Start.
In my case, I added the source sensor on 11-05.
This produces correct behavior (Stats Start > Source Start):
start: "{{ now().replace(month=11, day=6, hour=0, minute=0, second=0, microsecond=0) }}"
This produces wrong behavior (Stats Start < Source Start):
start: "{{ now().replace(month=1, day=1, hour=0, minute=0, second=0, microsecond=0) }}"
The problem and the solution was already described here:
https://community.home-assistant.io/t/history-stats-sensor-creates-wrong-data/476466/6
According to this solution, this change should fix the error in data.py (https://github.com/home-assistant/core/tree/dev/homeassistant/components/history_stats):
previous_state_matches = ( self._history_current_period and self._history_current_period[0].state in self._entity_states and start_timestamp > self._history_current_period[0].last_changed.timestamp() # fix first period )
@cdce8p history_stats has no Integration Owner. I am missing knowledge to do it myself. Something for you?
I believe this will be fixed by https://github.com/home-assistant/core/pull/126271
The problem
Hi, my history stats sensor is not working correctly. Iam having this Issue since 2 Years and could work around it with an old custom integration of history stats. Now the HA Log says: _TIME_HOURS was used from historystats, this is a deprecated constant which will be removed in HA Core 2025.1 So I thought it would have been fixed by now, but thats not the case:
As soon as I activate the Switch it goes from 0 to over 400.000.
What version of Home Assistant Core has the issue?
2024.10.2
What was the last working version of Home Assistant Core?
June, 2022
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
Anything in the logs that might be useful for us?
No response
Additional information
No response