mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Add 'days' flag to history fetch urls. (#5895)
* Add 'days' flag to history fetch urls. * Fix unrenamed variable * Switch to end_time param instead of days * Checkthat end_time is parsed
This commit is contained in:
parent
0effe14619
commit
ffb46ab541
@ -230,7 +230,6 @@ class HistoryPeriodView(HomeAssistantView):
|
|||||||
now = dt_util.utcnow()
|
now = dt_util.utcnow()
|
||||||
|
|
||||||
one_day = timedelta(days=1)
|
one_day = timedelta(days=1)
|
||||||
|
|
||||||
if datetime:
|
if datetime:
|
||||||
start_time = dt_util.as_utc(datetime)
|
start_time = dt_util.as_utc(datetime)
|
||||||
else:
|
else:
|
||||||
@ -239,6 +238,13 @@ class HistoryPeriodView(HomeAssistantView):
|
|||||||
if start_time > now:
|
if start_time > now:
|
||||||
return self.json([])
|
return self.json([])
|
||||||
|
|
||||||
|
end_time = request.GET.get('end_time')
|
||||||
|
if end_time:
|
||||||
|
end_time = dt_util.as_utc(
|
||||||
|
dt_util.parse_datetime(end_time))
|
||||||
|
if end_time is None:
|
||||||
|
return self.json_message('Invalid end_time', HTTP_BAD_REQUEST)
|
||||||
|
else:
|
||||||
end_time = start_time + one_day
|
end_time = start_time + one_day
|
||||||
entity_id = request.GET.get('filter_entity_id')
|
entity_id = request.GET.get('filter_entity_id')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user