Skip to content

Commit d601f3e

Browse files
authored
feat: expose Hysteresis data points (#392)
* 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
1 parent 950fd65 commit d601f3e

3 files changed

Lines changed: 163 additions & 4 deletions

File tree

PyViCare/PyViCareHeatPump.py

Lines changed: 101 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from PyViCare.PyViCareHeatingDevice import (HeatingDevice,
55
HeatingDeviceWithComponent)
6-
from PyViCare.PyViCareUtils import PyViCareNotSupportedFeatureError, handleNotSupported
6+
from PyViCare.PyViCareUtils import PyViCareNotSupportedFeatureError, handleAPICommandErrors, handleNotSupported
77

88

99
class HeatPump(HeatingDevice):
@@ -115,7 +115,7 @@ def setActiveVentilationMode(self, mode):
115115
----------
116116
mode : str
117117
Valid mode can be obtained using getModes()
118-
118+
119119
Returns
120120
-------
121121
result: json
@@ -144,14 +144,112 @@ def activateVentilationProgram(self, program):
144144
Parameters
145145
----------
146146
program : str
147-
147+
148148
Returns
149149
-------
150150
result: json
151151
json representation of the answer
152152
"""
153153
return self.service.setProperty(f"ventilation.operating.programs.{program}", "activate", {})
154154

155+
@handleNotSupported
156+
def getDomesticHotWaterHysteresisUnit(self) -> str:
157+
return str(self.service.getProperty("heating.dhw.temperature.hysteresis")["properties"]["value"]["unit"])
158+
159+
@handleNotSupported
160+
def getDomesticHotWaterHysteresis(self) -> float:
161+
return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["properties"]["value"]["value"])
162+
163+
@handleNotSupported
164+
def getDomesticHotWaterHysteresisMin(self) -> float:
165+
return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["commands"]["setHysteresis"]["params"]["hysteresis"]["constraints"]["min"])
166+
167+
@handleNotSupported
168+
def getDomesticHotWaterHysteresisMax(self) -> float:
169+
return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["commands"]["setHysteresis"]["params"]["hysteresis"]["constraints"]["max"])
170+
171+
@handleNotSupported
172+
def getDomesticHotWaterHysteresisStepping(self) -> float:
173+
return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["commands"]["setHysteresis"]["params"]["hysteresis"]["constraints"]["stepping"])
174+
175+
@handleAPICommandErrors
176+
def setDomesticHotWaterHysteresis(self, temperature: float) -> Any:
177+
""" Set the hysteresis temperature for domestic host water
178+
Parameters
179+
----------
180+
temperature : float
181+
hysteresis temperature
182+
183+
Returns
184+
-------
185+
result: json
186+
json representation of the answer
187+
"""
188+
return self.service.setProperty("heating.dhw.temperature.hysteresis", "setHysteresis", {'hysteresis': temperature})
189+
190+
@handleNotSupported
191+
def getDomesticHotWaterHysteresisSwitchOn(self) -> float:
192+
return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["properties"]["switchOnValue"]["value"])
193+
194+
@handleNotSupported
195+
def getDomesticHotWaterHysteresisSwitchOnMin(self) -> float:
196+
return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["commands"]["setHysteresisSwitchOnValue"]["params"]["hysteresis"]["constraints"]["min"])
197+
198+
@handleNotSupported
199+
def getDomesticHotWaterHysteresisSwitchOnMax(self) -> float:
200+
return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["commands"]["setHysteresisSwitchOnValue"]["params"]["hysteresis"]["constraints"]["max"])
201+
202+
@handleNotSupported
203+
def getDomesticHotWaterHysteresisSwitchOnStepping(self) -> float:
204+
return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["commands"]["setHysteresisSwitchOnValue"]["params"]["hysteresis"]["constraints"]["stepping"])
205+
206+
@handleAPICommandErrors
207+
def setDomesticHotWaterHysteresisSwitchOn(self, temperature: float) -> Any:
208+
""" Set the hysteresis switch on temperature for domestic host water
209+
Parameters
210+
----------
211+
temperature : float
212+
hysteresis switch on temperature
213+
214+
Returns
215+
-------
216+
result: json
217+
json representation of the answer
218+
"""
219+
return self.service.setProperty("heating.dhw.temperature.hysteresis", "setHysteresisSwitchOnValue", {'hysteresis': temperature})
220+
221+
@handleNotSupported
222+
def getDomesticHotWaterHysteresisSwitchOff(self) -> float:
223+
return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["properties"]["switchOffValue"]["value"])
224+
225+
@handleNotSupported
226+
def getDomesticHotWaterHysteresisSwitchOffMin(self) -> float:
227+
return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["commands"]["setHysteresisSwitchOffValue"]["params"]["hysteresis"]["constraints"]["min"])
228+
229+
@handleNotSupported
230+
def getDomesticHotWaterHysteresisSwitchOffMax(self) -> float:
231+
return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["commands"]["setHysteresisSwitchOffValue"]["params"]["hysteresis"]["constraints"]["max"])
232+
233+
@handleNotSupported
234+
def getDomesticHotWaterHysteresisSwitchOffStepping(self) -> float:
235+
return float(self.service.getProperty("heating.dhw.temperature.hysteresis")["commands"]["setHysteresisSwitchOffValue"]["params"]["hysteresis"]["constraints"]["stepping"])
236+
237+
@handleAPICommandErrors
238+
def setDomesticHotWaterHysteresisSwitchOff(self, temperature: float) -> Any:
239+
""" Set the hysteresis switch off temperature for domestic host water
240+
Parameters
241+
----------
242+
temperature : float
243+
hysteresis switch off temperature
244+
245+
Returns
246+
-------
247+
result: json
248+
json representation of the answer
249+
"""
250+
return self.service.setProperty("heating.dhw.temperature.hysteresis", "setHysteresisSwitchOffValue", {'hysteresis': temperature})
251+
252+
155253
class Compressor(HeatingDeviceWithComponent):
156254

157255
@property

tests/test_TestForMissingProperties.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def test_missingProperties(self):
3131
'heating.power.consumption',
3232

3333
'heating.circuits.0.temperature.levels', # hint: command
34-
'heating.dhw.temperature.hysteresis', # hint: command
3534
'heating.dhw.hygiene',
3635
'heating.dhw.temperature',
3736
'heating.burners',

tests/test_Vitocal250A.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,65 @@ def test_getPowerSummaryConsumptionDomesticHotWaterLastYear(self):
128128
def test_getCompressorPhase(self):
129129
self.assertEqual(
130130
self.device.getCompressor(0).getPhase(), "ready")
131+
132+
def test_getDomesticHotWaterHysteresis(self):
133+
self.assertEqual(
134+
self.device.getDomesticHotWaterHysteresisUnit(), 'kelvin')
135+
self.assertEqual(
136+
self.device.getDomesticHotWaterHysteresis(), 5)
137+
self.assertEqual(
138+
self.device.getDomesticHotWaterHysteresisMin(), 1)
139+
self.assertEqual(
140+
self.device.getDomesticHotWaterHysteresisMax(), 10)
141+
self.assertEqual(
142+
self.device.getDomesticHotWaterHysteresisStepping(), 0.5)
143+
144+
def test_getDomesticHotWaterHysteresisSwitchOn(self):
145+
self.assertEqual(
146+
self.device.getDomesticHotWaterHysteresisSwitchOn(), 5)
147+
self.assertEqual(
148+
self.device.getDomesticHotWaterHysteresisSwitchOnMin(), 1)
149+
self.assertEqual(
150+
self.device.getDomesticHotWaterHysteresisSwitchOnMax(), 10)
151+
self.assertEqual(
152+
self.device.getDomesticHotWaterHysteresisSwitchOnStepping(), 0.5)
153+
154+
def test_getDomesticHotWaterHysteresisSwitchOff(self):
155+
self.assertEqual(
156+
self.device.getDomesticHotWaterHysteresisSwitchOff(), 0)
157+
self.assertEqual(
158+
self.device.getDomesticHotWaterHysteresisSwitchOffMin(), 0)
159+
self.assertEqual(
160+
self.device.getDomesticHotWaterHysteresisSwitchOffMax(), 2.5)
161+
self.assertEqual(
162+
self.device.getDomesticHotWaterHysteresisSwitchOffStepping(), 0.5)
163+
164+
def test_setDomesticHotWaterHysteresis(self):
165+
self.device.setDomesticHotWaterHysteresis(5)
166+
self.assertEqual(len(self.service.setPropertyData), 1)
167+
self.assertEqual(
168+
self.service.setPropertyData[0]['property_name'], 'heating.dhw.temperature.hysteresis')
169+
self.assertEqual(
170+
self.service.setPropertyData[0]['action'], 'setHysteresis')
171+
self.assertEqual(self.service.setPropertyData[0]['data'], {
172+
'hysteresis': 5})
173+
174+
def test_setDomesticHotWaterHysteresisSwitchOn(self):
175+
self.device.setDomesticHotWaterHysteresisSwitchOn(5)
176+
self.assertEqual(len(self.service.setPropertyData), 1)
177+
self.assertEqual(
178+
self.service.setPropertyData[0]['property_name'], 'heating.dhw.temperature.hysteresis')
179+
self.assertEqual(
180+
self.service.setPropertyData[0]['action'], 'setHysteresisSwitchOnValue')
181+
self.assertEqual(self.service.setPropertyData[0]['data'], {
182+
'hysteresis': 5})
183+
184+
def test_setDomesticHotWaterHysteresisSwitchOff(self):
185+
self.device.setDomesticHotWaterHysteresisSwitchOff(5)
186+
self.assertEqual(len(self.service.setPropertyData), 1)
187+
self.assertEqual(
188+
self.service.setPropertyData[0]['property_name'], 'heating.dhw.temperature.hysteresis')
189+
self.assertEqual(
190+
self.service.setPropertyData[0]['action'], 'setHysteresisSwitchOffValue')
191+
self.assertEqual(self.service.setPropertyData[0]['data'], {
192+
'hysteresis': 5})

0 commit comments

Comments
 (0)