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

Add a method to lock/unlock the device

This commit is contained in:
Felipe Martins Diel 2020-06-16 18:19:18 -03:00 committed by Matthew Garrett
parent e9e14e82d2
commit e41d240942

View File

@ -244,9 +244,21 @@ class device:
def set_name(self, name): def set_name(self, name):
packet = bytearray(4) packet = bytearray(4)
packet.extend(map(ord, name)) packet += name.encode('utf-8')
packet += bytearray(0x50 - len(packet))
packet[0x43] = self.cloud
response = self.send_packet(0x6a, packet) response = self.send_packet(0x6a, packet)
check_error(response[0x22:0x24]) check_error(response[0x22:0x24])
self.name = name
def set_lock(self, state):
packet = bytearray(4)
packet += self.name.encode('utf-8')
packet += bytearray(0x50 - len(packet))
packet[0x43] = state
response = self.send_packet(0x6a, packet)
check_error(response[0x22:0x24])
self.cloud = bool(state)
def get_type(self): def get_type(self):
return self.type return self.type