diff --git a/homeassistant/components/lcn/climate.py b/homeassistant/components/lcn/climate.py index c3882033caf..31aedab2fe6 100644 --- a/homeassistant/components/lcn/climate.py +++ b/homeassistant/components/lcn/climate.py @@ -5,11 +5,8 @@ from typing import Any, cast import pypck -from homeassistant.components.climate import ( - DOMAIN as DOMAIN_CLIMATE, - ClimateEntity, - const, -) +from homeassistant.components.climate import DOMAIN as DOMAIN_CLIMATE, ClimateEntity +from homeassistant.components.climate.const import ClimateEntityFeature, HVACMode from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( ATTR_TEMPERATURE, @@ -69,6 +66,8 @@ async def async_setup_entry( class LcnClimate(LcnEntity, ClimateEntity): """Representation of a LCN climate device.""" + _attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE + def __init__( self, config: ConfigType, entry_id: str, device_connection: DeviceConnectionType ) -> None: @@ -90,6 +89,10 @@ class LcnClimate(LcnEntity, ClimateEntity): self._target_temperature = None self._is_on = True + self._attr_hvac_modes = [HVACMode.HEAT] + if self.is_lockable: + self._attr_hvac_modes.append(HVACMode.OFF) + async def async_added_to_hass(self) -> None: """Run when entity about to be added to hass.""" await super().async_added_to_hass() @@ -104,11 +107,6 @@ class LcnClimate(LcnEntity, ClimateEntity): await self.device_connection.cancel_status_request_handler(self.variable) await self.device_connection.cancel_status_request_handler(self.setpoint) - @property - def supported_features(self) -> int: - """Return the list of supported features.""" - return const.SUPPORT_TARGET_TEMPERATURE - @property def temperature_unit(self) -> str: """Return the unit of measurement.""" @@ -128,25 +126,14 @@ class LcnClimate(LcnEntity, ClimateEntity): return self._target_temperature @property - def hvac_mode(self) -> str: + def hvac_mode(self) -> HVACMode: """Return hvac operation ie. heat, cool mode. Need to be one of HVAC_MODE_*. """ if self._is_on: - return const.HVAC_MODE_HEAT - return const.HVAC_MODE_OFF - - @property - def hvac_modes(self) -> list[str]: - """Return the list of available hvac operation modes. - - Need to be a subset of HVAC_MODES. - """ - modes = [const.HVAC_MODE_HEAT] - if self.is_lockable: - modes.append(const.HVAC_MODE_OFF) - return modes + return HVACMode.HEAT + return HVACMode.OFF @property def max_temp(self) -> float: @@ -158,16 +145,16 @@ class LcnClimate(LcnEntity, ClimateEntity): """Return the minimum temperature.""" return cast(float, self._min_temp) - async def async_set_hvac_mode(self, hvac_mode: str) -> None: + async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None: """Set new target hvac mode.""" - if hvac_mode == const.HVAC_MODE_HEAT: + if hvac_mode == HVACMode.HEAT: if not await self.device_connection.lock_regulator( self.regulator_id, False ): return self._is_on = True self.async_write_ha_state() - elif hvac_mode == const.HVAC_MODE_OFF: + elif hvac_mode == HVACMode.OFF: if not await self.device_connection.lock_regulator(self.regulator_id, True): return self._is_on = False