Add lock/unlock commands.

This commit is contained in:
Andrius Štikonas 2020-11-22 11:55:41 +00:00
parent cbe9d0e418
commit 2415074907
2 changed files with 43 additions and 0 deletions

View File

@ -344,3 +344,38 @@ class NeoHub:
result = await self._send(message)
return result
async def lock(self, pin: int, devices: [NeoStat]):
"""
PIN locks thermostats
PIN is a four digit number
"""
if pin < 0 or pin > 9999:
return False
pins = []
for x in range(4):
pins.append(pin % 10)
pin = pin // 10
pins.reverse()
names = [x.name for x in devices]
message = {"LOCK": [pins, names]}
reply = {"result": "locked"}
result = await self._send(message, reply)
return result
async def unlock(self, devices: [NeoStat]):
"""
Unlocks PIN locked thermostats
"""
names = [x.name for x in devices]
message = {"UNLOCK": names}
reply = {"result": "unlocked"}
result = await self._send(message, reply)
return result

View File

@ -63,3 +63,11 @@ class NeoStat:
result = await self._hub._send(message, reply)
return result
async def lock(self, pin: int):
result = await self._hub.lock(pin, [self])
return result
async def unlock(self):
result = await self._hub.unlock([self])
return result