Skip to content
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
37 changes: 36 additions & 1 deletion PyViCare/PyViCareHeatPump.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from __future__ import annotations
from contextlib import suppress
from typing import Any, List
from deprecated import deprecated

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


Expand Down Expand Up @@ -320,6 +322,39 @@ def getHeatingRodPowerConsumptionHeatingThisYear(self) -> float:
def getHeatingRodPowerConsumptionTotalThisYear(self) -> float:
return float(self.getProperty("heating.heatingRod.power.consumption.total")["properties"]["year"]["value"][0])

# Cooling circuits
@property
def coolingCircuits(self) -> List[CoolingCircuit]:
return [self.getCoolingCircuit(x) for x in self.getAvailableCoolingCircuits()]

def getCoolingCircuit(self, circuit) -> CoolingCircuit:
return CoolingCircuit(self, circuit)

def getAvailableCoolingCircuits(self):
"""Detect available cooling circuits (0, 1, 2, etc.)."""
available = []
for circuit in ['0', '1', '2', '3']:
with suppress(KeyError, PyViCareNotSupportedFeatureError):
if self.getProperty(f"heating.coolingCircuits.{circuit}.type") is not None:
available.append(circuit)
return available


class CoolingCircuit(HeatingDeviceWithComponent):
"""Cooling circuit component for heat pumps with cooling capability."""

@property
def circuit(self) -> str:
return self.component

@handleNotSupported
def getType(self) -> str:
return str(self.getProperty(f"heating.coolingCircuits.{self.circuit}.type")["properties"]["value"]["value"])

@handleNotSupported
def getReverseActive(self) -> bool:
return bool(self.getProperty(f"heating.coolingCircuits.{self.circuit}.reverse")["properties"]["active"]["value"])


class Compressor(HeatingDeviceWithComponent):

Expand Down
4 changes: 1 addition & 3 deletions tests/test_TestForMissingProperties.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,6 @@ def test_missingProperties(self):
'heating.configuration.dhwHeater',
'heating.configuration.flow.temperature.max',
'heating.configuration.flow.temperature.min',
'heating.coolingCircuits.0.reverse',
'heating.coolingCircuits.0.type',
'heating.cop.cooling',
'heating.cop.dhw',
'heating.cop.green',
Expand Down Expand Up @@ -359,7 +357,7 @@ def test_unverifiedProperties(self):
continue

for match in re.findall(r'getProperty\(\s*?f?"(.*)"\s*?\)', all_python_files[python]):
feature_name = re.sub(r'{self.(circuit|burner|compressor|condensor|evaporator|inverter)}', '0', match)
feature_name = re.sub(r'{(self\.)?(circuit|burner|compressor|condensor|evaporator|inverter)}', '0', match)
feature_name = re.sub(r'{burner}', '0', feature_name)
feature_name = re.sub(r'\.{(quickmode|mode|program|active_program)}', '', feature_name)
used_features.append(feature_name)
Expand Down
13 changes: 13 additions & 0 deletions tests/test_Vitocal300G.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,16 @@ def test_getModes(self):
def test_getDomesticHotWaterCirculationPumpActive(self):
self.assertEqual(
self.device.getDomesticHotWaterCirculationPumpActive(), False)

# Cooling circuit tests
def test_getAvailableCoolingCircuits(self):
self.assertEqual(
self.device.getAvailableCoolingCircuits(), ['0'])

def test_coolingCircuit_getType(self):
self.assertEqual(
self.device.coolingCircuits[0].getType(), "VC 3xx-G Emerson")

def test_coolingCircuit_getReverseActive(self):
self.assertEqual(
self.device.coolingCircuits[0].getReverseActive(), False)
Loading