Skip to content

Commit

Permalink
feat: Add ventilation qickmode methods (#458)
Browse files Browse the repository at this point in the history
* add qickmode methods

* add qickmode methods

* add more quickmodes

* modify test case

* add test case

* add test case

* add test case
  • Loading branch information
CFenner authored Dec 2, 2024
1 parent 10f5a7e commit 7321c3e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
21 changes: 21 additions & 0 deletions PyViCare/PyViCareVentilationDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,24 @@ def getVentilationLevel(self) -> str:
@handleNotSupported
def getVentilationReason(self) -> str:
return str(self.service.getProperty("ventilation.operating.state")["properties"]["reason"]["value"])

@handleNotSupported
def getVentilationQuickmodes(self) -> list[str]:
available_quickmodes = []
for quickmode in ['comfort', 'eco', 'forcedLevelFour', 'holiday', 'standby', 'silent']:
with suppress(PyViCareNotSupportedFeatureError):
if self.service.getProperty(f"ventilation.quickmodes.{quickmode}") is not None:
available_quickmodes.append(quickmode)
return available_quickmodes

@handleNotSupported
def getVentilationQuickmode(self, quickmode: str) -> bool:
return bool(self.service.getProperty(f"ventilation.quickmodes.{quickmode}")["properties"]["active"]["value"])

@handleNotSupported
def activateVentilationQuickmode(self, quickmode: str) -> None:
self.service.setProperty(f"ventilation.quickmodes.{quickmode}", "activate", {})

@handleNotSupported
def deactivateVentilationQuickmode(self, quickmode: str) -> None:
self.service.setProperty(f"ventilation.quickmodes.{quickmode}", "deactivate", {})
5 changes: 3 additions & 2 deletions tests/test_TestForMissingProperties.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_missingProperties(self):
'ventilation.levels.levelTwo',
'ventilation.levels.levelThree',
'ventilation.levels.levelFour',
'ventilation.quickmodes.forcedLevelFour',
'ventilation.quickmodes.forcedLevelFour', # quickmode accessible via getVentilationQuickmode
'ventilation.quickmodes.silent',
'ventilation.quickmodes.standby',
'ventilation.quickmodes.comfort',
Expand Down Expand Up @@ -129,6 +129,7 @@ def test_unverifiedProperties(self):

ignore = [
'heating.dhw.sensors.temperature.dhwCylinder.midBottom', # FIXME: remove once test data is updated
'ventilation.quickmodes',
]

all_features = self.read_all_features()
Expand All @@ -142,7 +143,7 @@ def test_unverifiedProperties(self):
for match in re.findall(r'getProperty\(\s*?f?"(.*)"\s*?\)', all_python_files[python]):
feature_name = re.sub(r'{self.(circuit|burner|compressor)}', '0', match)
feature_name = re.sub(r'{burner}', '0', feature_name)
feature_name = re.sub(r'\.{(program|active_program)}', '', feature_name)
feature_name = re.sub(r'\.{(quickmode|program|active_program)}', '', feature_name)
used_features.append(feature_name)

self.assertSetEqual(set([]), set(used_features) - set(all_features) - set(ignore))
Expand Down
22 changes: 22 additions & 0 deletions tests/test_Vitopure350.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,25 @@ def test_ventilationState(self):
self.assertEqual(self.device.getVentilationDemand(), "unknown")
self.assertEqual(self.device.getVentilationLevel(), "unknown")
self.assertEqual(self.device.getVentilationReason(), "sensorDriven")

def test_ventilationQuickmode(self):
self.assertEqual(self.device.getVentilationQuickmode("standby"), False)

def test_ventilationQuickmodes(self):
self.assertEqual(self.device.getVentilationQuickmodes(), [
"forcedLevelFour",
"standby",
"silent",
])

def test_activateComfort(self):
self.device.activateVentilationQuickmode("standby")
self.assertEqual(len(self.service.setPropertyData), 1)
self.assertEqual(self.service.setPropertyData[0]['action'], 'activate')
self.assertEqual(self.service.setPropertyData[0]['property_name'], 'ventilation.quickmodes.standby')

def test_deactivateComfort(self):
self.device.deactivateVentilationQuickmode("standby")
self.assertEqual(len(self.service.setPropertyData), 1)
self.assertEqual(self.service.setPropertyData[0]['action'], 'deactivate')
self.assertEqual(self.service.setPropertyData[0]['property_name'], 'ventilation.quickmodes.standby')

0 comments on commit 7321c3e

Please sign in to comment.