/
PyViCareHeatPump.py
195 lines (150 loc) · 8.32 KB
/
PyViCareHeatPump.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
from contextlib import suppress
from typing import Any, List
from PyViCare.PyViCareHeatingDevice import (HeatingDevice,
HeatingDeviceWithComponent)
from PyViCare.PyViCareUtils import PyViCareNotSupportedFeatureError, handleNotSupported
class HeatPump(HeatingDevice):
@property
def compressors(self) -> List[Any]:
return list([self.getCompressor(x) for x in self.getAvailableCompressors()])
def getCompressor(self, compressor):
return Compressor(self, compressor)
@handleNotSupported
def getAvailableCompressors(self):
return self.service.getProperty("heating.compressors")["properties"]["enabled"]["value"]
@handleNotSupported
def getBufferMainTemperature(self):
return self.service.getProperty("heating.buffer.sensors.temperature.main")["properties"]['value']['value']
@handleNotSupported
def getBufferTopTemperature(self):
return self.service.getProperty("heating.buffer.sensors.temperature.top")["properties"]['value']['value']
# Power consumption for Heating:
@handleNotSupported
def getPowerSummaryConsumptionHeatingUnit(self):
return self.service.getProperty("heating.power.consumption.summary.heating")["properties"]["currentDay"]["unit"]
@handleNotSupported
def getPowerSummaryConsumptionHeatingCurrentDay(self):
return self.service.getProperty("heating.power.consumption.summary.heating")["properties"]["currentDay"]["value"]
@handleNotSupported
def getPowerSummaryConsumptionHeatingCurrentMonth(self):
return self.service.getProperty("heating.power.consumption.summary.heating")["properties"]["currentMonth"]["value"]
@handleNotSupported
def getPowerSummaryConsumptionHeatingCurrentYear(self):
return self.service.getProperty("heating.power.consumption.summary.heating")["properties"]["currentYear"]["value"]
@handleNotSupported
def getPowerSummaryConsumptionHeatingLastMonth(self):
return self.service.getProperty("heating.power.consumption.summary.heating")["properties"]["lastMonth"]["value"]
@handleNotSupported
def getPowerSummaryConsumptionHeatingLastSevenDays(self):
return self.service.getProperty("heating.power.consumption.summary.heating")["properties"]["lastSevenDays"]["value"]
@handleNotSupported
def getPowerSummaryConsumptionHeatingLastYear(self):
return self.service.getProperty("heating.power.consumption.summary.heating")["properties"]["lastYear"]["value"]
@handleNotSupported
def getPowerConsumptionUnit(self):
return self.service.getProperty("heating.power.consumption.total")["properties"]["day"]["unit"]
@handleNotSupported
def getPowerConsumptionToday(self):
return self.service.getProperty("heating.power.consumption.total")["properties"]["day"]["value"][0]
@handleNotSupported
def getPowerConsumptionDomesticHotWaterToday(self):
return self.service.getProperty("heating.power.consumption.dhw")["properties"]["day"]["value"][0]
# Power consumption for Domestic Hot Water:
@handleNotSupported
def getPowerSummaryConsumptionDomesticHotWaterUnit(self):
return self.service.getProperty("heating.power.consumption.summary.dhw")["properties"]["currentDay"]["unit"]
@handleNotSupported
def getPowerSummaryConsumptionDomesticHotWaterCurrentDay(self):
return self.service.getProperty("heating.power.consumption.summary.dhw")["properties"]["currentDay"]["value"]
@handleNotSupported
def getPowerSummaryConsumptionDomesticHotWaterCurrentMonth(self):
return self.service.getProperty("heating.power.consumption.summary.dhw")["properties"]["currentMonth"]["value"]
@handleNotSupported
def getPowerSummaryConsumptionDomesticHotWaterCurrentYear(self):
return self.service.getProperty("heating.power.consumption.summary.dhw")["properties"]["currentYear"]["value"]
@handleNotSupported
def getPowerSummaryConsumptionDomesticHotWaterLastMonth(self):
return self.service.getProperty("heating.power.consumption.summary.dhw")["properties"]["lastMonth"]["value"]
@handleNotSupported
def getPowerSummaryConsumptionDomesticHotWaterLastSevenDays(self):
return self.service.getProperty("heating.power.consumption.summary.dhw")["properties"]["lastSevenDays"]["value"]
@handleNotSupported
def getPowerSummaryConsumptionDomesticHotWaterLastYear(self):
return self.service.getProperty("heating.power.consumption.summary.dhw")["properties"]["lastYear"]["value"]
@handleNotSupported
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):
@property
def compressor(self) -> str:
return self.component
@handleNotSupported
def getStarts(self):
return self.service.getProperty(f"heating.compressors.{self.compressor}.statistics")["properties"]["starts"]["value"]
@handleNotSupported
def getHours(self):
return self.service.getProperty(f"heating.compressors.{self.compressor}.statistics")["properties"]["hours"]["value"]
@handleNotSupported
def getHoursLoadClass1(self):
return self.service.getProperty(f"heating.compressors.{self.compressor}.statistics")["properties"]["hoursLoadClassOne"]["value"]
@handleNotSupported
def getHoursLoadClass2(self):
return self.service.getProperty(f"heating.compressors.{self.compressor}.statistics")["properties"]["hoursLoadClassTwo"]["value"]
@handleNotSupported
def getHoursLoadClass3(self):
return self.service.getProperty(f"heating.compressors.{self.compressor}.statistics")["properties"]["hoursLoadClassThree"]["value"]
@handleNotSupported
def getHoursLoadClass4(self):
return self.service.getProperty(f"heating.compressors.{self.compressor}.statistics")["properties"]["hoursLoadClassFour"]["value"]
@handleNotSupported
def getHoursLoadClass5(self):
return self.service.getProperty(f"heating.compressors.{self.compressor}.statistics")["properties"]["hoursLoadClassFive"]["value"]
@handleNotSupported
def getActive(self):
return self.service.getProperty(f"heating.compressors.{self.compressor}")["properties"]["active"]["value"]
@handleNotSupported
def getPhase(self):
return self.service.getProperty(f"heating.compressors.{self.compressor}")["properties"]["phase"]["value"]