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 data points #392

Merged
merged 4 commits into from
Sep 6, 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
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 @@
'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 Expand Up @@ -63,7 +62,7 @@
'device.productIdentification',

# gateway
'gateway.devices', # not used

Check failure on line 65 in tests/test_TestForMissingProperties.py

View workflow job for this annotation

GitHub Actions / build (3.6)

E261 at least two spaces before inline comment

Check failure on line 65 in tests/test_TestForMissingProperties.py

View workflow job for this annotation

GitHub Actions / build (3.8)

E261 at least two spaces before inline comment

Check failure on line 65 in tests/test_TestForMissingProperties.py

View workflow job for this annotation

GitHub Actions / build (3.9)

E261 at least two spaces before inline comment
]

all_features = self.read_all_features()
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})
Loading