mirror of
https://github.com/no2chem/wideq.git
synced 2025-05-16 07:10:09 -07:00
DeviceInfo decodes monitor status data
This commit is contained in:
parent
910e55d018
commit
5a5e8bf47d
@ -42,10 +42,7 @@ def mon(client, device_id):
|
||||
data = mon.poll()
|
||||
if data:
|
||||
try:
|
||||
if model.monitor_type == 1:
|
||||
res = model.decode_monitor_binary(data)
|
||||
else:
|
||||
res = mon.decode_json(data)
|
||||
res = model.decode_monitor(data)
|
||||
except ValueError:
|
||||
print('status data: {!r}'.format(data))
|
||||
else:
|
||||
|
13
wideq.py
13
wideq.py
@ -702,6 +702,19 @@ class ModelInfo(object):
|
||||
decoded[key] = str(value)
|
||||
return decoded
|
||||
|
||||
def decode_monitor_json(self, data):
|
||||
"""Decode a bytestring that encodes JSON status data."""
|
||||
|
||||
return json.loads(data.decode('utf8'))
|
||||
|
||||
def decode_monitor(self, data):
|
||||
"""Decode status data."""
|
||||
|
||||
if self.monitor_type == 1:
|
||||
return self.decode_monitor_binary(data)
|
||||
else:
|
||||
return self.decode_monitor_json(data)
|
||||
|
||||
class Device(object):
|
||||
"""A higher-level interface to a specific device.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user