1 """Support for HomematicIP Cloud climate devices."""
3 from __future__
import annotations
7 from homematicip.aio.device
import (
8 AsyncHeatingThermostat,
9 AsyncHeatingThermostatCompact,
10 AsyncHeatingThermostatEvo,
12 from homematicip.aio.group
import AsyncHeatingGroup
13 from homematicip.base.enums
import AbsenceType
14 from homematicip.device
import Switch
15 from homematicip.functionalHomes
import IndoorClimateHome
16 from homematicip.group
import HeatingCoolingProfile
34 from .const
import DOMAIN
35 from .entity
import HomematicipGenericEntity
36 from .hap
import HomematicipHAP
38 HEATING_PROFILES = {
"PROFILE_1": 0,
"PROFILE_2": 1,
"PROFILE_3": 2}
39 COOLING_PROFILES = {
"PROFILE_4": 3,
"PROFILE_5": 4,
"PROFILE_6": 5}
40 NICE_PROFILE_NAMES = {
41 "PROFILE_1":
"Default",
42 "PROFILE_2":
"Alternative 1",
43 "PROFILE_3":
"Alternative 2",
44 "PROFILE_4":
"Cooling 1",
45 "PROFILE_5":
"Cooling 2",
46 "PROFILE_6":
"Cooling 3",
49 ATTR_PRESET_END_TIME =
"preset_end_time"
50 PERMANENT_END_TIME =
"permanent"
52 HMIP_AUTOMATIC_CM =
"AUTOMATIC"
53 HMIP_MANUAL_CM =
"MANUAL"
59 config_entry: ConfigEntry,
60 async_add_entities: AddEntitiesCallback,
62 """Set up the HomematicIP climate from a config entry."""
63 hap = hass.data[DOMAIN][config_entry.unique_id]
67 for device
in hap.home.groups
68 if isinstance(device, AsyncHeatingGroup)
73 """Representation of the HomematicIP heating group.
75 Heat mode is supported for all heating devices incl. their defined profiles.
76 Boost is available for radiator thermostats only.
77 Cool mode is only available for floor heating systems, if basically enabled in the hmip app.
80 _attr_supported_features = (
81 ClimateEntityFeature.PRESET_MODE | ClimateEntityFeature.TARGET_TEMPERATURE
83 _attr_temperature_unit = UnitOfTemperature.CELSIUS
84 _enable_turn_on_off_backwards_compatibility =
False
86 def __init__(self, hap: HomematicipHAP, device: AsyncHeatingGroup) ->
None:
87 """Initialize heating group."""
88 device.modelType =
"HmIP-Heating-Group"
91 if device.actualTemperature
is None:
96 """Return device specific attributes."""
98 identifiers={(DOMAIN, self.
_device_device.id)},
100 model=self.
_device_device.modelType,
101 name=self.
_device_device.label,
102 via_device=(DOMAIN, self.
_device_device.homeId),
107 """Return the temperature we try to reach."""
108 return self.
_device_device.setPointTemperature
112 """Return the current temperature."""
115 return self.
_device_device.actualTemperature
119 """Return the current humidity."""
120 return self.
_device_device.humidity
124 """Return hvac operation ie."""
127 if self.
_device_device.boostMode:
129 if self.
_device_device.controlMode == HMIP_MANUAL_CM:
136 """Return the list of available hvac operation modes."""
138 return [HVACMode.OFF]
141 return [HVACMode.AUTO, HVACMode.HEAT]
142 return [HVACMode.AUTO, HVACMode.COOL]
146 """Return the current hvac_action.
148 This is only relevant for radiator thermostats.
151 self.
_device_device.floorHeatingMode ==
"RADIATOR"
155 return HVACAction.HEATING
if self.
_device_device.valvePosition
else HVACAction.IDLE
161 """Return the current preset mode."""
162 if self.
_device_device.boostMode:
166 if self.
_device_device.controlMode == HMIP_ECO_CM:
167 if self.
_indoor_climate_indoor_climate.absenceType == AbsenceType.VACATION:
172 AbsenceType.PERMANENT,
185 """Return a list of available preset modes incl. hmip profiles."""
194 if not profile_names:
195 presets.append(PRESET_NONE)
196 presets.extend([PRESET_BOOST, PRESET_ECO])
198 presets.extend(profile_names)
204 """Return the minimum temperature."""
205 return self.
_device_device.minTemperature
209 """Return the maximum temperature."""
210 return self.
_device_device.maxTemperature
213 """Set new target temperature."""
214 if (temperature := kwargs.get(ATTR_TEMPERATURE))
is None:
218 await self.
_device_device.set_point_temperature(temperature)
221 """Set new target hvac mode."""
225 if hvac_mode == HVACMode.AUTO:
226 await self.
_device_device.set_control_mode(HMIP_AUTOMATIC_CM)
228 await self.
_device_device.set_control_mode(HMIP_MANUAL_CM)
231 """Set new preset mode."""
232 if self.
_device_device.boostMode
and preset_mode != PRESET_BOOST:
233 await self.
_device_device.set_boost(
False)
234 if preset_mode == PRESET_BOOST:
235 await self.
_device_device.set_boost()
236 if preset_mode == PRESET_ECO:
237 await self.
_device_device.set_control_mode(HMIP_ECO_CM)
240 if self.
_device_device.controlMode != HMIP_AUTOMATIC_CM:
242 await self.
_device_device.set_active_profile(profile_idx)
246 """Return the state attributes of the access point."""
247 state_attr = super().extra_state_attributes
249 if self.
_device_device.controlMode == HMIP_ECO_CM:
253 AbsenceType.VACATION,
255 state_attr[ATTR_PRESET_END_TIME] = self.
_indoor_climate_indoor_climate.absenceEndTime
256 elif self.
_indoor_climate_indoor_climate.absenceType == AbsenceType.PERMANENT:
257 state_attr[ATTR_PRESET_END_TIME] = PERMANENT_END_TIME
263 """Return the hmip indoor climate functional home of this group."""
264 return self._home.get_functionalHome(IndoorClimateHome)
268 """Return the relevant profiles."""
271 for profile
in self.
_device_device.profiles
277 """Return a collection of profile names."""
284 """Get a name for the given profile. If exists, this is the name of the profile."""
285 if profile.name !=
"":
287 if profile.index
in NICE_PROFILE_NAMES:
288 return NICE_PROFILE_NAMES[profile.index]
293 """Return a profile index by name."""
301 return relevant_index[index_name[0]]
305 """Return, if heating mode is enabled."""
306 return not self.
_device_device.cooling
310 """Return, if group is disabled by the cooling mode."""
311 return self.
_device_device.cooling
and (
312 self.
_device_device.coolingIgnored
or not self.
_device_device.coolingAllowed
317 """Return the relevant profile groups."""
321 return HEATING_PROFILES
if self.
_heat_mode_enabled_heat_mode_enabled
else COOLING_PROFILES
325 """Return, if a switch is in the hmip heating group."""
326 return any(isinstance(device, Switch)
for device
in self.
_device_device.devices)
330 """Return, if a radiator thermostat is in the hmip heating group."""
337 AsyncHeatingThermostat
338 | AsyncHeatingThermostatCompact
339 | AsyncHeatingThermostatEvo
342 """Return the first radiator thermostat from the hmip heating group."""
343 for device
in self.
_device_device.devices:
347 AsyncHeatingThermostat,
348 AsyncHeatingThermostatCompact,
349 AsyncHeatingThermostatEvo,
None async_set_hvac_mode(self, HVACMode hvac_mode)
HVACMode|None hvac_mode(self)
list[HVACMode] hvac_modes(self)
list[HVACMode] hvac_modes(self)
None async_set_preset_mode(self, str preset_mode)
list[str] _device_profile_names(self)
dict[str, int] _relevant_profile_group(self)
list[HeatingCoolingProfile] _device_profiles(self)
str|None preset_mode(self)
IndoorClimateHome _indoor_climate(self)
str _get_qualified_profile_name(self, HeatingCoolingProfile profile)
dict[str, Any] extra_state_attributes(self)
( AsyncHeatingThermostat|AsyncHeatingThermostatCompact|AsyncHeatingThermostatEvo|None) _first_radiator_thermostat(self)
int current_humidity(self)
float target_temperature(self)
None async_set_temperature(self, **Any kwargs)
int _get_profile_idx_by_name(self, str profile_name)
bool _disabled_by_cooling_mode(self)
DeviceInfo device_info(self)
bool _has_radiator_thermostat(self)
None async_set_hvac_mode(self, HVACMode hvac_mode)
list[str] preset_modes(self)
float current_temperature(self)
HVACAction|None hvac_action(self)
bool _heat_mode_enabled(self)
None __init__(self, HomematicipHAP hap, AsyncHeatingGroup device)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)