diff --git a/README.md b/README.md index a92fb77ff..3de1fa92e 100644 --- a/README.md +++ b/README.md @@ -43,3 +43,8 @@ Obtain sensor data from an A1: ``` data = devices[0].check_sensors() ``` + +Set power state on an SP2/SP3 (0 for off, 1 for on): +``` +devices[0].set_power(1) +``` \ No newline at end of file diff --git a/broadlink/__init__.py b/broadlink/__init__.py index cd9d1599f..2f3966c47 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