Skip to content

Crash when 'entity_picture' is missing #3

@errrrata

Description

@errrrata

On my HASS, probably because of some cameras being offline, I get the following error:

 Unhandled Error
 Traceback (most recent call last):
   File "/usr/local/lib/python3.7/dist-packages/twisted/python/log.py", line 103, in callWithLogger
     return callWithContext({"system": lp}, func, *args, **kw)
   File "/usr/local/lib/python3.7/dist-packages/twisted/python/log.py", line 86, in callWithContext
     return context.call({ILogContext: newCtx}, func, *args, **kw)
   File "/usr/local/lib/python3.7/dist-packages/twisted/python/context.py", line 122, in callWithContext
     return self.currentContext().callWithContext(ctx, func, *args, **kw)
   File "/usr/local/lib/python3.7/dist-packages/twisted/python/context.py", line 85, in callWithContext
     return func(*args,**kw)
 --- <exception caught here> ---
   File "/usr/local/lib/python3.7/dist-packages/twisted/internet/_threadedselect.py", line 276, in _doReadOrWrite
     why = getattr(selectable, method)()
   File "/usr/local/lib/python3.7/dist-packages/twisted/internet/tcp.py", line 243, in doRead
     return self._dataReceived(data)
   File "/usr/local/lib/python3.7/dist-packages/twisted/internet/tcp.py", line 249, in _dataReceived
     rval = self.protocol.dataReceived(data)
   File "/usr/local/lib/python3.7/dist-packages/autobahn/twisted/websocket.py", line 290, in dataReceived
     self._dataReceived(data)
   File "/usr/local/lib/python3.7/dist-packages/autobahn/websocket/protocol.py", line 1206, in _dataReceived
     self.consumeData()
   File "/usr/local/lib/python3.7/dist-packages/autobahn/websocket/protocol.py", line 1218, in consumeData
     while self.processData() and self.state != WebSocketProtocol.STATE_CLOSED:
   File "/usr/local/lib/python3.7/dist-packages/autobahn/websocket/protocol.py", line 1578, in processData
     fr = self.onFrameEnd()
   File "/usr/local/lib/python3.7/dist-packages/autobahn/websocket/protocol.py", line 1703, in onFrameEnd
     self._onMessageEnd()
   File "/usr/local/lib/python3.7/dist-packages/autobahn/twisted/websocket.py", line 318, in _onMessageEnd
     self.onMessageEnd()
   File "/usr/local/lib/python3.7/dist-packages/autobahn/websocket/protocol.py", line 627, in onMessageEnd
     self._onMessage(payload, self.message_is_binary)
   File "/usr/local/lib/python3.7/dist-packages/autobahn/twisted/websocket.py", line 321, in _onMessage
     self.onMessage(payload, isBinary)
   File "/home/pi/homeassistant-gui/core/connectors/homeassistant.py", line 35, in onMessage
     self.factory.handler.handle_message(json.loads(payload.decode('utf8')))
   File "/home/pi/homeassistant-gui/core/connectors/homeassistant.py", line 84, in handle_message
     self.config['port']) + result['attributes']['entity_picture']
 builtins.KeyError: 'entity_picture'

Just adding an if 'entity_picture' in result['attributes'] seems to fix it, while still allowing 'working cameras' to be displayed

However (probably unrelated), the camera image doesn't seem to update on my SHPI.zero

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions