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

Move base64/JSON assumption to config method

The "Control" settings seem to use other encodings?
This commit is contained in:
Adrian Sampson 2018-04-21 14:56:41 -04:00
parent 597895b263
commit 426043397d

View File

@ -372,8 +372,7 @@ class Session(object):
'workId': gen_uuid(), 'workId': gen_uuid(),
'data': '', 'data': '',
}) })
data = base64.b64decode(res['returnData']) return res['returnData']
return json.loads(data.decode('utf8'))
class Monitor(object): class Monitor(object):
@ -709,11 +708,24 @@ class Device(object):
def _get_config(self, key): def _get_config(self, key):
"""Look up a device's configuration for a given value. """Look up a device's configuration for a given value.
The response is parsed as base64-encoded JSON.
"""
data = self.client.session.get_device_config(
self.device.id,
key,
)
return json.loads(base64.b64decode(data).decode('utf8'))
def _get_control(self, key):
"""Look up a device's control value.
""" """
return self.client.session.get_device_config( return self.client.session.get_device_config(
self.device.id, self.device.id,
key, key,
'Control',
) )