From 0a48345409f5cfb34eabf34b8f39eaf757e2b1e7 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sat, 21 Apr 2018 15:14:10 -0400 Subject: [PATCH] Get speaker volume setting Still can't figure out how to *set* the light state. --- example.py | 1 + wideq.py | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/example.py b/example.py index 112beb7..cc26b93 100644 --- a/example.py +++ b/example.py @@ -119,6 +119,7 @@ def ac_config(client, device_id): print(ac.get_filter_state()) print(ac.get_mfilter_state()) print(ac.get_energy_target()) + print(ac.get_volume()) print(ac.get_light()) diff --git a/wideq.py b/wideq.py index 0440b5c..62bf328 100644 --- a/wideq.py +++ b/wideq.py @@ -348,7 +348,7 @@ class Session(object): `values` is a key/value map containing the settings to update. """ - self.post('rti/rtiControl', { + return self.post('rti/rtiControl', { 'cmd': 'Control', 'cmdOpt': 'Set', 'value': values, @@ -722,12 +722,16 @@ class Device(object): """Look up a device's control value. """ - return self.client.session.get_device_config( + data = self.client.session.get_device_config( self.device.id, key, 'Control', ) + # The response comes in a funky key/value format: "(key:value)". + _, value = data[1:-1].split(':') + return value + class ACMode(enum.Enum): """The operation mode for an AC/HVAC device.""" @@ -837,7 +841,13 @@ class ACDevice(Device): """Get a Boolean indicating whether the display light is on.""" value = self._get_control('DisplayControl') - return value == '(DisplayControl:0)' + return value == '0' # Seems backwards, but isn't. + + def get_volume(self): + """Get the speaker volume level.""" + + value = self._get_control('SpkVolume') + return int(value) def monitor_start(self): """Start monitoring the device's status."""