I notice a bunch of errors in the Home Assistant log like this:
2019-08-06 00:05:06 ERROR (MainThread) [homeassistant.helpers.entity] Update for image_processing.cam8_coral fails
Traceback (most recent call last):
File "/usr/src/app/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
await self.async_device_update()
File "/usr/src/app/homeassistant/helpers/entity.py", line 378, in async_device_update
await self.async_update()
File "/usr/src/app/homeassistant/components/image_processing/__init__.py", line 132, in async_update
await self.async_process_image(image.content)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/deepstack_object/image_processing.py", line 157, in process_image
predictions_json = response.json()["predictions"]
KeyError: 'predictions'
The error occurs when a response comes back from the coral-api.py server, and where there are no detections at all. The HTTP response is '200 OK', but there doesn't appear to be any 'prediction' key inserted into the response. That is only included in the response at https://github.com/robmarkcole/coral-pi-rest-server/blob/84d54ba69b5b909e7a27ec5cea0b36ab853095c6/coral-app.py#L77 if there's any predictions returned from the engine. It seems like the response would only have the success property as False, but that's not checked for.
I'm also not sure if it makes sense or is safe to return a null predictions array from the coral-api.py service? Again, this is also related to the deepstack container's API behavior.
I notice a bunch of errors in the Home Assistant log like this:
which seems to be coming from here https://github.com/robmarkcole/HASS-Deepstack-object/blob/017729ca61539978ac670e683075597ac094f97b/custom_components/deepstack_object/image_processing.py#L157
The error occurs when a response comes back from the coral-api.py server, and where there are no detections at all. The HTTP response is '200 OK', but there doesn't appear to be any 'prediction' key inserted into the response. That is only included in the response at https://github.com/robmarkcole/coral-pi-rest-server/blob/84d54ba69b5b909e7a27ec5cea0b36ab853095c6/coral-app.py#L77 if there's any predictions returned from the engine. It seems like the response would only have the
success
property asFalse
, but that's not checked for.So, I'm not sure what the right thing to do here might be, as I'm not sure what the deepstack API does. It looks like the block of code at https://github.com/robmarkcole/HASS-Deepstack-object/blob/017729ca61539978ac670e683075597ac094f97b/custom_components/deepstack_object/image_processing.py#L170-L172 really only takes effect if there no response... and it it safe to move that code up above as the default return value? Here's where my unfamiliarity with the Home Assistant internals fails me - should that state be modified or left as-is in an error condition?
I'm also not sure if it makes sense or is safe to return a null
predictions
array from the coral-api.py service? Again, this is also related to the deepstack container's API behavior.