Open tanelvakker opened 1 month ago
Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (history
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
history documentation history source (message by IssueLinks)
I copied the history component over as a custom component and added logger to it.
_LOGGER.info(f"history returning empty for entity_ids: {entity_ids} {get_instance(hass).recorder_runs_manager.first.start}")
which produces following log line: 2024-05-20 18:26:54.129 INFO (MainThread) [custom_components.history] history returning empty for entity_ids: ['sensor.load_power'] 2024-05-19 15:56:03.193007
this is what is in the recorder runs database. the question is why are previous runs missing from it?
The problem
I use emhass to automate energy usage. Emhass queries past power usage using /api/history/period/ endpoint. About once a month it fails to retrieve data from a specific time range. After a day or so the issue mitigates automatically. I have narrowed it down to something to do with end_time. By default it's start + 1 day. I am getting a 200 OK response, but body is "[]" when it does not work. https://HA:8123/api/history/period/2024-05-18T15:56:00+00:00?filter_entity_id=sensor.load_power does not work https://HA:8123/api/history/period/2024-05-18T15:56:00+00:00?filter_entity_id=sensor.load_power&end_time=2024-05-19T18:56:00 also does not work Extending it by 1 minute to https://HA:8123/api/history/period/2024-05-18T15:56:00+00:00?filter_entity_id=sensor.load_power&end_time=2024-05-19T18:57:00 returns data just fine.
I suspect the code path it takes is https://github.com/home-assistant/core/blob/7998f874c09afc0d0537279d92aefb92da6fc573/homeassistant/components/history/__init__.py#L110C31-L110C53
Is there a way to check recorder_runs_manager.first.start manually?
How can I troubleshoot this further?
What version of Home Assistant Core has the issue?
2024.5.4
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
history
Link to integration documentation on our website
https://www.home-assistant.io/integrations/history/
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response