1 """Support for Insteon thermostat."""
3 from __future__
import annotations
7 from pyinsteon.config
import CELSIUS
8 from pyinsteon.constants
import ThermostatMode
11 ATTR_TARGET_TEMP_HIGH,
25 from .const
import SIGNAL_ADD_ENTITIES
26 from .entity
import InsteonEntity
27 from .utils
import async_add_insteon_devices, async_add_insteon_entities
50 3: HVACMode.HEAT_COOL,
52 FAN_MODES = {4: FAN_AUTO, 8: FAN_ONLY}
57 config_entry: ConfigEntry,
58 async_add_entities: AddEntitiesCallback,
60 """Set up the Insteon climate entities from a config entry."""
63 def async_add_insteon_climate_entities(discovery_info=None):
64 """Add the Insteon entities for the platform."""
73 signal = f
"{SIGNAL_ADD_ENTITIES}_{Platform.CLIMATE}"
84 """A Class for an Insteon climate entity."""
86 _attr_supported_features = (
87 ClimateEntityFeature.FAN_MODE
88 | ClimateEntityFeature.TARGET_HUMIDITY
89 | ClimateEntityFeature.TARGET_TEMPERATURE
90 | ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
91 | ClimateEntityFeature.TURN_OFF
92 | ClimateEntityFeature.TURN_ON
94 _attr_hvac_modes =
list(HVAC_MODES.values())
95 _attr_fan_modes =
list(FAN_MODES.values())
96 _attr_min_humidity = 1
97 _enable_turn_on_off_backwards_compatibility =
False
101 """Return the unit of measurement."""
103 return UnitOfTemperature.CELSIUS
104 return UnitOfTemperature.FAHRENHEIT
108 """Return the current humidity."""
113 """Return hvac operation ie. heat, cool mode."""
114 return HVAC_MODES[self.
_insteon_device_insteon_device.groups[SYSTEM_MODE].value]
118 """Return the current temperature."""
123 """Return the temperature we try to reach."""
124 if self.
_insteon_device_insteon_device.groups[SYSTEM_MODE].value == ThermostatMode.HEAT:
125 return self.
_insteon_device_insteon_device.groups[HEAT_SET_POINT].value
126 if self.
_insteon_device_insteon_device.groups[SYSTEM_MODE].value == ThermostatMode.COOL:
127 return self.
_insteon_device_insteon_device.groups[COOL_SET_POINT].value
132 """Return the highbound target temperature we try to reach."""
133 if self.
_insteon_device_insteon_device.groups[SYSTEM_MODE].value == ThermostatMode.AUTO:
134 return self.
_insteon_device_insteon_device.groups[COOL_SET_POINT].value
139 """Return the lowbound target temperature we try to reach."""
140 if self.
_insteon_device_insteon_device.groups[SYSTEM_MODE].value == ThermostatMode.AUTO:
141 return self.
_insteon_device_insteon_device.groups[HEAT_SET_POINT].value
146 """Return the fan setting."""
147 return FAN_MODES[self.
_insteon_device_insteon_device.groups[FAN_MODE].value]
151 """Return the humidity we try to reach."""
155 return (high + low) / 2
if high
and low
else None
159 """Return the current running hvac operation if supported.
161 Need to be one of CURRENT_HVAC_*.
164 return HVACAction.COOLING
166 return HVACAction.HEATING
167 if self.
_insteon_device_insteon_device.groups[FAN_MODE].value == ThermostatMode.FAN_ALWAYS_ON:
168 return HVACAction.FAN
169 return HVACAction.IDLE
173 """Provide attributes for display on device card."""
174 attr = super().extra_state_attributes
177 humidifier =
"dehumidifying"
179 humidifier =
"humidifying"
180 attr[
"humidifier"] = humidifier
184 """Set new target temperature."""
185 target_temp = kwargs.get(ATTR_TEMPERATURE)
186 target_temp_low = kwargs.get(ATTR_TARGET_TEMP_LOW)
187 target_temp_high = kwargs.get(ATTR_TARGET_TEMP_HIGH)
188 if target_temp
is not None:
189 if self.
_insteon_device_insteon_device.groups[SYSTEM_MODE].value == ThermostatMode.HEAT:
190 await self.
_insteon_device_insteon_device.async_set_heat_set_point(target_temp)
191 elif self.
_insteon_device_insteon_device.groups[SYSTEM_MODE].value == ThermostatMode.COOL:
192 await self.
_insteon_device_insteon_device.async_set_cool_set_point(target_temp)
194 await self.
_insteon_device_insteon_device.async_set_heat_set_point(target_temp_low)
195 await self.
_insteon_device_insteon_device.async_set_cool_set_point(target_temp_high)
198 """Set new target fan mode."""
199 mode =
list(FAN_MODES)[
list(FAN_MODES.values()).index(fan_mode)]
203 """Set new target hvac mode."""
204 mode =
list(HVAC_MODES)[
list(HVAC_MODES.values()).index(hvac_mode)]
208 """Set new humidity level."""
210 high = self.
_insteon_device_insteon_device.groups[HUMIDITY_HIGH].value + change
211 low = self.
_insteon_device_insteon_device.groups[HUMIDITY_LOW].value + change
212 await self.
_insteon_device_insteon_device.async_set_humidity_low_set_point(low)
213 await self.
_insteon_device_insteon_device.async_set_humidity_high_set_point(high)
216 """Register INSTEON update events."""
float|None target_humidity(self)
HVACAction hvac_action(self)
None async_set_fan_mode(self, str fan_mode)
None async_set_temperature(self, **Any kwargs)
str temperature_unit(self)
None async_added_to_hass(self)
None async_set_hvac_mode(self, HVACMode hvac_mode)
None async_set_humidity(self, int humidity)
float|None target_temperature(self)
def extra_state_attributes(self)
int|None current_humidity(self)
float|None current_temperature(self)
float|None target_temperature_low(self)
int|None target_humidity(self)
float|None target_temperature_high(self)
def async_entity_update(self, name, address, value, group)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
None async_add_insteon_devices(HomeAssistant hass, Platform platform, type[InsteonEntity] entity_type, AddEntitiesCallback async_add_entities)
None async_add_insteon_entities(HomeAssistant hass, Platform platform, type[InsteonEntity] entity_type, AddEntitiesCallback async_add_entities, dict[str, Any] discovery_info)
Callable[[], None] subscribe(HomeAssistant hass, str topic, MessageCallbackType msg_callback, int qos=DEFAULT_QOS, str encoding="utf-8")
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)