Add NeoStat class.

This commit is contained in:
Andrius Štikonas 2020-11-22 00:59:22 +00:00
parent 5b590f577a
commit 7511b7b29e
3 changed files with 34 additions and 4 deletions

View File

@ -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

25
neostat.py Normal file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2020 Andrius Štikonas <andrius@stikonas.eu>
# 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

View File

@ -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)