History REST API returns blank unless date range is wide

Hi All,

I’ve got an interesting occurrence where by the history API resource is only returning data for date X when the end date for the call is set to X+3 days for specific dates - even when data exists for all of the dates within the range? (X , X+1 , X+2 , X+3 )…

If I ask for start date of XT00:00:00+00:00 and end date of XT23:59:59+00:00 I get [] as the returned data.

An end date of X+3T23:59:59+00:00 I get data, for X AND all dates until my end date. X In my example is 2024-04-19 - still within my retention period for a few more days.

I’ve reviewed Empty response from the REST API on history endpoint when end_time is used - #4 by dremsol, and RESTFul API - History endpoint - Answered - #2 by Jason_DeVelvis which are not my exact issue, but did point toward some differing formatting of the query string parameters however I still get the following:

(Note: The same occurs with using T as the date-time seperator, %20 as stated in the post above, and also using Z or +00:00 as the timeszone identifier)

(2nd Note: Obviously all the correct ‘missing’ information in the request is present in my call, I’ve removed my host and auth token to post here)

I’ve also revieed the docs and believe I am adhering to the request specs.

1st call - Simple day
Just get me the data for the single day:



2nd Call - Raise the date-span a bit
Thinking maybe I need to go outside of the 19th data to get it?



3rd Call - The working request
Extend the date-span to the 22nd… X+3 days - we get data INCLUDING all the other days.


        "entity_id": "sensor.energy_generated",
    "state": "2.0",
    "last_changed": "2024-04-19T06:06:15.489355+00:00"
... LOTS more data including dates for the 20th, 21st and 22nd...

Interestingly, this does not happen only on a start date of the 19th, it also occurs on the 20th and 21st… Only when the end time in my query is set to the 22nd - do I get data.

What is special about the 22nd…

Conversely; I can make a request for just a start date of 22, 23 or 24th - and get data without having to specify an end date in the query…

I’m really not sure what is going on and why a seemingly unrelated combunation of start and end period times for specific dates is required.