Fixed invalid response when sending a test-request from Locative iOS app (#5179)

This commit is contained in:
Sander de Leeuw 2017-01-05 09:05:39 +01:00 committed by Johann Kellerman
parent 2f907696f3
commit 497a1c84b5
2 changed files with 13 additions and 6 deletions

View file

@ -63,18 +63,18 @@ class LocativeView(HomeAssistantView):
return ('Device id not specified.',
HTTP_UNPROCESSABLE_ENTITY)
if 'id' not in data:
_LOGGER.error('Location id not specified.')
return ('Location id not specified.',
HTTP_UNPROCESSABLE_ENTITY)
if 'trigger' not in data:
_LOGGER.error('Trigger is not specified.')
return ('Trigger is not specified.',
HTTP_UNPROCESSABLE_ENTITY)
if 'id' not in data and data['trigger'] != 'test':
_LOGGER.error('Location id not specified.')
return ('Location id not specified.',
HTTP_UNPROCESSABLE_ENTITY)
device = data['device'].replace('-', '')
location_name = data['id'].lower()
location_name = data.get('id', data['trigger']).lower()
direction = data['trigger']
gps_location = (data[ATTR_LATITUDE], data[ATTR_LONGITUDE])