1 """Support for Radio Thermostat wifi-enabled home thermostats."""
3 from __future__
import annotations
26 from .coordinator
import RadioThermUpdateCoordinator
27 from .entity
import RadioThermostatEntity
29 ATTR_FAN_ACTION =
"fan_action"
31 PRESET_HOLIDAY =
"holiday"
33 PRESET_ALTERNATE =
"alternate"
35 STATE_CIRCULATE =
"circulate"
37 PRESET_MODES = [PRESET_HOME, PRESET_ALTERNATE, PRESET_AWAY, PRESET_HOLIDAY]
39 OPERATION_LIST = [HVACMode.AUTO, HVACMode.COOL, HVACMode.HEAT, HVACMode.OFF]
40 CT30_FAN_OPERATION_LIST = [FAN_ON, FAN_AUTO]
41 CT80_FAN_OPERATION_LIST = [FAN_ON, STATE_CIRCULATE, FAN_AUTO]
54 TEMP_MODE_TO_CODE = {v: k
for k, v
in CODE_TO_TEMP_MODE.items()}
57 CODE_TO_FAN_MODE = {0: FAN_AUTO, 1: STATE_CIRCULATE, 2: FAN_ON}
59 FAN_MODE_TO_CODE = {v: k
for k, v
in CODE_TO_FAN_MODE.items()}
63 CODE_TO_TEMP_STATE = {0: HVACAction.IDLE, 1: HVACAction.HEATING, 2: HVACAction.COOLING}
67 CODE_TO_FAN_STATE = {0: FAN_OFF, 1: FAN_ON}
69 PRESET_MODE_TO_CODE = {
76 CODE_TO_PRESET_MODE = {v: k
for k, v
in PRESET_MODE_TO_CODE.items()}
81 CONF_HOLD_TEMP =
"hold_temp"
85 """Round a temperature to the resolution of the thermostat.
87 RadioThermostats can handle 0.5 degree temps so the input
88 temperature is rounded to that value and returned.
90 return round(temperature * 2.0) / 2.0
96 async_add_entities: AddEntitiesCallback,
98 """Set up climate for a radiotherm device."""
99 coordinator: RadioThermUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
104 """Representation of a Radio Thermostat."""
106 _attr_hvac_modes = OPERATION_LIST
107 _attr_temperature_unit = UnitOfTemperature.FAHRENHEIT
108 _attr_precision = PRECISION_HALVES
110 _enable_turn_on_off_backwards_compatibility =
False
112 def __init__(self, coordinator: RadioThermUpdateCoordinator) ->
None:
113 """Initialize the thermostat."""
118 ClimateEntityFeature.TARGET_TEMPERATURE
119 | ClimateEntityFeature.FAN_MODE
120 | ClimateEntityFeature.TURN_OFF
121 | ClimateEntityFeature.TURN_ON
123 if not isinstance(self.
devicedevice, radiotherm.thermostat.CT80):
130 """Turn fan on/off."""
131 if (code := FAN_MODE_TO_CODE.get(fan_mode))
is None:
132 raise ValueError(f
"{fan_mode} is not a valid fan mode")
139 """Turn fan on/off."""
140 self.
devicedevice.fmode = code
144 """Update and validate the data from the thermostat."""
146 if isinstance(self.
devicedevice, radiotherm.thermostat.CT80):
151 self.
_attr_fan_mode_attr_fan_mode = CODE_TO_FAN_MODE[data[
"fmode"]]
153 ATTR_FAN_ACTION: CODE_TO_FAN_STATE[data[
"fstate"]]
174 """Set new target temperature."""
175 if (temperature := kwargs.get(ATTR_TEMPERATURE))
is None:
183 """Set new target temperature."""
186 self.
devicedevice.t_cool = temperature
188 self.
devicedevice.t_heat = temperature
191 self.
devicedevice.t_cool = temperature
193 self.
devicedevice.t_heat = temperature
196 """Set operation mode (auto, cool, heat, off)."""
203 """Set operation mode (auto, cool, heat, off)."""
204 if hvac_mode
in (HVACMode.OFF, HVACMode.AUTO):
205 self.
devicedevice.tmode = TEMP_MODE_TO_CODE[hvac_mode]
207 elif hvac_mode == HVACMode.COOL:
209 elif hvac_mode == HVACMode.HEAT:
213 """Set Preset mode (Home, Alternate, Away, Holiday)."""
214 if preset_mode
not in PRESET_MODES:
215 raise ValueError(f
"{preset_mode} is not a valid preset_mode")
222 """Set Preset mode (Home, Alternate, Away, Holiday)."""
223 assert isinstance(self.
devicedevice, radiotherm.thermostat.CT80)
224 self.
devicedevice.program_mode = PRESET_MODE_TO_CODE[preset_mode]
float|None target_temperature(self)
HVACAction|None hvac_action(self)
HVACMode|None hvac_mode(self)
_attr_extra_state_attributes
None _set_fan_mode(self, int code)
None async_set_preset_mode(self, str preset_mode)
None __init__(self, RadioThermUpdateCoordinator coordinator)
None _set_preset_mode(self, str preset_mode)
None async_set_fan_mode(self, str fan_mode)
_attr_current_temperature
None async_set_hvac_mode(self, HVACMode hvac_mode)
None async_set_temperature(self, **Any kwargs)
None _set_temperature(self, int temperature)
None _set_hvac_mode(self, HVACMode hvac_mode)
RadioThermUpdate data(self)
None async_write_ha_state(self)
None async_request_refresh(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)
def round_temp(temperature)