1
0
mirror of https://github.com/mjg59/python-broadlink.git synced 2024-11-22 15:10:12 +01:00

support for dooya curtain motor (#134)

This commit is contained in:
Aleksandr Smirnov 2017-12-25 02:34:37 +02:00 committed by Matthew Garrett
parent 9ff6fa817b
commit 82172f54ab

View File

@ -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):