1 """The Aprilaire climate component."""
3 from __future__
import annotations
7 from pyaprilaire.const
import Attribute
25 PRESET_PERMANENT_HOLD,
26 PRESET_TEMPORARY_HOLD,
29 from .coordinator
import AprilaireConfigEntry
30 from .entity
import BaseAprilaireEntity
41 1: [HVACMode.OFF, HVACMode.HEAT],
42 2: [HVACMode.OFF, HVACMode.COOL],
43 3: [HVACMode.OFF, HVACMode.HEAT, HVACMode.COOL],
44 4: [HVACMode.OFF, HVACMode.HEAT, HVACMode.COOL],
45 5: [HVACMode.OFF, HVACMode.HEAT, HVACMode.COOL, HVACMode.AUTO],
46 6: [HVACMode.OFF, HVACMode.HEAT, HVACMode.COOL, HVACMode.AUTO],
50 1: PRESET_TEMPORARY_HOLD,
51 2: PRESET_PERMANENT_HOLD,
65 config_entry: AprilaireConfigEntry,
66 async_add_entities: AddEntitiesCallback,
68 """Add climates for passed config_entry in HA."""
76 """Climate entity for Aprilaire."""
78 _attr_fan_modes = [FAN_AUTO, FAN_ON, FAN_CIRCULATE]
79 _attr_min_humidity = 10
80 _attr_max_humidity = 50
81 _attr_temperature_unit = UnitOfTemperature.CELSIUS
82 _attr_translation_key =
"thermostat"
86 """Get the precision based on the unit."""
89 if self.
hasshasshass.config.units.temperature_unit == UnitOfTemperature.CELSIUS
95 """Get supported features."""
98 if self.coordinator.data.get(Attribute.MODE) == 5:
99 features = features | ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
101 features = features | ClimateEntityFeature.TARGET_TEMPERATURE
103 if self.coordinator.data.get(Attribute.HUMIDIFICATION_AVAILABLE) == 2:
104 features = features | ClimateEntityFeature.TARGET_HUMIDITY
106 features = features | ClimateEntityFeature.PRESET_MODE
108 return features | ClimateEntityFeature.FAN_MODE
112 """Get current humidity."""
113 return self.coordinator.data.get(
114 Attribute.INDOOR_HUMIDITY_CONTROLLING_SENSOR_VALUE
119 """Get current target humidity."""
120 return self.coordinator.data.get(Attribute.HUMIDIFICATION_SETPOINT)
126 if mode := self.coordinator.data.get(Attribute.MODE):
127 if hvac_mode := HVAC_MODE_MAP.get(mode):
134 """Get supported HVAC modes."""
136 if modes := self.coordinator.data.get(Attribute.THERMOSTAT_MODES):
137 if thermostat_modes := HVAC_MODES_MAP.get(modes):
138 return thermostat_modes
144 """Get the current HVAC action."""
146 if self.coordinator.data.get(Attribute.HEATING_EQUIPMENT_STATUS, 0):
147 return HVACAction.HEATING
149 if self.coordinator.data.get(Attribute.COOLING_EQUIPMENT_STATUS, 0):
150 return HVACAction.COOLING
152 return HVACAction.IDLE
156 """Get current temperature."""
157 return self.coordinator.data.get(
158 Attribute.INDOOR_TEMPERATURE_CONTROLLING_SENSOR_VALUE
163 """Get the target temperature."""
167 if hvac_mode == HVACMode.COOL:
169 if hvac_mode == HVACMode.HEAT:
176 """Get the step for the target temperature based on the unit."""
179 if self.
hasshasshass.config.units.temperature_unit == UnitOfTemperature.CELSIUS
185 """Get cool setpoint."""
186 return self.coordinator.data.get(Attribute.COOL_SETPOINT)
190 """Get heat setpoint."""
191 return self.coordinator.data.get(Attribute.HEAT_SETPOINT)
195 """Get the current preset mode."""
196 if hold := self.coordinator.data.get(Attribute.HOLD):
197 if preset_mode := PRESET_MODE_MAP.get(hold):
204 """Get the supported preset modes."""
205 presets = [PRESET_NONE, PRESET_VACATION]
207 if self.coordinator.data.get(Attribute.AWAY_AVAILABLE) == 1:
208 presets.append(PRESET_AWAY)
210 hold = self.coordinator.data.get(Attribute.HOLD, 0)
213 presets.append(PRESET_TEMPORARY_HOLD)
215 presets.append(PRESET_PERMANENT_HOLD)
223 if mode := self.coordinator.data.get(Attribute.FAN_MODE):
224 if fan_mode := FAN_MODE_MAP.get(mode):
230 """Set new target temperature."""
235 if temperature := kwargs.get(
"temperature"):
236 if self.coordinator.data.get(Attribute.MODE) == 3:
237 cool_setpoint = temperature
239 heat_setpoint = temperature
241 if target_temp_low := kwargs.get(
"target_temp_low"):
242 heat_setpoint = target_temp_low
243 if target_temp_high := kwargs.get(
"target_temp_high"):
244 cool_setpoint = target_temp_high
246 if cool_setpoint == 0
and heat_setpoint == 0:
249 await self.coordinator.client.update_setpoint(cool_setpoint, heat_setpoint)
251 await self.coordinator.client.read_control()
254 """Set the target humidification setpoint."""
256 await self.coordinator.client.set_humidification_setpoint(humidity)
259 """Set the fan mode."""
262 fan_mode_value_index =
list(FAN_MODE_MAP.values()).index(fan_mode)
263 except ValueError
as exc:
264 raise ValueError(f
"Unsupported fan mode {fan_mode}")
from exc
266 fan_mode_value =
list(FAN_MODE_MAP.keys())[fan_mode_value_index]
268 await self.coordinator.client.update_fan_mode(fan_mode_value)
270 await self.coordinator.client.read_control()
273 """Set the HVAC mode."""
276 mode_value_index =
list(HVAC_MODE_MAP.values()).index(hvac_mode)
277 except ValueError
as exc:
278 raise ValueError(f
"Unsupported HVAC mode {hvac_mode}")
from exc
280 mode_value =
list(HVAC_MODE_MAP.keys())[mode_value_index]
282 await self.coordinator.client.update_mode(mode_value)
284 await self.coordinator.client.read_control()
287 """Set the preset mode."""
289 if preset_mode == PRESET_AWAY:
290 await self.coordinator.client.set_hold(3)
291 elif preset_mode == PRESET_VACATION:
292 await self.coordinator.client.set_hold(4)
293 elif preset_mode == PRESET_NONE:
294 await self.coordinator.client.set_hold(0)
296 raise ValueError(f
"Unsupported preset mode {preset_mode}")
298 await self.coordinator.client.read_scheduling()
float|None target_temperature_high(self)
HVACMode|None hvac_mode(self)
None async_set_humidity(self, int humidity)
float|None target_temperature_step(self)
list[str]|None preset_modes(self)
float|None target_temperature_low(self)
float|None current_temperature(self)
None async_set_temperature(self, **Any kwargs)
int|None current_humidity(self)
HVACAction|None hvac_action(self)
int|None target_humidity(self)
ClimateEntityFeature supported_features(self)
None async_set_fan_mode(self, str fan_mode)
list[HVACMode] hvac_modes(self)
float|None target_temperature(self)
None async_set_hvac_mode(self, HVACMode hvac_mode)
str|None preset_mode(self)
None async_set_preset_mode(self, str preset_mode)
float|None target_temperature_low(self)
float|None target_temperature_high(self)
HVACMode|None hvac_mode(self)
None async_setup_entry(HomeAssistant hass, AprilaireConfigEntry config_entry, AddEntitiesCallback async_add_entities)