Compare commits
5 Commits
ee252edc18
...
d811131f8a
Author | SHA1 | Date |
---|---|---|
Andrius Štikonas | d811131f8a | |
Roberto Cosenza | f8803a7b15 | |
Roberto Cosenza | dbda9b4157 | |
Andrius Štikonas | add4dfea10 | |
Roberto Cosenza | 43dbc27c0f |
|
@ -45,3 +45,10 @@ class Weekday(enum.Enum):
|
||||||
FRIDAY = "friday"
|
FRIDAY = "friday"
|
||||||
SATURDAY = "saturday"
|
SATURDAY = "saturday"
|
||||||
SUNDAY = "sunday"
|
SUNDAY = "sunday"
|
||||||
|
|
||||||
|
|
||||||
|
class HCMode(enum.Enum):
|
||||||
|
AUTO = "AUTO"
|
||||||
|
COOLING = "COOLING"
|
||||||
|
HEATING = "HEATING"
|
||||||
|
VENT = "VENT"
|
||||||
|
|
|
@ -10,6 +10,7 @@ import socket
|
||||||
from async_property import async_cached_property
|
from async_property import async_cached_property
|
||||||
from types import SimpleNamespace
|
from types import SimpleNamespace
|
||||||
|
|
||||||
|
from neohubapi.enums import HCMode
|
||||||
from neohubapi.enums import ScheduleFormat
|
from neohubapi.enums import ScheduleFormat
|
||||||
from neohubapi.enums import schedule_format_int_to_enum
|
from neohubapi.enums import schedule_format_int_to_enum
|
||||||
from neohubapi.neostat import NeoStat
|
from neohubapi.neostat import NeoStat
|
||||||
|
@ -84,6 +85,15 @@ class NeoHub:
|
||||||
raise(last_exception)
|
raise(last_exception)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def _devices_to_names(self, devices: [NeoStat]):
|
||||||
|
"""
|
||||||
|
Returns the list of device names
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
return [x.name for x in devices]
|
||||||
|
except (TypeError, AttributeError):
|
||||||
|
raise NeoHubUsageError('devices must be a list of NeoStat objects')
|
||||||
|
|
||||||
async def firmware(self):
|
async def firmware(self):
|
||||||
"""
|
"""
|
||||||
NeoHub firmware version
|
NeoHub firmware version
|
||||||
|
@ -164,6 +174,17 @@ class NeoHub:
|
||||||
result = await self._send(message, reply)
|
result = await self._send(message, reply)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
async def set_hc_mode(self, hc_mode: HCMode, devices: [NeoStat]):
|
||||||
|
"""
|
||||||
|
Set hc_mode to AUTO or...
|
||||||
|
"""
|
||||||
|
names = self._devices_to_names(devices)
|
||||||
|
message = {"SET_HC_MODE": [hc_mode.value, names]}
|
||||||
|
reply = {"result": "HC_MODE was set"}
|
||||||
|
|
||||||
|
result = await self._send(message, reply)
|
||||||
|
return result
|
||||||
|
|
||||||
async def set_format(self, sched_format: ScheduleFormat):
|
async def set_format(self, sched_format: ScheduleFormat):
|
||||||
"""
|
"""
|
||||||
Sets schedule format
|
Sets schedule format
|
||||||
|
@ -424,11 +445,7 @@ class NeoHub:
|
||||||
pin = pin // 10
|
pin = pin // 10
|
||||||
pins.reverse()
|
pins.reverse()
|
||||||
|
|
||||||
try:
|
names = self._devices_to_names(devices)
|
||||||
names = [x.name for x in devices]
|
|
||||||
except (TypeError, AttributeError):
|
|
||||||
raise NeoHubUsageError('devices must be a list of NeoStat objects')
|
|
||||||
|
|
||||||
message = {"LOCK": [pins, names]}
|
message = {"LOCK": [pins, names]}
|
||||||
reply = {"result": "locked"}
|
reply = {"result": "locked"}
|
||||||
|
|
||||||
|
@ -440,11 +457,7 @@ class NeoHub:
|
||||||
Unlocks PIN locked thermostats
|
Unlocks PIN locked thermostats
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
names = self._devices_to_names(devices)
|
||||||
names = [x.name for x in devices]
|
|
||||||
except (TypeError, AttributeError):
|
|
||||||
raise NeoHubUsageError('devices must be a list of NeoStat objects')
|
|
||||||
|
|
||||||
message = {"UNLOCK": names}
|
message = {"UNLOCK": names}
|
||||||
reply = {"result": "unlocked"}
|
reply = {"result": "unlocked"}
|
||||||
|
|
||||||
|
@ -456,17 +469,29 @@ class NeoHub:
|
||||||
Enables or disables Frost mode
|
Enables or disables Frost mode
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
names = self._devices_to_names(devices)
|
||||||
names = [x.name for x in devices]
|
|
||||||
except (TypeError, AttributeError):
|
|
||||||
raise NeoHubUsageError('devices must be a list of NeoStat objects')
|
|
||||||
|
|
||||||
message = {"FROST_ON" if state else "FROST_OFF": names}
|
message = {"FROST_ON" if state else "FROST_OFF": names}
|
||||||
reply = {"result": "frost on" if state else "frost off"}
|
reply = {"result": "frost on" if state else "frost off"}
|
||||||
|
|
||||||
result = await self._send(message, reply)
|
result = await self._send(message, reply)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
async def set_cool_temp(self, temperature: int, devices: [NeoStat]):
|
||||||
|
"""
|
||||||
|
Sets the thermostat's cooling temperature i.e. the temperature that will
|
||||||
|
trigger the thermostat if exceeded. Note that this is only supported on
|
||||||
|
the HC (Heating/Cooling) thermostats.
|
||||||
|
|
||||||
|
The temperature will be reset once next comfort level is reached
|
||||||
|
"""
|
||||||
|
|
||||||
|
names = self._devices_to_names(devices)
|
||||||
|
message = {"SET_COOL_TEMP": [temperature, names]}
|
||||||
|
reply = {"result": "temperature was set"}
|
||||||
|
|
||||||
|
result = await self._send(message, reply)
|
||||||
|
return result
|
||||||
|
|
||||||
async def set_target_temperature(self, temperature: int, devices: [NeoStat]):
|
async def set_target_temperature(self, temperature: int, devices: [NeoStat]):
|
||||||
"""
|
"""
|
||||||
Sets the thermostat's temperature
|
Sets the thermostat's temperature
|
||||||
|
@ -474,11 +499,7 @@ class NeoHub:
|
||||||
The temperature will be reset once next comfort level is reached
|
The temperature will be reset once next comfort level is reached
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
names = self._devices_to_names(devices)
|
||||||
names = [x.name for x in devices]
|
|
||||||
except (TypeError, AttributeError):
|
|
||||||
raise NeoHubUsageError('devices must be a list of NeoStat objects')
|
|
||||||
|
|
||||||
message = {"SET_TEMP": [temperature, names]}
|
message = {"SET_TEMP": [temperature, names]}
|
||||||
reply = {"result": "temperature was set"}
|
reply = {"result": "temperature was set"}
|
||||||
|
|
||||||
|
@ -496,11 +517,7 @@ class NeoHub:
|
||||||
3: 3 degrees
|
3: 3 degrees
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
names = self._devices_to_names(devices)
|
||||||
names = [x.name for x in devices]
|
|
||||||
except (TypeError, AttributeError):
|
|
||||||
raise NeoHubUsageError('devices must be a list of NeoStat objects')
|
|
||||||
|
|
||||||
message = {"SET_DIFF": [switching_differential, names]}
|
message = {"SET_DIFF": [switching_differential, names]}
|
||||||
reply = {"result": "switching differential was set"}
|
reply = {"result": "switching differential was set"}
|
||||||
|
|
||||||
|
@ -512,11 +529,7 @@ class NeoHub:
|
||||||
Returns time in minutes required to change temperature by 1 degree
|
Returns time in minutes required to change temperature by 1 degree
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
names = self._devices_to_names(devices)
|
||||||
names = [x.name for x in devices]
|
|
||||||
except (TypeError, AttributeError):
|
|
||||||
raise NeoHubUsageError('devices must be a list of NeoStat objects')
|
|
||||||
|
|
||||||
message = {"VIEW_ROC": names}
|
message = {"VIEW_ROC": names}
|
||||||
|
|
||||||
result = await self._send(message)
|
result = await self._send(message)
|
||||||
|
@ -530,11 +543,7 @@ class NeoHub:
|
||||||
NeoStats that are in timeclock mode.
|
NeoStats that are in timeclock mode.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
names = self._devices_to_names(devices)
|
||||||
names = [x.name for x in devices]
|
|
||||||
except (TypeError, AttributeError):
|
|
||||||
raise NeoHubUsageError('devices must be a list of NeoStat objects')
|
|
||||||
|
|
||||||
message = {"TIMER_ON" if state else "TIMER_OFF": names}
|
message = {"TIMER_ON" if state else "TIMER_OFF": names}
|
||||||
reply = {"result": "timers on" if state else "timers off"}
|
reply = {"result": "timers on" if state else "timers off"}
|
||||||
|
|
||||||
|
@ -548,11 +557,7 @@ class NeoHub:
|
||||||
This function works with NeoStats in timeclock mode
|
This function works with NeoStats in timeclock mode
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
names = self._devices_to_names(devices)
|
||||||
names = [x.name for x in devices]
|
|
||||||
except (TypeError, AttributeError):
|
|
||||||
raise NeoHubUsageError('devices must be a list of NeoStat objects')
|
|
||||||
|
|
||||||
message = {"TIMER_HOLD_ON" if state else "TIMER_HOLD_OFF": [minutes, names]}
|
message = {"TIMER_HOLD_ON" if state else "TIMER_HOLD_OFF": [minutes, names]}
|
||||||
reply = {"result": "timer hold on" if state else "timer hold off"}
|
reply = {"result": "timer hold on" if state else "timer hold off"}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ from types import SimpleNamespace
|
||||||
|
|
||||||
from async_property import async_property
|
from async_property import async_property
|
||||||
|
|
||||||
|
from neohubapi.enums import HCMode
|
||||||
from neohubapi.enums import Weekday
|
from neohubapi.enums import Weekday
|
||||||
|
|
||||||
|
|
||||||
|
@ -165,6 +166,14 @@ class NeoStat(SimpleNamespace):
|
||||||
result = await self._hub.set_target_temperature(temperature, [self])
|
result = await self._hub.set_target_temperature(temperature, [self])
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
async def set_hc_mode(self, hc_mode: HCMode):
|
||||||
|
result = await self._hub.set_hc_mode(hc_mode, [self])
|
||||||
|
return result
|
||||||
|
|
||||||
|
async def set_cool_temp(self, temperature: int):
|
||||||
|
result = await self._hub.set_cool_temp(temperature, [self])
|
||||||
|
return result
|
||||||
|
|
||||||
async def set_diff(self, switching_differential: int):
|
async def set_diff(self, switching_differential: int):
|
||||||
result = await self._hub.set_diff(switching_differential, [self])
|
result = await self._hub.set_diff(switching_differential, [self])
|
||||||
return result
|
return result
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -11,7 +11,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
|
||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name="neohubapi",
|
name="neohubapi",
|
||||||
version="0.7",
|
version="0.8",
|
||||||
description="Async library to communicate with Heatmiser NeoHub 2 API.",
|
description="Async library to communicate with Heatmiser NeoHub 2 API.",
|
||||||
url="https://gitlab.com/neohubapi/neohubapi/",
|
url="https://gitlab.com/neohubapi/neohubapi/",
|
||||||
author="Andrius Štikonas",
|
author="Andrius Štikonas",
|
||||||
|
|
Loading…
Reference in New Issue