From cd91aca3b515c96067e7ae378c20c3e31bd0538e Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 20 May 2025 10:09:25 +0200 Subject: [PATCH] Use shorthand attributes in tfiac climate (#145289) --- homeassistant/components/tfiac/climate.py | 57 +++++------------------ 1 file changed, 11 insertions(+), 46 deletions(-) diff --git a/homeassistant/components/tfiac/climate.py b/homeassistant/components/tfiac/climate.py index 7fc6e2594c4..bab05bfc25e 100644 --- a/homeassistant/components/tfiac/climate.py +++ b/homeassistant/components/tfiac/climate.py @@ -36,9 +36,6 @@ PLATFORM_SCHEMA = CLIMATE_PLATFORM_SCHEMA.extend({vol.Required(CONF_HOST): cv.st _LOGGER = logging.getLogger(__name__) -MIN_TEMP = 61 -MAX_TEMP = 88 - HVAC_MAP = { HVACMode.HEAT: "heat", HVACMode.AUTO: "selfFeel", @@ -50,9 +47,6 @@ HVAC_MAP = { HVAC_MAP_REV = {v: k for k, v in HVAC_MAP.items()} -SUPPORT_FAN = [FAN_AUTO, FAN_HIGH, FAN_MEDIUM, FAN_LOW] -SUPPORT_SWING = [SWING_OFF, SWING_HORIZONTAL, SWING_VERTICAL, SWING_BOTH] - CURR_TEMP = "current_temp" TARGET_TEMP = "target_temp" OPERATION_MODE = "operation" @@ -74,7 +68,7 @@ async def async_setup_platform( except futures.TimeoutError: _LOGGER.error("Unable to connect to %s", config[CONF_HOST]) return - async_add_entities([TfiacClimate(hass, tfiac_client)]) + async_add_entities([TfiacClimate(tfiac_client)]) class TfiacClimate(ClimateEntity): @@ -88,34 +82,23 @@ class TfiacClimate(ClimateEntity): | ClimateEntityFeature.TURN_ON ) _attr_temperature_unit = UnitOfTemperature.FAHRENHEIT + _attr_min_temp = 61 + _attr_max_temp = 88 + _attr_fan_modes = [FAN_AUTO, FAN_HIGH, FAN_MEDIUM, FAN_LOW] + _attr_hvac_modes = list(HVAC_MAP) + _attr_swing_modes = [SWING_OFF, SWING_HORIZONTAL, SWING_VERTICAL, SWING_BOTH] - def __init__(self, hass, client): + def __init__(self, client: Tfiac) -> None: """Init class.""" self._client = client - self._available = True - - @property - def available(self) -> bool: - """Return if the device is available.""" - return self._available async def async_update(self) -> None: """Update status via socket polling.""" try: await self._client.update() - self._available = True + self._attr_available = True except futures.TimeoutError: - self._available = False - - @property - def min_temp(self): - """Return the minimum temperature.""" - return MIN_TEMP - - @property - def max_temp(self): - """Return the maximum temperature.""" - return MAX_TEMP + self._attr_available = False @property def name(self): @@ -145,33 +128,15 @@ class TfiacClimate(ClimateEntity): return HVAC_MAP_REV.get(state) @property - def hvac_modes(self) -> list[HVACMode]: - """Return the list of available hvac operation modes. - - Need to be a subset of HVAC_MODES. - """ - return list(HVAC_MAP) - - @property - def fan_mode(self): + def fan_mode(self) -> str: """Return the fan setting.""" return self._client.status["fan_mode"].lower() @property - def fan_modes(self): - """Return the list of available fan modes.""" - return SUPPORT_FAN - - @property - def swing_mode(self): + def swing_mode(self) -> str: """Return the swing setting.""" return self._client.status["swing_mode"].lower() - @property - def swing_modes(self): - """List of available swing modes.""" - return SUPPORT_SWING - async def async_set_temperature(self, **kwargs: Any) -> None: """Set new target temperature.""" if (temp := kwargs.get(ATTR_TEMPERATURE)) is not None: