From fc9bc83b7383d3fe9806817ddcdb315b33bf6277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sat, 21 Nov 2020 18:08:25 +0000 Subject: [PATCH] Add DST commands. --- neohub.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/neohub.py b/neohub.py index 512ad98..2e19ac9 100644 --- a/neohub.py +++ b/neohub.py @@ -303,3 +303,34 @@ class NeoHub: if result: result = await self.set_time(date_time) return result + + + async def manual_dst(self, state: bool): + """ + Manually enables/disables daylight saving time + """ + + message = {"MANUAL_DST": int(state)} + reply = {"result": "Updated time"} + + result = await self._send(message, reply) + return result + + + async def set_dst(self, state: bool, region = None): + """ + Enables/disables automatic DST handling. + + By default it uses UK dates for turning DST on/off. + Available options for region are UK, EU, NZ. + """ + + message = {"DST_ON" if state else "DST_OFF": 0 if region is None else region} + reply = {"result": "dst on" if state else "dst off"} + + valid_timezones = ["UK", "EU", "NZ"] + if region not in valid_timezones: + return False + + result = await self._send(message, reply) + return result