about summary refs log tree commit diff
path: root/broadlink/__init__.py
diff options
context:
space:
mode:
authorMatthew Garrett <mjg59@coreos.com>2016-11-13T01·29+1300
committerMatthew Garrett <mjg59@coreos.com>2016-11-13T01·29+1300
commitc174e40f5903fdbc219ba09bc90256d83ebf1c22 (patch)
treeef3a1282e713cff93a0f51e57d7ef989e51ba6fe /broadlink/__init__.py
parent61efc7ae29b6ddb05e662a38941c1b1ed582131d (diff)
Add experimental support for smartplugs
This adds a set_power() call that should work for the SP2 - unsure whether
it will work for the SP3.
Diffstat (limited to 'broadlink/__init__.py')
-rwxr-xr-xbroadlink/__init__.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/broadlink/__init__.py b/broadlink/__init__.py
index cd9d1599f144..2f3966c4762f 100755
--- a/broadlink/__init__.py
+++ b/broadlink/__init__.py
@@ -180,6 +180,12 @@ class device:
     response = self.cs.recvfrom(1024)
     return response[0]
 
+  def set_power(self, state):
+    packet = bytearray(8)
+    packet[0] = 2
+    packet[4] = state
+    self.send_packet(0x6a, packet)
+
   def send_data(self, data):
     packet = bytearray([0x02, 0x00, 0x00, 0x00])
     packet += data