diff --git a/homeassistant/components/nuheat/climate.py b/homeassistant/components/nuheat/climate.py index a82e57cb7fb..6cc70965ade 100644 --- a/homeassistant/components/nuheat/climate.py +++ b/homeassistant/components/nuheat/climate.py @@ -11,13 +11,12 @@ from nuheat.util import ( nuheat_to_fahrenheit, ) -from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature +from homeassistant.components.climate import ClimateEntity from homeassistant.components.climate.const import ( ATTR_HVAC_MODE, - CURRENT_HVAC_HEAT, - CURRENT_HVAC_IDLE, - HVAC_MODE_AUTO, - HVAC_MODE_HEAT, + ClimateEntityFeature, + HVACAction, + HVACMode, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT @@ -43,7 +42,7 @@ _LOGGER = logging.getLogger(__name__) # The device does not have an off function. # To turn it off set to min_temp and PRESET_PERMANENT_HOLD -OPERATION_LIST = [HVAC_MODE_AUTO, HVAC_MODE_HEAT] +OPERATION_LIST = [HVACMode.AUTO, HVACMode.HEAT] PRESET_RUN = "Run Schedule" PRESET_TEMPORARY_HOLD = "Temporary Hold" @@ -82,6 +81,7 @@ async def async_setup_entry( class NuHeatThermostat(CoordinatorEntity, ClimateEntity): """Representation of a NuHeat Thermostat.""" + _attr_hvac_modes = OPERATION_LIST _attr_supported_features = ( ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE ) @@ -125,24 +125,24 @@ class NuHeatThermostat(CoordinatorEntity, ClimateEntity): """Return the unique id.""" return self.coordinator.last_update_success and self._thermostat.online - def set_hvac_mode(self, hvac_mode): + def set_hvac_mode(self, hvac_mode: HVACMode) -> None: """Set the system mode.""" - if hvac_mode == HVAC_MODE_AUTO: + if hvac_mode == HVACMode.AUTO: self._set_schedule_mode(SCHEDULE_RUN) - elif hvac_mode == HVAC_MODE_HEAT: + elif hvac_mode == HVACMode.HEAT: self._set_schedule_mode(SCHEDULE_HOLD) @property - def hvac_mode(self): + def hvac_mode(self) -> HVACMode: """Return current setting heat or auto.""" if self._schedule_mode in (SCHEDULE_TEMPORARY_HOLD, SCHEDULE_HOLD): - return HVAC_MODE_HEAT - return HVAC_MODE_AUTO + return HVACMode.HEAT + return HVACMode.AUTO @property - def hvac_action(self): + def hvac_action(self) -> HVACAction: """Return current operation heat or idle.""" - return CURRENT_HVAC_HEAT if self._thermostat.heating else CURRENT_HVAC_IDLE + return HVACAction.HEATING if self._thermostat.heating else HVACAction.IDLE @property def min_temp(self): @@ -178,11 +178,6 @@ class NuHeatThermostat(CoordinatorEntity, ClimateEntity): """Return available preset modes.""" return PRESET_MODES - @property - def hvac_modes(self): - """Return list of possible operation modes.""" - return OPERATION_LIST - def set_preset_mode(self, preset_mode): """Update the hold mode of the thermostat.""" self._set_schedule_mode( @@ -218,7 +213,7 @@ class NuHeatThermostat(CoordinatorEntity, ClimateEntity): preset_mode, SCHEDULE_RUN ) elif self._schedule_mode == SCHEDULE_HOLD or ( - hvac_mode and hvac_mode == HVAC_MODE_HEAT + hvac_mode and hvac_mode == HVACMode.HEAT ): target_schedule_mode = SCHEDULE_HOLD