From 87896d5003d0fcb27fda45885b41761142d67df1 Mon Sep 17 00:00:00 2001 From: Christopher Fenner Date: Mon, 23 Dec 2024 21:58:07 +0100 Subject: [PATCH] use features --- PyViCare/PyViCareHeatPump.py | 12 +++++++++--- PyViCare/PyViCareVentilationDevice.py | 9 ++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/PyViCare/PyViCareHeatPump.py b/PyViCare/PyViCareHeatPump.py index 800b4758..54747e2c 100644 --- a/PyViCare/PyViCareHeatPump.py +++ b/PyViCare/PyViCareHeatPump.py @@ -1,12 +1,15 @@ from contextlib import suppress from typing import Any, List -from PyViCare.PyViCareHeatingDevice import (HeatingDevice, - HeatingDeviceWithComponent) +from PyViCare.Features.FeatureVentilationModePermanent import FeatureVentilationModePermanent +from PyViCare.Features.FeatureVentilationModes import FeatureVentilationModes +from PyViCare.Features.FeatureVentilationQuickmodes import FeatureVentilationQuickmodes +from PyViCare.Features.FeatureVentilationState import FeatureVentilationState +from PyViCare.PyViCareHeatingDevice import HeatingDevice, HeatingDeviceWithComponent from PyViCare.PyViCareUtils import PyViCareNotSupportedFeatureError, handleAPICommandErrors, handleNotSupported -class HeatPump(HeatingDevice): +class HeatPump(FeatureVentilationModePermanent, FeatureVentilationModes, FeatureVentilationQuickmodes, FeatureVentilationState, HeatingDevice): @property def compressors(self) -> List[Any]: @@ -118,14 +121,17 @@ def getPowerSummaryConsumptionDomesticHotWaterLastYear(self): def getVolumetricFlowReturn(self): return self.service.getProperty("heating.sensors.volumetricFlow.allengra")["properties"]['value']['value'] + #TODO: deprecate, use getVentilationModes @handleNotSupported def getAvailableVentilationModes(self): return self.service.getProperty("ventilation.operating.modes.active")["commands"]["setMode"]["params"]["mode"]["constraints"]["enum"] + #TODO: deprecate, use getActiveVentilationMode @handleNotSupported def getActiveVentilationMode(self): return self.service.getProperty("ventilation.operating.modes.active")["properties"]["value"]["value"] + #TODO: deprecate, use activateVentilationMode def setActiveVentilationMode(self, mode): """ Set the active mode Parameters diff --git a/PyViCare/PyViCareVentilationDevice.py b/PyViCare/PyViCareVentilationDevice.py index 123e289a..16fae89e 100644 --- a/PyViCare/PyViCareVentilationDevice.py +++ b/PyViCare/PyViCareVentilationDevice.py @@ -1,27 +1,32 @@ from contextlib import suppress +from PyViCare.Features.FeatureVentilationModePermanent import FeatureVentilationModePermanent +from PyViCare.Features.FeatureVentilationModes import FeatureVentilationModes from PyViCare.Features.FeatureVentilationQuickmodes import FeatureVentilationQuickmodes from PyViCare.Features.FeatureVentilationState import FeatureVentilationState from PyViCare.PyViCareDevice import Device from PyViCare.PyViCareUtils import (PyViCareNotSupportedFeatureError, handleAPICommandErrors, handleNotSupported) -class VentilationDevice(FeatureVentilationQuickmodes, FeatureVentilationState, Device): +class VentilationDevice(FeatureVentilationModePermanent, FeatureVentilationModes, FeatureVentilationQuickmodes, FeatureVentilationState, Device): """This is the base class for all ventilation devices. This class connects to the Viessmann ViCare API. The authentication is done through OAuth2. Note that currently, a new token is generated for each run. """ + #TODO: deprecate, use getVentilationModes @handleNotSupported def getAvailableModes(self): return self.service.getProperty("ventilation.operating.modes.active")["commands"]["setMode"]["params"]["mode"]["constraints"]["enum"] + #TODO: deprecate, use getActiveVentilationMode @handleNotSupported def getActiveMode(self): return self.service.getProperty("ventilation.operating.modes.active")["properties"]["value"]["value"] + #TODO: deprecate, use activateVentilationMode def setActiveMode(self, mode): """ Set the active mode Parameters @@ -77,10 +82,12 @@ def deactivateProgram(self, program): """ return self.service.setProperty(f"ventilation.operating.programs.{program}", "deactivate", {}) + #TODO: deprecate, use getVentilationModePermanentLevels @handleNotSupported def getPermanentLevels(self) -> list[str]: return list[str](self.service.getProperty("ventilation.operating.modes.permanent")["commands"]["setLevel"]["params"]["level"]["constraints"]["enum"]) + #TODO: deprecate, use setVentilationModePermanentLevel @handleAPICommandErrors def setPermanentLevel(self, level: str): return self.service.setProperty("ventilation.operating.modes.permanent", "setLevel", {'level': level})