From cbe9d0e41819ba2285d513affd76c263f2decd63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sun, 22 Nov 2020 11:13:24 +0000 Subject: [PATCH] Add permit_join and remove zone functions. --- neohub.py | 17 +++++++++++++++++ neostat.py | 16 ++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/neohub.py b/neohub.py index 1c82705..1daea91 100644 --- a/neohub.py +++ b/neohub.py @@ -327,3 +327,20 @@ class NeoHub: result = await self._send(message, reply) return result + + async def permit_join(self, name, timeout_s=120): + """ + Permit new thermostat to join network + + name: new zone will be added with this name + timeout: duration of discovery mode in seconds + + To actually join network you need to select 01 + from the thermostat's setup menu. + """ + + message = {"PERMIT_JOIN": [timeout_s, name]} + reply = {"result": "network allows joining"} + + result = await self._send(message) + return result diff --git a/neostat.py b/neostat.py index 8f47939..7fc0c6f 100644 --- a/neostat.py +++ b/neostat.py @@ -47,3 +47,19 @@ class NeoStat: if result: self.name = new_name return result + + async def remove(self): + """ + Removes this zone + + If successful, thermostat will be disconnected from the hub + Note that it takes a few seconds to remove thermostat + New get_zones call will still return the original list + during that period. + """ + + message = {"REMOVE_ZONE": self.name} + reply = {"result": "zone removed"} + + result = await self._hub._send(message, reply) + return result