mirror of
https://github.com/no2chem/wideq.git
synced 2025-05-16 23:30:10 -07:00
try and catch JSONDecodeError
this is related to bug https://github.com/sampsyo/wideq/issues/64
This commit is contained in:
parent
d7440be7a0
commit
5e47dd0bb2
@ -432,7 +432,15 @@ class Device(object):
|
|||||||
self.device.id,
|
self.device.id,
|
||||||
key,
|
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):
|
def _get_control(self, key):
|
||||||
"""Look up a device's control value."""
|
"""Look up a device's control value."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user