From d79f242c0fb5cec99769a8bb81096da0fb0f39ee Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sun, 18 Feb 2018 11:28:57 -0500 Subject: [PATCH] Set on/off --- wideq.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/wideq.py b/wideq.py index 0d6c33a..583bcb7 100644 --- a/wideq.py +++ b/wideq.py @@ -640,12 +640,24 @@ class ACDevice(object): def set_mode(self, mode): """Set the device's operating mode to an `OpMode` value. """ + mode_value = self.model.enum_value('OpMode', mode.value) self.client.session.set_device_controls( self.device.id, {'OpMode': mode_value}, ) + def set_on(self, is_on): + """Turn on or off the device (according to a boolean). + """ + + op = ACOp.RIGHT_ON if is_on else ACOp.OFF + op_value = self.model.enum_value('Operation', op.value) + self.client.session.set_device_controls( + self.device.id, + {'Operation': op_value}, + ) + def monitor_start(self): """Start monitoring the device's status."""