mirror of
https://github.com/no2chem/wideq.git
synced 2025-05-16 07:10:09 -07:00
Start controlling settings
This commit is contained in:
parent
244f4756c5
commit
c9afb9035c
@ -108,6 +108,12 @@ def example(args):
|
||||
print('setting: {}°C'.format(res['TempCfg']))
|
||||
print('current: {}°C'.format(res['TempCur']))
|
||||
|
||||
elif args[0] == 'set-temp':
|
||||
temp = args[1]
|
||||
device_id = args[2]
|
||||
|
||||
session.set_device_control(device_id, 'TempCfg', temp)
|
||||
|
||||
except wideq.NotLoggedInError:
|
||||
print('Session expired.')
|
||||
return
|
||||
|
20
wideq.py
20
wideq.py
@ -15,6 +15,10 @@ SVC_CODE = 'SVC202'
|
||||
CLIENT_ID = 'LGAO221A02'
|
||||
|
||||
|
||||
def gen_uuid():
|
||||
return str(uuid.uuid4())
|
||||
|
||||
|
||||
class APIError(Exception):
|
||||
"""An error reported by the API."""
|
||||
|
||||
@ -194,12 +198,11 @@ class Session(object):
|
||||
monitoring.
|
||||
"""
|
||||
|
||||
input_work_id = str(uuid.uuid4()) # Why is this necessary?
|
||||
res = self.post('rti/rtiMon', {
|
||||
'cmd': 'Mon',
|
||||
'cmdOpt': 'Start',
|
||||
'deviceId': device_id,
|
||||
'workId': input_work_id,
|
||||
'workId': gen_uuid(),
|
||||
})
|
||||
return res['workId']
|
||||
|
||||
@ -229,6 +232,19 @@ class Session(object):
|
||||
'workId': work_id,
|
||||
})
|
||||
|
||||
def set_device_control(self, device_id, key, value):
|
||||
"""Control a device's settings."""
|
||||
|
||||
res = self.post('rti/rtiControl', {
|
||||
'cmd': 'Control',
|
||||
'cmdOpt': key,
|
||||
'value': value,
|
||||
'deviceId': device_id,
|
||||
'workId': gen_uuid(),
|
||||
'data': '',
|
||||
})
|
||||
print(res)
|
||||
|
||||
|
||||
class Monitor(object):
|
||||
"""A monitoring task for a device."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user