mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 02:37:08 +00:00
Fixed invalid response when sending a test-request from Locative iOS app (#5179)
This commit is contained in:
parent
2f907696f3
commit
497a1c84b5
@ -63,18 +63,18 @@ class LocativeView(HomeAssistantView):
|
|||||||
return ('Device id not specified.',
|
return ('Device id not specified.',
|
||||||
HTTP_UNPROCESSABLE_ENTITY)
|
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:
|
if 'trigger' not in data:
|
||||||
_LOGGER.error('Trigger is not specified.')
|
_LOGGER.error('Trigger is not specified.')
|
||||||
return ('Trigger is not specified.',
|
return ('Trigger is not specified.',
|
||||||
HTTP_UNPROCESSABLE_ENTITY)
|
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('-', '')
|
device = data['device'].replace('-', '')
|
||||||
location_name = data['id'].lower()
|
location_name = data.get('id', data['trigger']).lower()
|
||||||
direction = data['trigger']
|
direction = data['trigger']
|
||||||
gps_location = (data[ATTR_LATITUDE], data[ATTR_LONGITUDE])
|
gps_location = (data[ATTR_LATITUDE], data[ATTR_LONGITUDE])
|
||||||
|
|
||||||
|
@ -108,6 +108,13 @@ class TestLocative(unittest.TestCase):
|
|||||||
req = requests.get(_url(copy))
|
req = requests.get(_url(copy))
|
||||||
self.assertEqual(200, req.status_code)
|
self.assertEqual(200, req.status_code)
|
||||||
|
|
||||||
|
# Test message, no location
|
||||||
|
copy = data.copy()
|
||||||
|
copy['trigger'] = 'test'
|
||||||
|
del copy['id']
|
||||||
|
req = requests.get(_url(copy))
|
||||||
|
self.assertEqual(200, req.status_code)
|
||||||
|
|
||||||
# Unknown trigger
|
# Unknown trigger
|
||||||
copy = data.copy()
|
copy = data.copy()
|
||||||
copy['trigger'] = 'foobar'
|
copy['trigger'] = 'foobar'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user