Skip to content

Commit 9eedb11

Browse files
authored
Merge branch 'speleolontra:master' into master
2 parents 852a8a6 + b6a08c9 commit 9eedb11

File tree

12 files changed

+507
-732
lines changed

12 files changed

+507
-732
lines changed
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: Issue report
3+
about: Create a report to help us improve
4+
title: '[Issue]: '
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
<!-- When reporting an issue always attach the device diagnostics (see Settings/Device&Services/Daikin Residential Controller for Altherma/Download diagnostics). Remove all tokens and passwords from the device diagnostics before attaching it to this issue. When you have an issue about missing or incorrect data compared to the Onecta app please attach also some screenshots of the Onecta app. -->

custom_components/daikin_residential_altherma/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
MIN_TIME_BETWEEN_UPDATES = datetime.timedelta(seconds=2)
3030

31-
COMPONENT_TYPES = ["climate", "sensor", "switch"]
31+
COMPONENT_TYPES = ["climate", "sensor", "water_heater"]
3232

3333

3434
CONFIG_SCHEMA = vol.Schema(

custom_components/daikin_residential_altherma/climate.py

+113-46
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
HVAC_MODE_OFF,
1414
PRESET_AWAY,
1515
PRESET_COMFORT,
16-
PRESET_BOOST,
1716
PRESET_ECO,
1817
PRESET_NONE,
1918
SUPPORT_TARGET_TEMPERATURE,
20-
#SUPPORT_TARGET_TEMPERATURE_RANGE,
2119
SUPPORT_PRESET_MODE,
20+
DEFAULT_MAX_TEMP,
21+
DEFAULT_MIN_TEMP,
2222
)
2323
from homeassistant.const import ATTR_TEMPERATURE, CONF_HOST, CONF_NAME, TEMP_CELSIUS
2424
import homeassistant.helpers.config_validation as cv
@@ -34,6 +34,11 @@
3434
ATTR_ON_OFF_TANK,
3535
ATTR_STATE_OFF,
3636
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,
3742
)
3843

3944
_LOGGER = logging.getLogger(__name__)
@@ -43,7 +48,7 @@
4348
)
4449

4550

46-
PRESET_MODES = {PRESET_BOOST, PRESET_COMFORT, PRESET_ECO, PRESET_AWAY}
51+
PRESET_MODES = {PRESET_COMFORT, PRESET_ECO, PRESET_AWAY}
4752

4853
HA_HVAC_TO_DAIKIN = {
4954
HVAC_MODE_COOL: "cooling",
@@ -55,6 +60,7 @@
5560
HA_ATTR_TO_DAIKIN = {
5661
ATTR_PRESET_MODE: "en_hol",
5762
ATTR_HVAC_MODE: "mode",
63+
ATTR_LEAVINGWATER_OFFSET: "c",
5864
ATTR_LEAVINGWATER_TEMPERATURE: "c",
5965
ATTR_OUTSIDE_TEMPERATURE: "otemp",
6066
ATTR_ROOM_TEMPERATURE: "stemp",
@@ -75,29 +81,33 @@ async def async_setup_entry(hass, entry, async_add_entities):
7581
"""Set up Daikin climate based on config_entry."""
7682
for dev_id, device in hass.data[DAIKIN_DOMAIN][DAIKIN_DEVICES].items():
7783
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)
8084

8185

8286
class DaikinClimate(ClimateEntity):
8387
"""Representation of a Daikin HVAC."""
8488

8589
def __init__(self, device):
8690
"""Initialize the climate device."""
87-
_LOGGER.info("DAMIANO Initializing CLIMATE...")
91+
_LOGGER.info("Initializing Daiking Altherma...")
8892
self._device = device
8993
self._list = {
9094
ATTR_HVAC_MODE: list(HA_HVAC_TO_DAIKIN),
9195
}
9296

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:
96108
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)
101111

102112
self._supported_preset_modes = [PRESET_NONE]
103113
self._current_preset_mode = PRESET_NONE
@@ -106,7 +116,7 @@ def __init__(self, device):
106116
if support_preset:
107117
self._supported_preset_modes.append(mode)
108118
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))
110120

111121
async def _set(self, settings):
112122
"""Set device settings using API."""
@@ -129,12 +139,20 @@ async def _set(self, settings):
129139
# temperature
130140
elif attr == ATTR_TEMPERATURE:
131141
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":
133150
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))
138156
except ValueError:
139157
_LOGGER.error("Invalid temperature %s", value)
140158

@@ -171,41 +189,100 @@ def temperature_unit(self):
171189
@property
172190
def current_temperature(self):
173191
"""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
174195
# At the moment the device supports a separate
175196
# 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
182203

183204
@property
184205
def max_temp(self):
185206
"""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
187224

188225
@property
189226
def min_temp(self):
190227
"""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
192245

193246
@property
194247
def target_temperature(self):
195248
"""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:
203252
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
204265

205266
@property
206267
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
209286

210287
async def async_set_temperature(self, **kwargs):
211288
"""Set new target temperature."""
@@ -267,16 +344,6 @@ async def async_turn_off(self):
267344
"""Turn device CLIMATE off."""
268345
await self._device.setValue(ATTR_ON_OFF_CLIMATE, ATTR_STATE_OFF)
269346

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-
280347
@property
281348
def device_info(self):
282349
"""Return a device description for device registry."""

0 commit comments

Comments
 (0)