Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose hysteresis value data points #19

Merged
merged 7 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion 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 @@ -152,6 +152,50 @@ 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"]

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

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

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

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

@handleAPICommandErrors
def setDomesticHotWaterHysteresis(self, temperature):
""" 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': int(temperature)})

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

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

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 @@ -32,7 +32,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
12 changes: 12 additions & 0 deletions tests/test_Vitocal250A.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,15 @@ def test_getOutsideTemperature(self):
def test_getFrostProtectionActive(self):
self.assertEqual(
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.getDomesticHotWaterHysteresisMin(), 1)
self.assertEqual(
self.device.getDomesticHotWaterHysteresisMax(), 10)
self.assertEqual(
self.device.getDomesticHotWaterHysteresisStepping(), 0.5)