diff options
author | Aleksandr Smirnov <alex@sander.ee> | 2017-12-25T00·34+0200 |
---|---|---|
committer | Matthew Garrett <mjg59-github@srcf.ucam.org> | 2017-12-25T00·34+0000 |
commit | 82172f54ab722fb9de998d0ae4c24337e41d5787 (patch) | |
tree | 5a0ae3b063a0e4a5a82e4178d2200b961e1d84d4 /broadlink/__init__.py | |
parent | 9ff6fa817b6d4314fcc9b805e480290f3a1ba20e (diff) |
support for dooya curtain motor (#134)
Diffstat (limited to 'broadlink/__init__.py')
-rw-r--r-- | broadlink/__init__.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/broadlink/__init__.py b/broadlink/__init__.py index ea4cbc5fab34..dbabce0b3494 100644 --- a/broadlink/__init__.py +++ b/broadlink/__init__.py @@ -58,6 +58,8 @@ def gendevice(devtype, host, mac): return mp1(host=host, mac=mac) elif devtype == 0x2722: # S1 (SmartOne Alarm Kit) return S1C(host=host, mac=mac) + elif devtype == 0x4E4D: # Dooya DT360E (DOOYA_CURTAIN_V2) + return dooya(host=host, mac=mac) else: return device(host=host, mac=mac) @@ -581,6 +583,52 @@ class S1C(device): return result +class dooya(device): + def __init__ (self, host, mac): + device.__init__(self, host, mac) + self.type = "Dooya DT360E" + + def _send(self, magic1, magic2): + packet = bytearray(16) + packet[0] = 0x09 + packet[2] = 0xbb + packet[3] = magic1 + packet[4] = magic2 + packet[9] = 0xfa + packet[10] = 0x44 + response = self.send_packet(0x6a, packet) + err = response[0x22] | (response[0x23] << 8) + if err == 0: + payload = self.decrypt(bytes(response[0x38:])) + return ord(payload[4]) + + def open(self): + return self._send(0x01, 0x00) + + def close(self): + return self._send(0x02, 0x00) + + def stop(self): + return self._send(0x03, 0x00) + + def get_percentage(self): + return self._send(0x06, 0x5d) + + def set_percentage_and_wait(self, new_percentage): + current = self.get_percentage() + if current > new_percentage: + self.close() + while current is not None and current > new_percentage: + time.sleep(0.2) + current = self.get_percentage() + + elif current < new_percentage: + self.open() + while current is not None and current < new_percentage: + time.sleep(0.2) + current = self.get_percentage() + self.stop() + # Setup a new Broadlink device via AP Mode. Review the README to see how to enter AP Mode. # Only tested with Broadlink RM3 Mini (Blackbean) def setup(ssid, password, security_mode): |