Skip to content

Commit

Permalink
use features
Browse files Browse the repository at this point in the history
  • Loading branch information
CFenner committed Dec 23, 2024
1 parent 8f2875a commit 87896d5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
12 changes: 9 additions & 3 deletions PyViCare/PyViCareHeatPump.py
Original file line number Diff line number Diff line change
@@ -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]:
Expand Down Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion PyViCare/PyViCareVentilationDevice.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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})
Expand Down

0 comments on commit 87896d5

Please sign in to comment.