mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 05:47:10 +00:00
Use shorthand attributes in tfiac climate (#145289)
This commit is contained in:
parent
77ea654a1f
commit
cd91aca3b5
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user