forked from andrius/neohubapi
Add lock/unlock commands.
This commit is contained in:
parent
cbe9d0e418
commit
2415074907
35
neohub.py
35
neohub.py
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue