Extend logbook api to be able to fetch a slice of data between two time boundaries. (#35847)
* Create logbook_timeslice api * add end_datetime * Add tests * switch to end_time to match history api
This commit is contained in:
1 parent
dcb04acc65
commit
751e2f4125
2 files changed
+69
-2
No files matched your search
@@ -171,8 +171,17 @@ class LogbookView(HomeAssistantView):
|
||||
period = int(period)
|
||||
|
||||
entity_id = request.query.get("entity")
|
||||
start_day = dt_util.as_utc(datetime) - timedelta(days=period - 1)
|
||||
end_day = start_day + timedelta(days=period)
|
||||
|
||||
end_time = request.query.get("end_time")
|
||||
if end_time is None:
|
||||
start_day = dt_util.as_utc(datetime) - timedelta(days=period - 1)
|
||||
end_day = start_day + timedelta(days=period)
|
||||
else:
|
||||
start_day = datetime
|
||||
end_day = dt_util.parse_datetime(end_time)
|
||||
if end_day is None:
|
||||
return self.json_message("Invalid end_time", HTTP_BAD_REQUEST)
|
||||
|
||||
hass = request.app["hass"]
|
||||
|
||||
def json_events():
|
||||
|
||||
Reference in new issue
Block a user