diff --git a/neohub.py b/neohub.py index dcda4ef..dbc89ce 100644 --- a/neohub.py +++ b/neohub.py @@ -9,6 +9,7 @@ import logging from enums import ScheduleFormat from system import System from holiday import Holiday +from neostat import NeoStat class NeoHub: @@ -197,14 +198,18 @@ class NeoHub: async def get_zones(self): """ - Returns list of zones and their ids + Get list of all thermostats - {"zone1": 1} + Returns a list of NeoStat objects """ message = {"GET_ZONES": 0} - result = await self._send(message) + zones = await self._send(message) + result = [] + for name,zone_id in zones.items(): + result.append(NeoStat(name, zone_id)) + return result diff --git a/neostat.py b/neostat.py new file mode 100644 index 0000000..206f22d --- /dev/null +++ b/neostat.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 + +# SPDX-FileCopyrightText: 2020 Andrius Štikonas +# SPDX-License-Identifier: LGPL-3.0-or-later + + +class NeoStat: + """ + Class representing NeoStat theormostat + """ + + def __init__(self, name: str, zone_id: int): + self._name = name + self._zone_id = zone_id + + @property + def name(self): + """ Zone name. """ + return self._name + + + @property + def zone_id(self): + """ End of holiday. """ + return self._zone_id diff --git a/test.py b/test.py index a230e9f..a9a90d5 100755 --- a/test.py +++ b/test.py @@ -15,7 +15,7 @@ async def run(): hub = neohub.NeoHub() await hub.connect() system = await hub.get_system() - result = await hub.identify() + result = await hub.get_zones() print(result)