diff --git a/PyViCare/PyViCareHeatPump.py b/PyViCare/PyViCareHeatPump.py index c5776a81..29a28333 100644 --- a/PyViCare/PyViCareHeatPump.py +++ b/PyViCare/PyViCareHeatPump.py @@ -152,29 +152,28 @@ def activateVentilationProgram(self, program): """ return self.service.setProperty(f"ventilation.operating.programs.{program}", "activate", {}) - @handleNotSupported - def getDomesticHotWaterHysteresis(self): - return self.service.getProperty("heating.dhw.temperature.hysteresis")["properties"]["value"]["value"] + def getDomesticHotWaterHysteresisUnit(self) -> str: + return str(self.service.getProperty("heating.dhw.temperature.hysteresis")["properties"]["value"]["unit"]) @handleNotSupported - def getDomesticHotWaterHysteresisMin(self): - return self.service.getProperty("heating.dhw.temperature.hysteresis")["commands"]["setHysteresis"]["params"]["hysteresis"]["constraints"]["min"] + def getDomesticHotWaterHysteresis(self) -> float: + return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["properties"]["value"]["value"]) @handleNotSupported - def getDomesticHotWaterHysteresisMax(self): - return self.service.getProperty("heating.dhw.temperature.hysteresis")["commands"]["setHysteresis"]["params"]["hysteresis"]["constraints"]["max"] + def getDomesticHotWaterHysteresisMin(self) -> float: + return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["commands"]["setHysteresis"]["params"]["hysteresis"]["constraints"]["min"]) @handleNotSupported - def getDomesticHotWaterHysteresisStepping(self): - return self.service.getProperty("heating.dhw.temperature.hysteresis")["commands"]["setHysteresis"]["params"]["hysteresis"]["constraints"]["stepping"] + def getDomesticHotWaterHysteresisMax(self) -> float: + return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["commands"]["setHysteresis"]["params"]["hysteresis"]["constraints"]["max"]) @handleNotSupported - def getDomesticHotWaterHysteresisUnit(self): - return self.service.getProperty("heating.dhw.temperature.hysteresis")["properties"]["value"]["unit"] + def getDomesticHotWaterHysteresisStepping(self) -> float: + return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["commands"]["setHysteresis"]["params"]["hysteresis"]["constraints"]["stepping"]) @handleAPICommandErrors - def setDomesticHotWaterHysteresis(self, temperature): + def setDomesticHotWaterHysteresis(self, temperature: float) -> Any: """ Set the hysteresis temperature for domestic host water Parameters ---------- @@ -186,15 +185,69 @@ def setDomesticHotWaterHysteresis(self, temperature): result: json json representation of the answer """ - return self.service.setProperty("heating.dhw.temperature.hysteresis", "setHysteresis", {'hysteresis': int(temperature)}) + 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 getDomesticHotWaterHysteresisSwitchOn(self): - return self.service.getProperty("heating.dhw.temperature.hysteresis")["properties"]["switchOnValue"]["value"] + 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): - return self.service.getProperty("heating.dhw.temperature.hysteresis")["properties"]["switchOffValue"]["value"] + 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): + 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): diff --git a/tests/test_Vitocal250A.py b/tests/test_Vitocal250A.py index 9c46ebb0..1d112a62 100644 --- a/tests/test_Vitocal250A.py +++ b/tests/test_Vitocal250A.py @@ -130,13 +130,63 @@ def test_getFrostProtectionActive(self): self.device.circuits[0].getFrostProtectionActive(), False) def test_getDomesticHotWaterHysteresis(self): - self.assertEqual( - self.device.getDomesticHotWaterHysteresis(), 5) 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})