From 426043397db4c07e110b8a617e459634b0736089 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sat, 21 Apr 2018 14:56:41 -0400 Subject: [PATCH] Move base64/JSON assumption to config method The "Control" settings seem to use other encodings? --- wideq.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/wideq.py b/wideq.py index fe527f2..8ff5d24 100644 --- a/wideq.py +++ b/wideq.py @@ -372,8 +372,7 @@ class Session(object): 'workId': gen_uuid(), 'data': '', }) - data = base64.b64decode(res['returnData']) - return json.loads(data.decode('utf8')) + return res['returnData'] class Monitor(object): @@ -709,11 +708,24 @@ class Device(object): def _get_config(self, key): """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( self.device.id, key, + 'Control', )