From 16c04113502e56c64f65aadc6945e6c6623628dd Mon Sep 17 00:00:00 2001 From: Christian Lackas Date: Tue, 7 Jul 2026 21:33:05 +0200 Subject: [PATCH] feat(heatpump): add weekly per-compressor power consumption getters Newer heat pumps (e.g. Vitocal 300-G / CU401B) expose consumption only as scalar heating.compressors.N.power.consumption..week features, not via the device-level heating.power.consumption. day/month/year buckets the existing getters read. Adds getPowerConsumption{Heating,DHW,Cooling}ThisWeek plus unit getters on the Compressor class, with tests. --- PyViCare/PyViCareHeatPump.py | 24 +++++++++++++++++++++ tests/test_Vitocal333G_with_Vitovent300F.py | 13 +++++++++++ 2 files changed, 37 insertions(+) diff --git a/PyViCare/PyViCareHeatPump.py b/PyViCare/PyViCareHeatPump.py index 74da5477..dbbc54ec 100644 --- a/PyViCare/PyViCareHeatPump.py +++ b/PyViCare/PyViCareHeatPump.py @@ -677,6 +677,30 @@ def getPowerConsumptionHeatingThisYear(self) -> float: def getPowerConsumptionCoolingThisYear(self) -> float: return float(self.getProperty(f"heating.compressors.{self.compressor}.power.consumption.cooling")["properties"]["year"]["value"][0]) + @handleNotSupported + def getPowerConsumptionHeatingThisWeek(self) -> float: + return float(self.getProperty(f"heating.compressors.{self.compressor}.power.consumption.heating.week")["properties"]["value"]["value"]) + + @handleNotSupported + def getPowerConsumptionHeatingThisWeekUnit(self) -> str: + return str(self.getProperty(f"heating.compressors.{self.compressor}.power.consumption.heating.week")["properties"]["value"]["unit"]) + + @handleNotSupported + def getPowerConsumptionDHWThisWeek(self) -> float: + return float(self.getProperty(f"heating.compressors.{self.compressor}.power.consumption.dhw.week")["properties"]["value"]["value"]) + + @handleNotSupported + def getPowerConsumptionDHWThisWeekUnit(self) -> str: + return str(self.getProperty(f"heating.compressors.{self.compressor}.power.consumption.dhw.week")["properties"]["value"]["unit"]) + + @handleNotSupported + def getPowerConsumptionCoolingThisWeek(self) -> float: + return float(self.getProperty(f"heating.compressors.{self.compressor}.power.consumption.cooling.week")["properties"]["value"]["value"]) + + @handleNotSupported + def getPowerConsumptionCoolingThisWeekUnit(self) -> str: + return str(self.getProperty(f"heating.compressors.{self.compressor}.power.consumption.cooling.week")["properties"]["value"]["unit"]) + @handleNotSupported def getPowerConsumptionTotalThisYear(self) -> float: return float(self.getProperty(f"heating.compressors.{self.compressor}.power.consumption.total")["properties"]["year"]["value"][0]) diff --git a/tests/test_Vitocal333G_with_Vitovent300F.py b/tests/test_Vitocal333G_with_Vitovent300F.py index 9ed9ff17..ba882fe6 100644 --- a/tests/test_Vitocal333G_with_Vitovent300F.py +++ b/tests/test_Vitocal333G_with_Vitovent300F.py @@ -2,6 +2,7 @@ from PyViCare.PyViCareService import ViCareDeviceAccessor from PyViCare.PyViCareHeatPump import HeatPump +from PyViCare.PyViCareUtils import PyViCareNotSupportedFeatureError from tests.ViCareServiceMock import ViCareServiceMock @@ -33,3 +34,15 @@ def test_evaporator_getLiquidTemperature(self): def test_compressor_getInletPressure(self): self.assertEqual(self.device.getCompressor("0").getInletPressure(), 12.9) self.assertEqual(self.device.getCompressor("0").getInletPressureUnit(), "bar") + + def test_compressor_getPowerConsumptionHeatingThisWeek(self): + self.assertEqual(self.device.getCompressor("0").getPowerConsumptionHeatingThisWeek(), 6.3) + self.assertEqual(self.device.getCompressor("0").getPowerConsumptionHeatingThisWeekUnit(), "kilowattHour") + + def test_compressor_getPowerConsumptionDHWThisWeek(self): + self.assertEqual(self.device.getCompressor("0").getPowerConsumptionDHWThisWeek(), 2.3) + self.assertEqual(self.device.getCompressor("0").getPowerConsumptionDHWThisWeekUnit(), "kilowattHour") + + def test_compressor_getPowerConsumptionCoolingThisWeek_notSupported(self): + with self.assertRaises(PyViCareNotSupportedFeatureError): + self.device.getCompressor("0").getPowerConsumptionCoolingThisWeek()