Kane610/deconz

json.decoder.JSONDecodeError: Unterminated string

Closed this issue · 8 comments

This error came up on my test system today. Running your deconz-component branch of HA (0.60.0.dev0). Currently I have a Tradfri motion sensor and Tradfri 5 button dimmer paired with the gateway through deCONZ. Not sure what provoked it (not sure if it was a motion event or button event, I can test more to reproduce if you think it’s relevant).

2017-12-08 16:46:57 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback _SelectorSocketTransport._read_ready()
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/events.py", line 126, in _run
    self._callback(*self._args)
  File "/usr/lib/python3.5/asyncio/selector_events.py", line 730, in _read_ready
    self._protocol.data_received(data)
  File "/opt/home-assistant/homeassistant/lib/python3.5/site-packages/pydeconz/websocket.py", line 96, in data_received
    payload, extra_data = self.get_payload(data)
  File "/opt/home-assistant/homeassistant/lib/python3.5/site-packages/pydeconz/websocket.py", line 122, in get_payload
    payload = json.loads(data[start:end].decode())
  File "/usr/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.5/json/decoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 38 (char 37)

Yes please. Add a print out of data if you can. Will have to add that debug print later on.

I can confirm it was neither a button event nor motion event that provoked it - at least, no amount of motion or buttons is making it happen again. I’ll turn on debug logging so if it happens again you have more to go on.

Great! A good thing is that even if it fails it, it will not break. That would have been a show stopper...

Just as an update, I haven’t seen this issue again in more than 24 hours of a lot of button pressing, motion events, and HA restarts.

If it doesn't bother you let's keep open for a couple of weeks. I'd prefer to catch stuff like this if possible. I'm not doing additions to the component unless necessary until merging. But I'll look into improved try catch and error messsges

Yes by all means - just wanted to post a status update. I will have this test system running 24/7 and will be gradually migrating my devices to it so hopefully if it happens again we will be able to trace it.

Hi @marthoc could it possibly have been that you had added a new device to deconz when you got this message? I got a similar error myself and it turns out that the payload calculations for web sockets where wrong. I've fixed it but it is not planned on going in to a hass release right now.

I am positive in the correctness in my previous comment so I'm closing this.