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
1 changed files with 8 additions and 2 deletions
|
@ -230,7 +230,6 @@ class HistoryPeriodView(HomeAssistantView):
|
|||
now = dt_util.utcnow()
|
||||
|
||||
one_day = timedelta(days=1)
|
||||
|
||||
if datetime:
|
||||
start_time = dt_util.as_utc(datetime)
|
||||
else:
|
||||
|
@ -239,6 +238,13 @@ class HistoryPeriodView(HomeAssistantView):
|
|||
if start_time > now:
|
||||
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
|
||||
entity_id = request.GET.get('filter_entity_id')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue