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

Support Ventilation modes and programs on heat pumps #358

Merged
merged 1 commit into from
Apr 2, 2024
Merged
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
53 changes: 52 additions & 1 deletion PyViCare/PyViCareHeatPump.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from contextlib import suppress
from typing import Any, List

from PyViCare.PyViCareHeatingDevice import (HeatingDevice,
HeatingDeviceWithComponent)
from PyViCare.PyViCareUtils import handleNotSupported
from PyViCare.PyViCareUtils import PyViCareNotSupportedFeatureError, handleNotSupported


class HeatPump(HeatingDevice):
Expand Down Expand Up @@ -100,8 +101,58 @@
def getVolumetricFlowReturn(self):
return self.service.getProperty("heating.sensors.volumetricFlow.allengra")["properties"]['value']['value']

@handleNotSupported
def getAvailableVentilationModes(self):
return self.service.getProperty("ventilation.operating.modes.active")["commands"]["setMode"]["params"]["mode"]["constraints"]["enum"]

@handleNotSupported
def getActiveVentilationMode(self):
return self.service.getProperty("ventilation.operating.modes.active")["properties"]["value"]["value"]

""" Set the active mode
Parameters
----------
mode : str
Valid mode can be obtained using getModes()

Returns
-------
result: json
json representation of the answer
"""
def setActiveVentilationMode(self, mode):
return self.service.setProperty("ventilation.operating.modes.active", "setMode", {'mode': mode})

@handleNotSupported
def getAvailableVentilationPrograms(self):
available_programs = []
for program in ['basic', 'intensive', 'reduced', 'standard', 'standby', 'comfort', 'eco', 'forcedLevelFour',
'holiday', 'holidayAtHome', 'levelFour', 'levelOne', 'levelThree', 'levelTwo', 'permanent', 'silent']:
with suppress(PyViCareNotSupportedFeatureError):
if self.service.getProperty(f"ventilation.operating.programs.{program}") is not None:
available_programs.append(program)
return available_programs

@handleNotSupported
def getActiveVentilationProgram(self):
return self.service.getProperty("ventilation.operating.programs.active")["properties"]["value"]["value"]

""" Activate a ventilation program
NOTE
DEVICE_COMMUNICATION_ERROR can just mean that the program is already on
Parameters
----------
program : str

Returns
-------
result: json
json representation of the answer
"""
def activateVentilationProgram(self, program):
return self.service.setProperty(f"ventilation.operating.programs.{program}", "activate", {})

class Compressor(HeatingDeviceWithComponent):

Check failure on line 155 in PyViCare/PyViCareHeatPump.py

View workflow job for this annotation

GitHub Actions / build (3.8)

E302 expected 2 blank lines, found 1

Check failure on line 155 in PyViCare/PyViCareHeatPump.py

View workflow job for this annotation

GitHub Actions / build (3.9)

E302 expected 2 blank lines, found 1

@property
def compressor(self) -> str:
Expand Down
Loading