1
0
mirror of https://github.com/no2chem/wideq.git synced 2025-05-16 07:10:09 -07:00

try and catch JSONDecodeError

this is related to bug https://github.com/sampsyo/wideq/issues/64
This commit is contained in:
pifou 2020-10-12 23:06:22 +02:00
parent d7440be7a0
commit 5e47dd0bb2

View File

@ -432,7 +432,15 @@ class Device(object):
self.device.id,
key,
)
return json.loads(base64.b64decode(data).decode('utf8'))
data = base64.b64decode(data).decode('utf8')
try:
return json.loads(data)
except json.decoder.JSONDecodeError:
LOGGER.warning(
'JSONDecodeError malformed json (%s)', data)
# Added fix to correct malformed JSON!
# see https://github.com/sampsyo/wideq/issues/64
return json.loads(data.replace('{[', '[').replace(']}', ']'))
def _get_control(self, key):
"""Look up a device's control value."""