diff --git a/homeassistant/components/honeywell/climate.py b/homeassistant/components/honeywell/climate.py index fc9a1b9b03c..5c238d73e0b 100644 --- a/homeassistant/components/honeywell/climate.py +++ b/homeassistant/components/honeywell/climate.py @@ -6,25 +6,20 @@ from typing import Any import somecomfort -from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature +from homeassistant.components.climate import ClimateEntity from homeassistant.components.climate.const import ( ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, - CURRENT_HVAC_COOL, - CURRENT_HVAC_FAN, - CURRENT_HVAC_HEAT, - CURRENT_HVAC_IDLE, DEFAULT_MAX_TEMP, DEFAULT_MIN_TEMP, FAN_AUTO, FAN_DIFFUSE, FAN_ON, - HVAC_MODE_COOL, - HVAC_MODE_HEAT, - HVAC_MODE_HEAT_COOL, - HVAC_MODE_OFF, PRESET_AWAY, PRESET_NONE, + ClimateEntityFeature, + HVACAction, + HVACMode, ) from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT @@ -42,23 +37,23 @@ ATTR_PERMANENT_HOLD = "permanent_hold" PRESET_HOLD = "Hold" HVAC_MODE_TO_HW_MODE = { - "SwitchOffAllowed": {HVAC_MODE_OFF: "off"}, - "SwitchAutoAllowed": {HVAC_MODE_HEAT_COOL: "auto"}, - "SwitchCoolAllowed": {HVAC_MODE_COOL: "cool"}, - "SwitchHeatAllowed": {HVAC_MODE_HEAT: "heat"}, + "SwitchOffAllowed": {HVACMode.OFF: "off"}, + "SwitchAutoAllowed": {HVACMode.HEAT_COOL: "auto"}, + "SwitchCoolAllowed": {HVACMode.COOL: "cool"}, + "SwitchHeatAllowed": {HVACMode.HEAT: "heat"}, } HW_MODE_TO_HVAC_MODE = { - "off": HVAC_MODE_OFF, - "emheat": HVAC_MODE_HEAT, - "heat": HVAC_MODE_HEAT, - "cool": HVAC_MODE_COOL, - "auto": HVAC_MODE_HEAT_COOL, + "off": HVACMode.OFF, + "emheat": HVACMode.HEAT, + "heat": HVACMode.HEAT, + "cool": HVACMode.COOL, + "auto": HVACMode.HEAT_COOL, } HW_MODE_TO_HA_HVAC_ACTION = { - "off": CURRENT_HVAC_IDLE, - "fan": CURRENT_HVAC_FAN, - "heat": CURRENT_HVAC_HEAT, - "cool": CURRENT_HVAC_COOL, + "off": HVACAction.IDLE, + "fan": HVACAction.FAN, + "heat": HVACAction.HEATING, + "cool": HVACAction.COOLING, } FAN_MODE_TO_HW = { "fanModeOnAllowed": {FAN_ON: "on"}, @@ -150,18 +145,18 @@ class HoneywellUSThermostat(ClimateEntity): @property def min_temp(self) -> float: """Return the minimum temperature.""" - if self.hvac_mode in [HVAC_MODE_COOL, HVAC_MODE_HEAT_COOL]: + if self.hvac_mode in [HVACMode.COOL, HVACMode.HEAT_COOL]: return self._device.raw_ui_data["CoolLowerSetptLimit"] - if self.hvac_mode == HVAC_MODE_HEAT: + if self.hvac_mode == HVACMode.HEAT: return self._device.raw_ui_data["HeatLowerSetptLimit"] return DEFAULT_MIN_TEMP @property def max_temp(self) -> float: """Return the maximum temperature.""" - if self.hvac_mode == HVAC_MODE_COOL: + if self.hvac_mode == HVACMode.COOL: return self._device.raw_ui_data["CoolUpperSetptLimit"] - if self.hvac_mode in [HVAC_MODE_HEAT, HVAC_MODE_HEAT_COOL]: + if self.hvac_mode in [HVACMode.HEAT, HVACMode.HEAT_COOL]: return self._device.raw_ui_data["HeatUpperSetptLimit"] return DEFAULT_MAX_TEMP @@ -171,14 +166,14 @@ class HoneywellUSThermostat(ClimateEntity): return self._device.current_humidity @property - def hvac_mode(self) -> str: + def hvac_mode(self) -> HVACMode: """Return hvac operation ie. heat, cool mode.""" return HW_MODE_TO_HVAC_MODE[self._device.system_mode] @property - def hvac_action(self) -> str | None: + def hvac_action(self) -> HVACAction | None: """Return the current running hvac operation if supported.""" - if self.hvac_mode == HVAC_MODE_OFF: + if self.hvac_mode == HVACMode.OFF: return None return HW_MODE_TO_HA_HVAC_ACTION[self._device.equipment_output_status] @@ -190,23 +185,23 @@ class HoneywellUSThermostat(ClimateEntity): @property def target_temperature(self) -> float | None: """Return the temperature we try to reach.""" - if self.hvac_mode == HVAC_MODE_COOL: + if self.hvac_mode == HVACMode.COOL: return self._device.setpoint_cool - if self.hvac_mode == HVAC_MODE_HEAT: + if self.hvac_mode == HVACMode.HEAT: return self._device.setpoint_heat return None @property def target_temperature_high(self) -> float | None: """Return the highbound target temperature we try to reach.""" - if self.hvac_mode == HVAC_MODE_HEAT_COOL: + if self.hvac_mode == HVACMode.HEAT_COOL: return self._device.setpoint_cool return None @property def target_temperature_low(self) -> float | None: """Return the lowbound target temperature we try to reach.""" - if self.hvac_mode == HVAC_MODE_HEAT_COOL: + if self.hvac_mode == HVACMode.HEAT_COOL: return self._device.setpoint_heat return None @@ -254,11 +249,11 @@ class HoneywellUSThermostat(ClimateEntity): def set_temperature(self, **kwargs) -> None: """Set new target temperature.""" - if {HVAC_MODE_COOL, HVAC_MODE_HEAT} & set(self._hvac_mode_map): + if {HVACMode.COOL, HVACMode.HEAT} & set(self._hvac_mode_map): self._set_temperature(**kwargs) try: - if HVAC_MODE_HEAT_COOL in self._hvac_mode_map: + if HVACMode.HEAT_COOL in self._hvac_mode_map: if temperature := kwargs.get(ATTR_TARGET_TEMP_HIGH): self._device.setpoint_cool = temperature if temperature := kwargs.get(ATTR_TARGET_TEMP_LOW): @@ -270,7 +265,7 @@ class HoneywellUSThermostat(ClimateEntity): """Set new target fan mode.""" self._device.fan_mode = self._fan_mode_map[fan_mode] - def set_hvac_mode(self, hvac_mode: str) -> None: + def set_hvac_mode(self, hvac_mode: HVACMode) -> None: """Set new target hvac mode.""" self._device.system_mode = self._hvac_mode_map[hvac_mode] @@ -347,10 +342,10 @@ class HoneywellUSThermostat(ClimateEntity): def turn_aux_heat_off(self) -> None: """Turn auxiliary heater off.""" - if HVAC_MODE_HEAT in self.hvac_modes: - self.set_hvac_mode(HVAC_MODE_HEAT) + if HVACMode.HEAT in self.hvac_modes: + self.set_hvac_mode(HVACMode.HEAT) else: - self.set_hvac_mode(HVAC_MODE_OFF) + self.set_hvac_mode(HVACMode.OFF) async def async_update(self): """Get the latest state from the service."""