Skip to content

Commit

Permalink
feat: expose Hysteresis data points (#392)
Browse files Browse the repository at this point in the history
* feat: expose hysteresis value data points (#19)

* update test data

* add hysteresis getter

* add setDomesticHotWaterHysteresis

* move to heat pump

* add test case

* update

* feat: expose Hysteresis data points (#25)

* update test data

* add hysteresis getter

* add setDomesticHotWaterHysteresis

* move to heat pump

* add test case

* update

* add switchOn switchOff temp setter

* add test cases

* add types

* fix type in setter

* add tes cases

* remove duplicate test case

* add missing type
  • Loading branch information
CFenner authored Sep 6, 2024
1 parent 950fd65 commit d601f3e
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 4 deletions.
104 changes: 101 additions & 3 deletions PyViCare/PyViCareHeatPump.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from PyViCare.PyViCareHeatingDevice import (HeatingDevice,
HeatingDeviceWithComponent)
from PyViCare.PyViCareUtils import PyViCareNotSupportedFeatureError, handleNotSupported
from PyViCare.PyViCareUtils import PyViCareNotSupportedFeatureError, handleAPICommandErrors, handleNotSupported


class HeatPump(HeatingDevice):
Expand Down Expand Up @@ -115,7 +115,7 @@ def setActiveVentilationMode(self, mode):
----------
mode : str
Valid mode can be obtained using getModes()
Returns
-------
result: json
Expand Down Expand Up @@ -144,14 +144,112 @@ def activateVentilationProgram(self, program):
Parameters
----------
program : str
Returns
-------
result: json
json representation of the answer
"""
return self.service.setProperty(f"ventilation.operating.programs.{program}", "activate", {})

@handleNotSupported
def getDomesticHotWaterHysteresisUnit(self) -> str:
return str(self.service.getProperty("heating.dhw.temperature.hysteresis")["properties"]["value"]["unit"])

@handleNotSupported
def getDomesticHotWaterHysteresis(self) -> float:
return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["properties"]["value"]["value"])

@handleNotSupported
def getDomesticHotWaterHysteresisMin(self) -> float:
return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["commands"]["setHysteresis"]["params"]["hysteresis"]["constraints"]["min"])

@handleNotSupported
def getDomesticHotWaterHysteresisMax(self) -> float:
return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["commands"]["setHysteresis"]["params"]["hysteresis"]["constraints"]["max"])

@handleNotSupported
def getDomesticHotWaterHysteresisStepping(self) -> float:
return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["commands"]["setHysteresis"]["params"]["hysteresis"]["constraints"]["stepping"])

@handleAPICommandErrors
def setDomesticHotWaterHysteresis(self, temperature: float) -> Any:
""" Set the hysteresis temperature for domestic host water
Parameters
----------
temperature : float
hysteresis temperature
Returns
-------
result: json
json representation of the answer
"""
return self.service.setProperty("heating.dhw.temperature.hysteresis", "setHysteresis", {'hysteresis': temperature})

@handleNotSupported
def getDomesticHotWaterHysteresisSwitchOn(self) -> float:
return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["properties"]["switchOnValue"]["value"])

@handleNotSupported
def getDomesticHotWaterHysteresisSwitchOnMin(self) -> float:
return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["commands"]["setHysteresisSwitchOnValue"]["params"]["hysteresis"]["constraints"]["min"])

@handleNotSupported
def getDomesticHotWaterHysteresisSwitchOnMax(self) -> float:
return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["commands"]["setHysteresisSwitchOnValue"]["params"]["hysteresis"]["constraints"]["max"])

@handleNotSupported
def getDomesticHotWaterHysteresisSwitchOnStepping(self) -> float:
return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["commands"]["setHysteresisSwitchOnValue"]["params"]["hysteresis"]["constraints"]["stepping"])

@handleAPICommandErrors
def setDomesticHotWaterHysteresisSwitchOn(self, temperature: float) -> Any:
""" Set the hysteresis switch on temperature for domestic host water
Parameters
----------
temperature : float
hysteresis switch on temperature
Returns
-------
result: json
json representation of the answer
"""
return self.service.setProperty("heating.dhw.temperature.hysteresis", "setHysteresisSwitchOnValue", {'hysteresis': temperature})

@handleNotSupported
def getDomesticHotWaterHysteresisSwitchOff(self) -> float:
return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["properties"]["switchOffValue"]["value"])

@handleNotSupported
def getDomesticHotWaterHysteresisSwitchOffMin(self) -> float:
return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["commands"]["setHysteresisSwitchOffValue"]["params"]["hysteresis"]["constraints"]["min"])

@handleNotSupported
def getDomesticHotWaterHysteresisSwitchOffMax(self) -> float:
return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["commands"]["setHysteresisSwitchOffValue"]["params"]["hysteresis"]["constraints"]["max"])

@handleNotSupported
def getDomesticHotWaterHysteresisSwitchOffStepping(self) -> float:
return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["commands"]["setHysteresisSwitchOffValue"]["params"]["hysteresis"]["constraints"]["stepping"])

@handleAPICommandErrors
def setDomesticHotWaterHysteresisSwitchOff(self, temperature: float) -> Any:
""" Set the hysteresis switch off temperature for domestic host water
Parameters
----------
temperature : float
hysteresis switch off temperature
Returns
-------
result: json
json representation of the answer
"""
return self.service.setProperty("heating.dhw.temperature.hysteresis", "setHysteresisSwitchOffValue", {'hysteresis': temperature})


class Compressor(HeatingDeviceWithComponent):

@property
Expand Down
1 change: 0 additions & 1 deletion tests/test_TestForMissingProperties.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def test_missingProperties(self):
'heating.power.consumption',

'heating.circuits.0.temperature.levels', # hint: command
'heating.dhw.temperature.hysteresis', # hint: command
'heating.dhw.hygiene',
'heating.dhw.temperature',
'heating.burners',
Expand Down
62 changes: 62 additions & 0 deletions tests/test_Vitocal250A.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,65 @@ def test_getPowerSummaryConsumptionDomesticHotWaterLastYear(self):
def test_getCompressorPhase(self):
self.assertEqual(
self.device.getCompressor(0).getPhase(), "ready")

def test_getDomesticHotWaterHysteresis(self):
self.assertEqual(
self.device.getDomesticHotWaterHysteresisUnit(), 'kelvin')
self.assertEqual(
self.device.getDomesticHotWaterHysteresis(), 5)
self.assertEqual(
self.device.getDomesticHotWaterHysteresisMin(), 1)
self.assertEqual(
self.device.getDomesticHotWaterHysteresisMax(), 10)
self.assertEqual(
self.device.getDomesticHotWaterHysteresisStepping(), 0.5)

def test_getDomesticHotWaterHysteresisSwitchOn(self):
self.assertEqual(
self.device.getDomesticHotWaterHysteresisSwitchOn(), 5)
self.assertEqual(
self.device.getDomesticHotWaterHysteresisSwitchOnMin(), 1)
self.assertEqual(
self.device.getDomesticHotWaterHysteresisSwitchOnMax(), 10)
self.assertEqual(
self.device.getDomesticHotWaterHysteresisSwitchOnStepping(), 0.5)

def test_getDomesticHotWaterHysteresisSwitchOff(self):
self.assertEqual(
self.device.getDomesticHotWaterHysteresisSwitchOff(), 0)
self.assertEqual(
self.device.getDomesticHotWaterHysteresisSwitchOffMin(), 0)
self.assertEqual(
self.device.getDomesticHotWaterHysteresisSwitchOffMax(), 2.5)
self.assertEqual(
self.device.getDomesticHotWaterHysteresisSwitchOffStepping(), 0.5)

def test_setDomesticHotWaterHysteresis(self):
self.device.setDomesticHotWaterHysteresis(5)
self.assertEqual(len(self.service.setPropertyData), 1)
self.assertEqual(
self.service.setPropertyData[0]['property_name'], 'heating.dhw.temperature.hysteresis')
self.assertEqual(
self.service.setPropertyData[0]['action'], 'setHysteresis')
self.assertEqual(self.service.setPropertyData[0]['data'], {
'hysteresis': 5})

def test_setDomesticHotWaterHysteresisSwitchOn(self):
self.device.setDomesticHotWaterHysteresisSwitchOn(5)
self.assertEqual(len(self.service.setPropertyData), 1)
self.assertEqual(
self.service.setPropertyData[0]['property_name'], 'heating.dhw.temperature.hysteresis')
self.assertEqual(
self.service.setPropertyData[0]['action'], 'setHysteresisSwitchOnValue')
self.assertEqual(self.service.setPropertyData[0]['data'], {
'hysteresis': 5})

def test_setDomesticHotWaterHysteresisSwitchOff(self):
self.device.setDomesticHotWaterHysteresisSwitchOff(5)
self.assertEqual(len(self.service.setPropertyData), 1)
self.assertEqual(
self.service.setPropertyData[0]['property_name'], 'heating.dhw.temperature.hysteresis')
self.assertEqual(
self.service.setPropertyData[0]['action'], 'setHysteresisSwitchOffValue')
self.assertEqual(self.service.setPropertyData[0]['data'], {
'hysteresis': 5})

0 comments on commit d601f3e

Please sign in to comment.