1 """Climate platform that offers a climate device for the TFIAC protocol."""
3 from __future__
import annotations
5 from concurrent
import futures
6 from datetime
import timedelta
10 from pytfiac
import Tfiac
11 import voluptuous
as vol
18 PLATFORM_SCHEMA
as CLIMATE_PLATFORM_SCHEMA,
35 PLATFORM_SCHEMA = CLIMATE_PLATFORM_SCHEMA.extend({vol.Required(CONF_HOST): cv.string})
37 _LOGGER = logging.getLogger(__name__)
43 HVACMode.HEAT:
"heat",
44 HVACMode.AUTO:
"selfFeel",
45 HVACMode.DRY:
"dehumi",
46 HVACMode.FAN_ONLY:
"fan",
47 HVACMode.COOL:
"cool",
51 HVAC_MAP_REV = {v: k
for k, v
in HVAC_MAP.items()}
53 SUPPORT_FAN = [FAN_AUTO, FAN_HIGH, FAN_MEDIUM, FAN_LOW]
54 SUPPORT_SWING = [SWING_OFF, SWING_HORIZONTAL, SWING_VERTICAL, SWING_BOTH]
56 CURR_TEMP =
"current_temp"
57 TARGET_TEMP =
"target_temp"
58 OPERATION_MODE =
"operation"
60 SWING_MODE =
"swing_mode"
67 async_add_entities: AddEntitiesCallback,
68 discovery_info: DiscoveryInfoType |
None =
None,
70 """Set up the TFIAC climate device."""
71 tfiac_client = Tfiac(config[CONF_HOST])
73 await tfiac_client.update()
74 except futures.TimeoutError:
75 _LOGGER.error(
"Unable to connect to %s", config[CONF_HOST])
83 _attr_supported_features = (
84 ClimateEntityFeature.FAN_MODE
85 | ClimateEntityFeature.SWING_MODE
86 | ClimateEntityFeature.TARGET_TEMPERATURE
87 | ClimateEntityFeature.TURN_OFF
88 | ClimateEntityFeature.TURN_ON
90 _attr_temperature_unit = UnitOfTemperature.FAHRENHEIT
91 _enable_turn_on_off_backwards_compatibility =
False
100 """Return if the device is available."""
104 """Update status via socket polling."""
108 except futures.TimeoutError:
113 """Return the minimum temperature."""
118 """Return the maximum temperature."""
123 """Return the name of the climate device."""
124 return self.
_client_client.name
128 """Return the temperature we try to reach."""
129 return self.
_client_client.status[
"target_temp"]
133 """Return the current temperature."""
134 return self.
_client_client.status[
"current_temp"]
138 """Return hvac operation ie. heat, cool mode.
140 Need to be one of HVAC_MODE_*.
142 if self.
_client_client.status[ON_MODE] !=
"on":
145 state = self.
_client_client.status[
"operation"]
146 return HVAC_MAP_REV.get(state)
150 """Return the list of available hvac operation modes.
152 Need to be a subset of HVAC_MODES.
154 return list(HVAC_MAP)
158 """Return the fan setting."""
159 return self.
_client_client.status[
"fan_mode"].lower()
163 """Return the list of available fan modes."""
168 """Return the swing setting."""
169 return self.
_client_client.status[
"swing_mode"].lower()
173 """List of available swing modes."""
177 """Set new target temperature."""
178 if (temp := kwargs.get(ATTR_TEMPERATURE))
is not None:
179 await self.
_client_client.set_state(TARGET_TEMP, temp)
182 """Set new target hvac mode."""
183 if hvac_mode == HVACMode.OFF:
184 await self.
_client_client.set_state(ON_MODE,
"off")
186 await self.
_client_client.set_state(OPERATION_MODE, HVAC_MAP[hvac_mode])
189 """Set new fan mode."""
190 await self.
_client_client.set_state(FAN_MODE, fan_mode.capitalize())
193 """Set new swing mode."""
194 await self.
_client_client.set_swing(swing_mode.capitalize())
197 """Turn device on."""
198 await self.
_client_client.set_state(OPERATION_MODE)
201 """Turn device off."""
202 await self.
_client_client.set_state(ON_MODE,
"off")
None async_set_swing_mode(self, str swing_mode)
def target_temperature(self)
None async_set_hvac_mode(self, HVACMode hvac_mode)
def __init__(self, hass, client)
None async_set_fan_mode(self, str fan_mode)
None async_set_temperature(self, **Any kwargs)
None async_turn_off(self)
list[HVACMode] hvac_modes(self)
def current_temperature(self)
IssData update(pyiss.ISS iss)
None async_setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback async_add_entities, DiscoveryInfoType|None discovery_info=None)