forked from andrius/neohubapi
Parse GET_LIVE_DATA fields.
This commit is contained in:
parent
87c9516172
commit
e099fe4741
13
enums.py
13
enums.py
|
@ -6,7 +6,7 @@
|
||||||
import enum
|
import enum
|
||||||
|
|
||||||
|
|
||||||
class ScheduleFormat(str, enum.Enum):
|
class ScheduleFormat(enum.Enum):
|
||||||
"""
|
"""
|
||||||
Enum to specify Schedule Format
|
Enum to specify Schedule Format
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ class ScheduleFormat(str, enum.Enum):
|
||||||
TWO = "5DAY/2DAY"
|
TWO = "5DAY/2DAY"
|
||||||
SEVEN = "7DAY"
|
SEVEN = "7DAY"
|
||||||
|
|
||||||
|
|
||||||
def schedule_format_int_to_enum(int_format):
|
def schedule_format_int_to_enum(int_format):
|
||||||
if int_format == 0:
|
if int_format == 0:
|
||||||
return ScheduleFormat.ZERO
|
return ScheduleFormat.ZERO
|
||||||
|
@ -32,3 +33,13 @@ def schedule_format_int_to_enum(int_format):
|
||||||
return ScheduleFormat.SEVEN
|
return ScheduleFormat.SEVEN
|
||||||
else:
|
else:
|
||||||
raise ValueError('Unrecognized ScheduleFormat')
|
raise ValueError('Unrecognized ScheduleFormat')
|
||||||
|
|
||||||
|
|
||||||
|
class Weekday(enum.Enum):
|
||||||
|
MONDAY = "monday"
|
||||||
|
TUESDAY = "tuesday"
|
||||||
|
WEDNESDAY = "wednesday"
|
||||||
|
THURSDAY = "thursday"
|
||||||
|
FRIDAY = "friday"
|
||||||
|
SATURDAY = "saturday"
|
||||||
|
SUNDAY = "sunday"
|
||||||
|
|
|
@ -364,7 +364,7 @@ class NeoHub:
|
||||||
result = await self._send(message)
|
result = await self._send(message)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
async def lock(self, pin: int, devices: [NeoStat]):
|
async def set_lock(self, pin: int, devices: [NeoStat]):
|
||||||
"""
|
"""
|
||||||
PIN locks thermostats
|
PIN locks thermostats
|
||||||
|
|
||||||
|
@ -399,7 +399,7 @@ class NeoHub:
|
||||||
result = await self._send(message, reply)
|
result = await self._send(message, reply)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
async def frost(self, state: bool, devices: [NeoStat]):
|
async def set_frost(self, state: bool, devices: [NeoStat]):
|
||||||
"""
|
"""
|
||||||
Enables or disables Frost mode
|
Enables or disables Frost mode
|
||||||
"""
|
"""
|
||||||
|
|
65
neostat.py
65
neostat.py
|
@ -3,8 +3,12 @@
|
||||||
# SPDX-FileCopyrightText: 2020 Andrius Štikonas <andrius@stikonas.eu>
|
# SPDX-FileCopyrightText: 2020 Andrius Štikonas <andrius@stikonas.eu>
|
||||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
from types import SimpleNamespace
|
from types import SimpleNamespace
|
||||||
|
|
||||||
|
from enums import Weekday
|
||||||
|
|
||||||
|
|
||||||
class NeoStat(SimpleNamespace):
|
class NeoStat(SimpleNamespace):
|
||||||
"""
|
"""
|
||||||
|
@ -15,17 +19,50 @@ class NeoStat(SimpleNamespace):
|
||||||
self._data_ = thermostat
|
self._data_ = thermostat
|
||||||
self._hub = hub
|
self._hub = hub
|
||||||
|
|
||||||
@property
|
self.active_level = self._data_.ACTIVE_LEVEL
|
||||||
def name(self):
|
self.active_profile = self._data_.ACTIVE_PROFILE
|
||||||
""" Zone name. """
|
self.available_modes = self._data_.AVAILABLE_MODES
|
||||||
|
self.away = self._data_.AWAY
|
||||||
return self._data_.ZONE_NAME
|
self.cool_on = self._data_.COOL_ON
|
||||||
|
self.cool_temp = self._data_.COOL_TEMP
|
||||||
@property
|
self.current_floor_temperature = self._data_.CURRENT_FLOOR_TEMPERATURE
|
||||||
def temperature(self):
|
self.weekday = Weekday(self._data_.DATE)
|
||||||
""" Actual zone temperature. """
|
self.device_id = self._data_.DEVICE_ID
|
||||||
|
self.fan_control = self._data_.FAN_CONTROL
|
||||||
return self._data_.ACTUAL_TEMP
|
self.fan_speed = self._data_.FAN_SPEED
|
||||||
|
self.floor_limit = self._data_.ZONE_NAME
|
||||||
|
self.hc_mode = self._data_.HC_MODE
|
||||||
|
self.heat_mode = self._data_.HEAT_MODE
|
||||||
|
self.heat_on = self._data_.HEAT_ON
|
||||||
|
self.hold_cool = self._data_.HOLD_COOL
|
||||||
|
self.hold_off = self._data_.HOLD_OFF
|
||||||
|
self.hold_on = self._data_.HOLD_ON
|
||||||
|
self.hold_temp = self._data_.HOLD_TEMP
|
||||||
|
_hold_time = datetime.strptime(self._data_.HOLD_TIME, "%H:%M")
|
||||||
|
self.hold_time = timedelta(hours=_hold_time.hour, minutes=_hold_time.minute)
|
||||||
|
self.holiday = self._data_.HOLIDAY
|
||||||
|
self.lock = self._data_.LOCK
|
||||||
|
self.low_battery = self._data_.LOW_BATTERY
|
||||||
|
self.manual_off = self._data_.MANUAL_OFF
|
||||||
|
self.modelock = self._data_.MODELOCK
|
||||||
|
self.modulation_level = self._data_.MODULATION_LEVEL
|
||||||
|
self.name = self._data_.ZONE_NAME
|
||||||
|
self.offline = self._data_.OFFLINE
|
||||||
|
self.pin_number = int(self._data_.PIN_NUMBER)
|
||||||
|
self.preheat_active = int(self._data_.PREHEAT_ACTIVE)
|
||||||
|
self.prg_temp = self._data_.PRG_TEMP
|
||||||
|
self.prg_timer = self._data_.PRG_TIMER
|
||||||
|
self.set_temp = self._data_.SET_TEMP # target temperature
|
||||||
|
self.standby = self._data_.STANDBY
|
||||||
|
_switch_delay_left = datetime.strptime(self._data_.SWITCH_DELAY_LEFT, "%H:%M")
|
||||||
|
self.switch_delay_left = timedelta(hours=_switch_delay_left.hour, minutes=_switch_delay_left.minute)
|
||||||
|
self.temporary_set_flag = self._data_.TEMPORARY_SET_FLAG
|
||||||
|
self.temperature = self._data_.ACTUAL_TEMP
|
||||||
|
_time = datetime.strptime(self._data_.TIME, "%H:%M")
|
||||||
|
self.time = timedelta(hours=_time.hour, minutes=_time.minute)
|
||||||
|
self.timer_on = self._data_.TIMER_ON
|
||||||
|
self.window_open = self._data_.WINDOW_OPEN
|
||||||
|
self.write_count = self._data_.WRITE_COUNT
|
||||||
|
|
||||||
async def identify(self):
|
async def identify(self):
|
||||||
"""
|
"""
|
||||||
|
@ -65,15 +102,15 @@ class NeoStat(SimpleNamespace):
|
||||||
result = await self._hub._send(message, reply)
|
result = await self._hub._send(message, reply)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
async def lock(self, pin: int):
|
async def set_lock(self, pin: int):
|
||||||
result = await self._hub.lock(pin, [self])
|
result = await self._hub.set_lock(pin, [self])
|
||||||
return result
|
return result
|
||||||
|
|
||||||
async def unlock(self):
|
async def unlock(self):
|
||||||
result = await self._hub.unlock([self])
|
result = await self._hub.unlock([self])
|
||||||
return result
|
return result
|
||||||
|
|
||||||
async def frost(self, state: bool):
|
async def set_frost(self, state: bool):
|
||||||
result = await self._hub.frost(state, [self])
|
result = await self._hub.frost(state, [self])
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
2
test.py
2
test.py
|
@ -19,7 +19,7 @@ async def run():
|
||||||
hub_data, thermostats = await hub.get_live_data()
|
hub_data, thermostats = await hub.get_live_data()
|
||||||
for device in thermostats:
|
for device in thermostats:
|
||||||
print(f"Temperature in zone {device.name}: {device.temperature}")
|
print(f"Temperature in zone {device.name}: {device.temperature}")
|
||||||
#await device.identify()
|
await device.identify()
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
Loading…
Reference in New Issue