robmarkcole / HASS-Sighthound

Beta features for Home Assistant Sighthound integration
https://www.home-assistant.io/integrations/sighthound/
MIT License
34 stars 10 forks source link

Check response status code #1

Closed robmarkcole closed 6 years ago

robmarkcole commented 6 years ago

The following error is caused by status code not being checked:

Update for image_processing.sighthound_porch fails
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 197, in async_update_ha_state
    yield from self.async_device_update()
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 318, in async_device_update
    yield from self.async_update()
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/image_processing/__init__.py", line 145, in async_update
    yield from self.async_process_image(image.content)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/image_processing/sighthound.py", line 110, in process_image
    self.faces, self.persons = parse_api_response(response)
  File "/home/homeassistant/.homeassistant/custom_components/image_processing/sighthound.py", line 41, in parse_api_response
    for obj in response.json()['objects']:
KeyError: 'objects'