mjg59 / python-broadlink

Python module for controlling Broadlink RM2/3 (Pro) remote controls, A1 sensor platforms and SP2/3 smartplugs
MIT License
1.35k stars 477 forks source link

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xea #729

Open dev4i opened 1 year ago

dev4i commented 1 year ago

Getting this error occurring sometimes with the S3 Hub. It seems to resolve on it's own sometimes, but can also be resolved by rebooting the hub.

Error stack trace shows hub.py line 42 - return self._decode(response) and also hub.py line 82 - state = json.loads(payload[0x0C : 0x0C + js_len])

I couldn't figure out what was causing it, but there seems to be some of the JSON missing when i was printing 'payload' on line 80. See output below:

Payload: b'\xa5\xa5ZZ/\xcd\x03\x0b\x1f\x00\x00\x00\xea\x0e\xac\x91\x1d\x05\xf4K\xddV\x8c\x8d+\xda4,"lb_online1":0}\x00\x00\x00\x00\x00'

js_len: 31

A working example was as below:

Payload: b'\xa5\xa5ZZg\xd7\x03\x0bI\x00\x00\x00{"pwr1":0,"pwr2":0,"pwr3":0,"plugmode":0,"hb_timeout":180,"lb_online1":1}\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

js_len: 73