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: Add ventilation qickmode methods #458

Merged
merged 9 commits into from
Dec 2, 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
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')
Loading