Skip to content

Commit 1acf2ea

Browse files
ckoeber83CFenner
andauthored
feat(heat pump): add condenser, evaporator and compressor data points (#654)
* Update PyViCareHeatPump.py Add refrigeration circuit pressure and temperature sensors: heating.compressors.N.sensors.pressure.outlet heating.compressors.N.sensors.pressure.inlet heating.compressors.N.sensors.temperature.outlet heating.compressors.N.sensors.temperature.inlet heating.evaporators.N.sensors.temperature.liquid heating.evaporators.N.sensors.temperature.overheat * Update PyViCareHeatPump.py Adding subcooling of the first condensor. heating.condensors.N.sensors.temperature.subcooling * Apply suggestions from code review * Refactor compressor and evaporator methods * Rename methods for consistency in naming * add test cases * fix * add test case * add test case * add test case * add test case --------- Co-authored-by: Christopher Fenner <9592452+CFenner@users.noreply.github.com> Co-authored-by: Christopher Fenner <Christopher.Fenner@me.com>
1 parent 30d9122 commit 1acf2ea

File tree

4 files changed

+152
-6
lines changed

4 files changed

+152
-6
lines changed

PyViCare/PyViCareHeatPump.py

Lines changed: 112 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import annotations
12
from typing import Any, List
23
from deprecated import deprecated
34

@@ -9,16 +10,30 @@
910
class HeatPump(HeatingDevice, VentilationDevice):
1011

1112
@property
12-
def compressors(self) -> List[Any]:
13-
return list([self.getCompressor(x) for x in self.getAvailableCompressors()])
13+
def compressors(self) -> List[Compressor]:
14+
return [self.getCompressor(x) for x in self.getAvailableCompressors()]
1415

15-
def getCompressor(self, compressor):
16+
def getCompressor(self, compressor) -> Compressor:
1617
return Compressor(self, compressor)
1718

1819
@handleNotSupported
1920
def getAvailableCompressors(self):
2021
return self.getProperty("heating.compressors")["properties"]["enabled"]["value"]
2122

23+
@property
24+
def condensors(self) -> List[Condensor]:
25+
return [self.getCondensor(x) for x in self.getAvailableCompressors()]
26+
27+
def getCondensor(self, condensor) -> Condensor:
28+
return Condensor(self, condensor)
29+
30+
@property
31+
def evaporators(self) -> List[Evaporator]:
32+
return [self.getEvaporator(x) for x in self.getAvailableCompressors()]
33+
34+
def getEvaporator(self, evaporator) -> Evaporator:
35+
return Evaporator(self, evaporator)
36+
2237
@handleNotSupported
2338
def getBufferMainTemperature(self):
2439
return self.getProperty("heating.bufferCylinder.sensors.temperature.main")["properties"]['value']['value']
@@ -376,3 +391,97 @@ def getPowerConsumptionTotalThisYear(self) -> float:
376391
@handleNotSupported
377392
def getPowerConsumptionTotalUnit(self) -> str:
378393
return str(self.getProperty(f"heating.compressors.{self.compressor}.power.consumption.total")["properties"]["year"]["unit"])
394+
395+
@handleNotSupported
396+
def getCompressorOutletPressureUnit(self) -> str:
397+
# Shows the unit of measurement of the outlet pressure.
398+
return str(self.getProperty(f"heating.compressors.{self.compressor}.sensors.pressure.outlet")["properties"]["value"]["unit"])
399+
400+
@handleNotSupported
401+
def getCompressorOutletPressure(self) -> float:
402+
# Shows the outlet pressure of the compressor.
403+
return float(self.getProperty(f"heating.compressors.{self.compressor}.sensors.pressure.outlet")["properties"]["value"]["value"])
404+
405+
@handleNotSupported
406+
def getCompressorInletPressureUnit(self) -> str:
407+
# Shows the unit of measurement of the inlet pressure.
408+
return str(self.getProperty(f"heating.compressors.{self.compressor}.sensors.pressure.inlet")["properties"]["value"]["unit"])
409+
410+
@handleNotSupported
411+
def getCompressorInletPressure(self) -> float:
412+
# Shows the inlet pressure of the compressor.
413+
return float(self.getProperty(f"heating.compressors.{self.compressor}.sensors.pressure.inlet")["properties"]["value"]["value"])
414+
415+
@handleNotSupported
416+
def getCompressorOutletTemperatureUnit(self) -> str:
417+
# Shows the unit of measurement of the outlet temperature.
418+
return str(self.getProperty(f"heating.compressors.{self.compressor}.sensors.temperature.outlet")["properties"]["value"]["unit"])
419+
420+
@handleNotSupported
421+
def getCompressorOutletTemperature(self) -> float:
422+
# Shows the outlet temperature of the compressor.
423+
return float(self.getProperty(f"heating.compressors.{self.compressor}.sensors.temperature.outlet")["properties"]["value"]["value"])
424+
425+
@handleNotSupported
426+
def getCompressorInletTemperatureUnit(self) -> str:
427+
# Shows the unit of measurement of the inlet temperature.
428+
return str(self.getProperty(f"heating.compressors.{self.compressor}.sensors.temperature.inlet")["properties"]["value"]["unit"])
429+
430+
@handleNotSupported
431+
def getCompressorInletTemperature(self) -> float:
432+
# Shows the inlet temperature of the compressor.
433+
return float(self.getProperty(f"heating.compressors.{self.compressor}.sensors.temperature.inlet")["properties"]["value"]["value"])
434+
435+
436+
class Evaporator(HeatingDeviceWithComponent):
437+
438+
@property
439+
def evaporator(self) -> str:
440+
return self.component
441+
442+
@handleNotSupported
443+
def getEvaporatorLiquidTemperatureUnit(self) -> str:
444+
# Shows the unit of measurement of the liquid temperature of the evaporator.
445+
return str(self.getProperty(f"heating.evaporators.{self.evaporator}.sensors.temperature.liquid")["properties"]["value"]["unit"])
446+
447+
@handleNotSupported
448+
def getEvaporatorLiquidTemperature(self) -> float:
449+
# Shows the liquid temperature of the evaporator.
450+
return float(self.getProperty(f"heating.evaporators.{self.evaporator}.sensors.temperature.liquid")["properties"]["value"]["value"])
451+
452+
@handleNotSupported
453+
def getEvaporatorOverheatTemperatureUnit(self) -> str:
454+
# Shows the unit of measurement of the overheat temperature of the evaporator.
455+
return str(self.getProperty(f"heating.evaporators.{self.evaporator}.sensors.temperature.overheat")["properties"]["value"]["unit"])
456+
457+
@handleNotSupported
458+
def getEvaporatorOverheatTemperature(self) -> float:
459+
# Shows the overheat temperature of the evaporator.
460+
return float(self.getProperty(f"heating.evaporators.{self.evaporator}.sensors.temperature.overheat")["properties"]["value"]["value"])
461+
462+
463+
class Condensor(HeatingDeviceWithComponent):
464+
465+
@property
466+
def condensor(self) -> str:
467+
return self.component
468+
469+
@handleNotSupported
470+
def getCondensorSubcoolingTemperatureUnit(self) -> str:
471+
# Shows the unit of measurement of the subcooling temperature of the condensor.
472+
return str(self.getProperty(f"heating.condensors.{self.condensor}.sensors.temperature.subcooling")["properties"]["value"]["unit"])
473+
474+
@handleNotSupported
475+
def getCondensorSubcoolingTemperature(self) -> float:
476+
# Shows the subcooling temperature of the condensor.
477+
return float(self.getProperty(f"heating.condensors.{self.condensor}.sensors.temperature.subcooling")["properties"]["value"]["value"])
478+
479+
@handleNotSupported
480+
def getCondensorLiquidTemperatureUnit(self) -> str:
481+
# Shows the unit of measurement of the liquid temperature of the condensor.
482+
return str(self.getProperty(f"heating.condensors.{self.condensor}.sensors.temperature.liquid")["properties"]["value"]["unit"])
483+
484+
@handleNotSupported
485+
def getCondensorLiquidTemperature(self) -> float:
486+
# Shows the liquid temperature of the condensor.
487+
return float(self.getProperty(f"heating.condensors.{self.condensor}.sensors.temperature.liquid")["properties"]["value"]["value"])

tests/test_TestForMissingProperties.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ def test_missingProperties(self):
5555
'heating.compressors.0.sensors.temperature.oil',
5656
'heating.compressors.0.sensors.temperature.outlet',
5757
'heating.compressors.0.speed.current',
58-
'heating.condensors.0.sensors.temperature.liquid',
5958
'heating.configuration.heatingRod.dhw',
6059
'heating.configuration.heatingRod.heating',
6160
'heating.configuration.internalPumpOne',
@@ -168,7 +167,6 @@ def test_missingProperties(self):
168167
'heating.compressors.0.sensors.temperature.ambient',
169168
'heating.compressors.0.sensors.temperature.overheat',
170169
'heating.compressors.0.statistics.load',
171-
'heating.condensors.0.sensors.temperature.subcooling',
172170
'heating.configuration.buffer.temperature.max',
173171
'heating.configuration.flow.temperature.max',
174172
'heating.configuration.flow.temperature.min',
@@ -271,6 +269,7 @@ def test_unverifiedProperties(self):
271269
'heating.compressors.0.power.consumption.total',
272270
'ventilation.sensors.temperature.outside',
273271
'ventilation.sensors.humidity.outdoor',
272+
'heating.compressors.0.sensors.pressure.outlet',
274273
]
275274

276275
all_features = self.read_all_features()
@@ -282,7 +281,7 @@ def test_unverifiedProperties(self):
282281
continue
283282

284283
for match in re.findall(r'getProperty\(\s*?f?"(.*)"\s*?\)', all_python_files[python]):
285-
feature_name = re.sub(r'{self.(circuit|burner|compressor)}', '0', match)
284+
feature_name = re.sub(r'{self.(circuit|burner|compressor|condensor|evaporator)}', '0', match)
286285
feature_name = re.sub(r'{burner}', '0', feature_name)
287286
feature_name = re.sub(r'\.{(quickmode|mode|program|active_program)}', '', feature_name)
288287
used_features.append(feature_name)

tests/test_Vitocal222S.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import unittest
2+
3+
from PyViCare.PyViCareHeatPump import HeatPump
4+
from tests.ViCareServiceMock import ViCareServiceMock
5+
6+
7+
class Vitocal222S(unittest.TestCase):
8+
def setUp(self):
9+
self.service = ViCareServiceMock('response/Vitocal222S.json')
10+
self.device = HeatPump(self.service)
11+
12+
def test_getCondensorsLiquidTemperature(self):
13+
self.assertEqual(self.device.getCondensor(0).getCondensorLiquidTemperature(), 26.1)
14+
self.assertEqual(self.device.getCondensor(0).getCondensorLiquidTemperatureUnit(), "celsius")
15+
16+
def test_getCompressorInletTemperature(self):
17+
self.assertEqual(self.device.getCompressor(0).getCompressorInletTemperature(), 0.0)
18+
self.assertEqual(self.device.getCompressor(0).getCompressorInletTemperatureUnit(), "celsius")
19+
20+
def test_getCompressorOutletTemperature(self):
21+
self.assertEqual(self.device.getCompressor(0).getCompressorOutletTemperature(), 32.8)
22+
self.assertEqual(self.device.getCompressor(0).getCompressorOutletTemperatureUnit(), "celsius")

tests/test_Vitocal333G_with_Vitovent300F.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,19 @@ def test_getHeatExchangerFrostProtectionActive(self):
1515
def test_getVolumeFlow(self):
1616
self.assertEqual(self.device.getSupplyVolumeFlow(), 257)
1717
self.assertEqual(self.device.getExhaustVolumeFlow(), 257)
18+
19+
def test_getCondensorSubcoolingTemperature(self):
20+
self.assertEqual(self.device.getCondensor("0").getCondensorSubcoolingTemperature(), -2.8)
21+
self.assertEqual(self.device.getCondensor("0").getCondensorSubcoolingTemperatureUnit(), "celsius")
22+
23+
def test_getEvaporatorOverheatTemperature(self):
24+
self.assertEqual(self.device.getEvaporator("0").getEvaporatorOverheatTemperature(), 0.0)
25+
self.assertEqual(self.device.getEvaporator("0").getEvaporatorOverheatTemperatureUnit(), "celsius")
26+
27+
def test_getEvaporatorLiquidTemperature(self):
28+
self.assertEqual(self.device.getEvaporator("0").getEvaporatorLiquidTemperature(), 18.2)
29+
self.assertEqual(self.device.getEvaporator("0").getEvaporatorLiquidTemperatureUnit(), "celsius")
30+
31+
def test_getCompressorInletPressure(self):
32+
self.assertEqual(self.device.getCompressor("0").getCompressorInletPressure(), 12.9)
33+
self.assertEqual(self.device.getCompressor("0").getCompressorInletPressureUnit(), "bar")

0 commit comments

Comments
 (0)