13
13
HVAC_MODE_OFF ,
14
14
PRESET_AWAY ,
15
15
PRESET_COMFORT ,
16
- PRESET_BOOST ,
17
16
PRESET_ECO ,
18
17
PRESET_NONE ,
19
18
SUPPORT_TARGET_TEMPERATURE ,
20
- #SUPPORT_TARGET_TEMPERATURE_RANGE,
21
19
SUPPORT_PRESET_MODE ,
20
+ DEFAULT_MAX_TEMP ,
21
+ DEFAULT_MIN_TEMP ,
22
22
)
23
23
from homeassistant .const import ATTR_TEMPERATURE , CONF_HOST , CONF_NAME , TEMP_CELSIUS
24
24
import homeassistant .helpers .config_validation as cv
34
34
ATTR_ON_OFF_TANK ,
35
35
ATTR_STATE_OFF ,
36
36
ATTR_STATE_ON ,
37
+ ATTR_CONTROL_MODE ,
38
+ ATTR_OPERATION_MODE ,
39
+ ATTR_TARGET_ROOM_TEMPERATURE ,
40
+ ATTR_TARGET_LEAVINGWATER_OFFSET ,
41
+ ATTR_TARGET_LEAVINGWATER_TEMPERATURE ,
37
42
)
38
43
39
44
_LOGGER = logging .getLogger (__name__ )
43
48
)
44
49
45
50
46
- PRESET_MODES = {PRESET_BOOST , PRESET_COMFORT , PRESET_ECO , PRESET_AWAY }
51
+ PRESET_MODES = {PRESET_COMFORT , PRESET_ECO , PRESET_AWAY }
47
52
48
53
HA_HVAC_TO_DAIKIN = {
49
54
HVAC_MODE_COOL : "cooling" ,
55
60
HA_ATTR_TO_DAIKIN = {
56
61
ATTR_PRESET_MODE : "en_hol" ,
57
62
ATTR_HVAC_MODE : "mode" ,
63
+ ATTR_LEAVINGWATER_OFFSET : "c" ,
58
64
ATTR_LEAVINGWATER_TEMPERATURE : "c" ,
59
65
ATTR_OUTSIDE_TEMPERATURE : "otemp" ,
60
66
ATTR_ROOM_TEMPERATURE : "stemp" ,
@@ -75,29 +81,33 @@ async def async_setup_entry(hass, entry, async_add_entities):
75
81
"""Set up Daikin climate based on config_entry."""
76
82
for dev_id , device in hass .data [DAIKIN_DOMAIN ][DAIKIN_DEVICES ].items ():
77
83
async_add_entities ([DaikinClimate (device )], update_before_add = True )
78
- # daikin_api = hass.data[DAIKIN_DOMAIN].get(entry.entry_id)
79
- # async_add_entities([DaikinClimate(daikin_api)], update_before_add=True)
80
84
81
85
82
86
class DaikinClimate (ClimateEntity ):
83
87
"""Representation of a Daikin HVAC."""
84
88
85
89
def __init__ (self , device ):
86
90
"""Initialize the climate device."""
87
- _LOGGER .info ("DAMIANO Initializing CLIMATE ..." )
91
+ _LOGGER .info ("Initializing Daiking Altherma ..." )
88
92
self ._device = device
89
93
self ._list = {
90
94
ATTR_HVAC_MODE : list (HA_HVAC_TO_DAIKIN ),
91
95
}
92
96
93
- # At the moment we have a separate room temperature we
94
- # can control that
95
- if self ._device .support_room_temperature :
97
+ # Check whether we can control the target temperature
98
+ controlMode = device .getValue (ATTR_CONTROL_MODE )
99
+ tempSettable = False
100
+ if controlMode == "roomTemperature" :
101
+ tempSettable = device .getData (ATTR_TARGET_ROOM_TEMPERATURE )["settable" ]
102
+ if controlMode in ("leavingWaterTemperature" , "externalRoomTemperature" ):
103
+ if device .getData (ATTR_TARGET_LEAVINGWATER_OFFSET ) is not None :
104
+ tempSettable = device .getData (ATTR_TARGET_LEAVINGWATER_OFFSET )["settable" ]
105
+ if device .getData (ATTR_TARGET_LEAVINGWATER_TEMPERATURE ) is not None :
106
+ tempSettable = device .getData (ATTR_TARGET_LEAVINGWATER_TEMPERATURE )["settable" ]
107
+ if tempSettable :
96
108
self ._supported_features = SUPPORT_TARGET_TEMPERATURE
97
- elif self ._device .support_leaving_water_offset :
98
- self ._supported_features = SUPPORT_TARGET_TEMPERATURE
99
- else :
100
- self ._supported_features = 0
109
+
110
+ _LOGGER .info ("Support features %s for controlMode %s" , self ._supported_features , controlMode )
101
111
102
112
self ._supported_preset_modes = [PRESET_NONE ]
103
113
self ._current_preset_mode = PRESET_NONE
@@ -106,7 +116,7 @@ def __init__(self, device):
106
116
if support_preset :
107
117
self ._supported_preset_modes .append (mode )
108
118
self ._supported_features |= SUPPORT_PRESET_MODE
109
- _LOGGER .info ("DAMIANO support_preset_mode {}: {}" .format (mode ,support_preset ))
119
+ _LOGGER .info ("Support_preset_mode {}: {}" .format (mode ,support_preset ))
110
120
111
121
async def _set (self , settings ):
112
122
"""Set device settings using API."""
@@ -129,12 +139,20 @@ async def _set(self, settings):
129
139
# temperature
130
140
elif attr == ATTR_TEMPERATURE :
131
141
try :
132
- if self ._device .support_room_temperature :
142
+ availableOperationModes = self ._device .getValidValues (ATTR_OPERATION_MODE )
143
+ operationMode = self ._device .getValue (ATTR_OPERATION_MODE )
144
+ if operationMode not in availableOperationModes :
145
+ return None
146
+
147
+ # Check which controlMode is used to control the device
148
+ controlMode = self ._device .getValue (ATTR_CONTROL_MODE )
149
+ if controlMode == "roomTemperature" :
133
150
values [HA_ATTR_TO_DAIKIN [ATTR_ROOM_TEMPERATURE ]] = str (int (value ))
134
- if self ._device .support_leaving_water_offset :
135
- values [HA_ATTR_TO_DAIKIN [ATTR_LEAVINGWATER_OFFSET ]] = str (int (value ))
136
- else :
137
- values [HA_ATTR_TO_DAIKIN [ATTR_LEAVINGWATER_TEMPERATURE ]] = str (int (value ))
151
+ if controlMode in ("leavingWaterTemperature" , "externalRoomTemperature" ):
152
+ if self ._device .getData (ATTR_TARGET_LEAVINGWATER_OFFSET ) is not None :
153
+ values [HA_ATTR_TO_DAIKIN [ATTR_LEAVINGWATER_OFFSET ]] = str (int (value ))
154
+ if self ._device .getData (ATTR_TARGET_LEAVINGWATER_TEMPERATURE ) is not None :
155
+ values [HA_ATTR_TO_DAIKIN [ATTR_LEAVINGWATER_TEMPERATURE ]] = str (int (value ))
138
156
except ValueError :
139
157
_LOGGER .error ("Invalid temperature %s" , value )
140
158
@@ -171,41 +189,100 @@ def temperature_unit(self):
171
189
@property
172
190
def current_temperature (self ):
173
191
"""Return the current temperature."""
192
+ # Check which controlMode is used to control the device
193
+ controlMode = self ._device .getValue (ATTR_CONTROL_MODE )
194
+ currentTemp = None
174
195
# At the moment the device supports a separate
175
196
# room temperature do return that
176
- if self . _device . support_room_temperature :
177
- return self ._device .room_temperature
178
- if self . _device . support_leaving_water_offset :
179
- return self ._device .leaving_water_offset
180
- else :
181
- return self . _device . leaving_water_temperature
197
+ if controlMode == "roomTemperature" :
198
+ currentTemp = self ._device .getValue ( ATTR_ROOM_TEMPERATURE )
199
+ if controlMode in ( "leavingWaterTemperature" , "externalRoomTemperature" ) :
200
+ currentTemp = self ._device .getValue ( ATTR_LEAVINGWATER_TEMPERATURE )
201
+ _LOGGER . debug ( "Current temperature: %s" , currentTemp )
202
+ return currentTemp
182
203
183
204
@property
184
205
def max_temp (self ):
185
206
"""Return the maximum temperature we are allowed to set."""
186
- return self ._device .max_temp
207
+ availableOperationModes = self ._device .getValidValues (ATTR_OPERATION_MODE )
208
+ operationMode = self ._device .getValue (ATTR_OPERATION_MODE )
209
+ if operationMode not in availableOperationModes :
210
+ return DEFAULT_MAX_TEMP
211
+
212
+ # Check which controlMode is used to control the device
213
+ controlMode = self ._device .getValue (ATTR_CONTROL_MODE )
214
+ maxTemp = DEFAULT_MAX_TEMP
215
+ if controlMode == "roomTemperature" :
216
+ maxTemp = float (self ._device .getData (ATTR_TARGET_ROOM_TEMPERATURE )["maxValue" ])
217
+ if controlMode in ("leavingWaterTemperature" , "externalRoomTemperature" ):
218
+ if self ._device .getData (ATTR_TARGET_LEAVINGWATER_OFFSET ) is not None :
219
+ maxTemp = float (self ._device .getData (ATTR_TARGET_LEAVINGWATER_OFFSET )["maxValue" ])
220
+ if self ._device .getData (ATTR_TARGET_LEAVINGWATER_TEMPERATURE ) is not None :
221
+ maxTemp = float (self ._device .getData (ATTR_TARGET_LEAVINGWATER_TEMPERATURE )["maxValue" ])
222
+ _LOGGER .debug ("Max temperature: %s" , maxTemp )
223
+ return maxTemp
187
224
188
225
@property
189
226
def min_temp (self ):
190
227
"""Return the minimum temperature we are allowed to set."""
191
- return self ._device .min_temp
228
+ availableOperationModes = self ._device .getValidValues (ATTR_OPERATION_MODE )
229
+ operationMode = self ._device .getValue (ATTR_OPERATION_MODE )
230
+ if operationMode not in availableOperationModes :
231
+ return DEFAULT_MIN_TEMP
232
+
233
+ # Check which controlMode is used to control the device
234
+ controlMode = self ._device .getValue (ATTR_CONTROL_MODE )
235
+ minTemp = DEFAULT_MIN_TEMP
236
+ if controlMode == "roomTemperature" :
237
+ minTemp = float (self ._device .getData (ATTR_TARGET_ROOM_TEMPERATURE )["minValue" ])
238
+ if controlMode in ("leavingWaterTemperature" , "externalRoomTemperature" ):
239
+ if self ._device .getData (ATTR_TARGET_LEAVINGWATER_OFFSET ) is not None :
240
+ minTemp = float (self ._device .getData (ATTR_TARGET_LEAVINGWATER_OFFSET )["minValue" ])
241
+ if self ._device .getData (ATTR_TARGET_LEAVINGWATER_TEMPERATURE ) is not None :
242
+ minTemp = float (self ._device .getData (ATTR_TARGET_LEAVINGWATER_TEMPERATURE )["minValue" ])
243
+ _LOGGER .debug ("Min temperature: %s" , minTemp )
244
+ return minTemp
192
245
193
246
@property
194
247
def target_temperature (self ):
195
248
"""Return the temperature we try to reach."""
196
- if self ._device .support_room_temperature :
197
- return self ._device .target_temperature
198
-
199
- if self ._device .support_leaving_water_offset :
200
- return self ._device .leaving_water_offset
201
-
202
- else :
249
+ availableOperationModes = self ._device .getValidValues (ATTR_OPERATION_MODE )
250
+ operationMode = self ._device .getValue (ATTR_OPERATION_MODE )
251
+ if operationMode not in availableOperationModes :
203
252
return None
253
+ # Check which controlMode is used to control the device
254
+ controlMode = self ._device .getValue (ATTR_CONTROL_MODE )
255
+ targetTemp = None
256
+ if controlMode == "roomTemperature" :
257
+ targetTemp = float (self ._device .getValue (ATTR_TARGET_ROOM_TEMPERATURE ))
258
+ if controlMode in ("leavingWaterTemperature" , "externalRoomTemperature" ):
259
+ if self ._device .getData (ATTR_TARGET_LEAVINGWATER_OFFSET ) is not None :
260
+ targetTemp = float (self ._device .getValue (ATTR_TARGET_LEAVINGWATER_OFFSET ))
261
+ if self ._device .getData (ATTR_TARGET_LEAVINGWATER_TEMPERATURE ) is not None :
262
+ targetTemp = float (self ._device .getValue (ATTR_TARGET_LEAVINGWATER_TEMPERATURE ))
263
+ _LOGGER .debug ("Target temperature: %s" , targetTemp )
264
+ return targetTemp
204
265
205
266
@property
206
267
def target_temperature_step (self ):
207
- """Return the supported step of target temperature."""
208
- return self ._device .target_temperature_step
268
+ """Return current target temperature step."""
269
+ availableOperationModes = self ._device .getValidValues (ATTR_OPERATION_MODE )
270
+ operationMode = self ._device .getValue (ATTR_OPERATION_MODE )
271
+ if operationMode not in availableOperationModes :
272
+ return None
273
+
274
+ # Check which controlMode is used to control the device
275
+ controlMode = self ._device .getValue (ATTR_CONTROL_MODE )
276
+ tempStep = None
277
+ if controlMode == "roomTemperature" :
278
+ tempStep = float (self ._device .getData (ATTR_TARGET_ROOM_TEMPERATURE )["stepValue" ])
279
+ if controlMode in ("leavingWaterTemperature" , "externalRoomTemperature" ):
280
+ if self ._device .getData (ATTR_TARGET_LEAVINGWATER_OFFSET ) is not None :
281
+ tempStep = float (self ._device .getData (ATTR_TARGET_LEAVINGWATER_OFFSET )["stepValue" ])
282
+ if self ._device .getData (ATTR_TARGET_LEAVINGWATER_TEMPERATURE ) is not None :
283
+ tempStep = float (self ._device .getData (ATTR_TARGET_LEAVINGWATER_TEMPERATURE )["stepValue" ])
284
+ _LOGGER .debug ("Step temperature: %s" , tempStep )
285
+ return tempStep
209
286
210
287
async def async_set_temperature (self , ** kwargs ):
211
288
"""Set new target temperature."""
@@ -267,16 +344,6 @@ async def async_turn_off(self):
267
344
"""Turn device CLIMATE off."""
268
345
await self ._device .setValue (ATTR_ON_OFF_CLIMATE , ATTR_STATE_OFF )
269
346
270
- # async def async_turn_tank_on(self):
271
- # """Turn device TANK on."""
272
- # print("DAMIANO {} to on".format(self._device))
273
- # await self._device.setValue(ATTR_ON_OFF_TANK, ATTR_STATE_ON)
274
-
275
- # async def async_turn_tank_off(self):
276
- # """Turn device TANK off."""
277
- # print("DAMIANO {} to off".format(self._device))
278
- # await self._device.setValue(ATTR_ON_OFF_TANK, ATTR_STATE_OFF)
279
-
280
347
@property
281
348
def device_info (self ):
282
349
"""Return a device description for device registry."""
0 commit comments