11from __future__ import annotations
2+ from contextlib import suppress
23from typing import Any , List
34from deprecated import deprecated
45
56from PyViCare .PyViCareHeatingDevice import HeatingDevice , HeatingDeviceWithComponent
6- from PyViCare .PyViCareUtils import handleAPICommandErrors , handleNotSupported
7+ from PyViCare .PyViCareUtils import (PyViCareNotSupportedFeatureError ,
8+ handleAPICommandErrors , handleNotSupported )
79from PyViCare .PyViCareVentilationDevice import VentilationDevice
810
911
@@ -51,6 +53,23 @@ def getBufferTopTemperature(self):
5153
5254 # Power consumption for Heating:
5355 @handleNotSupported
56+ def getPowerConsumptionHeatingUnit (self ):
57+ return self .getProperty ("heating.power.consumption.heating" )["properties" ]["day" ]["unit" ]
58+
59+ @handleNotSupported
60+ def getPowerConsumptionHeatingToday (self ):
61+ return self .getProperty ("heating.power.consumption.heating" )["properties" ]["day" ]["value" ][0 ]
62+
63+ @handleNotSupported
64+ def getPowerConsumptionHeatingThisMonth (self ):
65+ return self .getProperty ("heating.power.consumption.heating" )["properties" ]["month" ]["value" ][0 ]
66+
67+ @handleNotSupported
68+ def getPowerConsumptionHeatingThisYear (self ):
69+ return self .getProperty ("heating.power.consumption.heating" )["properties" ]["year" ]["value" ][0 ]
70+
71+ # Power summary consumption for Heating:
72+ @handleNotSupported
5473 def getPowerSummaryConsumptionHeatingUnit (self ):
5574 return self .getProperty ("heating.power.consumption.summary.heating" )["properties" ]["currentDay" ]["unit" ]
5675
@@ -95,6 +114,7 @@ def getPowerConsumptionCoolingThisMonth(self):
95114 def getPowerConsumptionCoolingThisYear (self ):
96115 return self .getProperty ("heating.power.consumption.cooling" )["properties" ]["year" ]["value" ][0 ]
97116
117+ # Total power consumption:
98118 @handleNotSupported
99119 def getPowerConsumptionUnit (self ):
100120 return self .getProperty ("heating.power.consumption.total" )["properties" ]["day" ]["unit" ]
@@ -103,11 +123,32 @@ def getPowerConsumptionUnit(self):
103123 def getPowerConsumptionToday (self ):
104124 return self .getProperty ("heating.power.consumption.total" )["properties" ]["day" ]["value" ][0 ]
105125
126+ @handleNotSupported
127+ def getPowerConsumptionThisMonth (self ):
128+ return self .getProperty ("heating.power.consumption.total" )["properties" ]["month" ]["value" ][0 ]
129+
130+ @handleNotSupported
131+ def getPowerConsumptionThisYear (self ):
132+ return self .getProperty ("heating.power.consumption.total" )["properties" ]["year" ]["value" ][0 ]
133+
134+ # Power consumption for Domestic Hot Water:
135+ @handleNotSupported
136+ def getPowerConsumptionDomesticHotWaterUnit (self ):
137+ return self .getProperty ("heating.power.consumption.dhw" )["properties" ]["day" ]["unit" ]
138+
106139 @handleNotSupported
107140 def getPowerConsumptionDomesticHotWaterToday (self ):
108141 return self .getProperty ("heating.power.consumption.dhw" )["properties" ]["day" ]["value" ][0 ]
109142
110- # Power consumption for Domestic Hot Water:
143+ @handleNotSupported
144+ def getPowerConsumptionDomesticHotWaterThisMonth (self ):
145+ return self .getProperty ("heating.power.consumption.dhw" )["properties" ]["month" ]["value" ][0 ]
146+
147+ @handleNotSupported
148+ def getPowerConsumptionDomesticHotWaterThisYear (self ):
149+ return self .getProperty ("heating.power.consumption.dhw" )["properties" ]["year" ]["value" ][0 ]
150+
151+ # Power summary consumption for Domestic Hot Water:
111152 @handleNotSupported
112153 def getPowerSummaryConsumptionDomesticHotWaterUnit (self ):
113154 return self .getProperty ("heating.power.consumption.summary.dhw" )["properties" ]["currentDay" ]["unit" ]
@@ -320,6 +361,39 @@ def getHeatingRodPowerConsumptionHeatingThisYear(self) -> float:
320361 def getHeatingRodPowerConsumptionTotalThisYear (self ) -> float :
321362 return float (self .getProperty ("heating.heatingRod.power.consumption.total" )["properties" ]["year" ]["value" ][0 ])
322363
364+ # Cooling circuits
365+ @property
366+ def coolingCircuits (self ) -> List [CoolingCircuit ]:
367+ return [self .getCoolingCircuit (x ) for x in self .getAvailableCoolingCircuits ()]
368+
369+ def getCoolingCircuit (self , circuit ) -> CoolingCircuit :
370+ return CoolingCircuit (self , circuit )
371+
372+ def getAvailableCoolingCircuits (self ):
373+ """Detect available cooling circuits (0, 1, 2, etc.)."""
374+ available = []
375+ for circuit in ['0' , '1' , '2' , '3' ]:
376+ with suppress (KeyError , PyViCareNotSupportedFeatureError ):
377+ if self .getProperty (f"heating.coolingCircuits.{ circuit } .type" ) is not None :
378+ available .append (circuit )
379+ return available
380+
381+
382+ class CoolingCircuit (HeatingDeviceWithComponent ):
383+ """Cooling circuit component for heat pumps with cooling capability."""
384+
385+ @property
386+ def circuit (self ) -> str :
387+ return self .component
388+
389+ @handleNotSupported
390+ def getType (self ) -> str :
391+ return str (self .getProperty (f"heating.coolingCircuits.{ self .circuit } .type" )["properties" ]["value" ]["value" ])
392+
393+ @handleNotSupported
394+ def getReverseActive (self ) -> bool :
395+ return bool (self .getProperty (f"heating.coolingCircuits.{ self .circuit } .reverse" )["properties" ]["active" ]["value" ])
396+
323397
324398class Compressor (HeatingDeviceWithComponent ):
325399
0 commit comments