1 """Support for Insteon Thermostats via ISY Platform."""
3 from __future__
import annotations
7 from pyisy.constants
import (
8 CMD_CLIMATE_FAN_SETTING,
18 from pyisy.nodes
import Node
21 ATTR_TARGET_TEMP_HIGH,
51 UOM_HVAC_MODE_GENERIC,
52 UOM_HVAC_MODE_INSTEON,
58 from .entity
import ISYNodeEntity
59 from .helpers
import convert_isy_value_to_hass
60 from .models
import IsyData
64 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
66 """Set up the ISY thermostat platform."""
68 isy_data: IsyData = hass.data[DOMAIN][entry.entry_id]
69 devices: dict[str, DeviceInfo] = isy_data.devices
73 for node
in isy_data.nodes[Platform.CLIMATE]
78 """Representation of an ISY thermostat entity."""
80 _attr_hvac_modes = ISY_HVAC_MODES
81 _attr_precision = PRECISION_TENTHS
82 _attr_supported_features = (
83 ClimateEntityFeature.FAN_MODE
84 | ClimateEntityFeature.TARGET_TEMPERATURE
85 | ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
86 | ClimateEntityFeature.TURN_OFF
87 | ClimateEntityFeature.TURN_ON
89 _attr_target_temperature_step = 1.0
90 _attr_fan_modes = [FAN_AUTO, FAN_ON]
91 _enable_turn_on_off_backwards_compatibility =
False
93 def __init__(self, node: Node, device_info: DeviceInfo |
None =
None) ->
None:
94 """Initialize the ISY Thermostat entity."""
95 super().
__init__(node, device_info=device_info)
97 if isinstance(self.
_uom_uom, list):
102 """Return the unit of measurement."""
103 if not (uom := self.
_node_node.aux_properties.get(PROP_UOM)):
104 return self.
hasshass.config.units.temperature_unit
105 if uom.value == UOM_ISY_CELSIUS:
106 return UnitOfTemperature.CELSIUS
107 if uom.value == UOM_ISY_FAHRENHEIT:
108 return UnitOfTemperature.FAHRENHEIT
109 return UnitOfTemperature.FAHRENHEIT
113 """Return the current humidity."""
114 if not (humidity := self.
_node_node.aux_properties.get(PROP_HUMIDITY)):
116 if humidity.value == ISY_VALUE_UNKNOWN:
118 return int(humidity.value)
122 """Return hvac operation ie. heat, cool mode."""
123 if not (hvac_mode := self.
_node_node.aux_properties.get(CMD_CLIMATE_MODE)):
129 if uom
in (UOM_ISYV4_NONE,
""):
131 UOM_HVAC_MODE_INSTEON
132 if self.
_node_node.protocol == PROTO_INSTEON
133 else UOM_HVAC_MODE_GENERIC
136 try_parse_enum(HVACMode, UOM_TO_STATES[uom].
get(hvac_mode.value))
142 """Return the current running hvac operation if supported."""
143 hvac_action = self.
_node_node.aux_properties.get(PROP_HEAT_COOL_STATE)
146 return try_parse_enum(
147 HVACAction, UOM_TO_STATES[UOM_HVAC_ACTIONS].
get(hvac_action.value)
152 """Return the current temperature."""
159 """Return the temperature we try to reach."""
168 """Return the highbound target temperature we try to reach."""
169 target = self.
_node_node.aux_properties.get(PROP_SETPOINT_COOL)
176 """Return the lowbound target temperature we try to reach."""
177 target = self.
_node_node.aux_properties.get(PROP_SETPOINT_HEAT)
184 """Return the current fan mode ie. auto, on."""
185 fan_mode = self.
_node_node.aux_properties.get(CMD_CLIMATE_FAN_SETTING)
188 return UOM_TO_STATES[UOM_FAN_MODES].
get(fan_mode.value, FAN_OFF)
191 """Set new target temperature."""
192 target_temp = kwargs.get(ATTR_TEMPERATURE)
193 target_temp_low = kwargs.get(ATTR_TARGET_TEMP_LOW)
194 target_temp_high = kwargs.get(ATTR_TARGET_TEMP_HIGH)
195 if target_temp
is not None:
197 target_temp_high = target_temp
199 target_temp_low = target_temp
200 if target_temp_low
is not None:
201 await self.
_node_node.set_climate_setpoint_heat(
int(target_temp_low))
202 if target_temp_high
is not None:
203 await self.
_node_node.set_climate_setpoint_cool(
int(target_temp_high))
207 """Set new target fan mode."""
208 _LOGGER.debug(
"Requested fan mode %s", fan_mode)
213 """Set new target hvac mode."""
214 _LOGGER.debug(
"Requested operation mode %s", hvac_mode)
215 await self.
_node_node.set_climate_mode(HA_HVAC_TO_ISY.get(hvac_mode))
None set_fan_mode(self, str fan_mode)
float|None target_temperature_low(self)
float|None target_temperature_high(self)
HVACMode|None hvac_mode(self)
None async_set_hvac_mode(self, HVACMode hvac_mode)
str temperature_unit(self)
None async_set_fan_mode(self, str fan_mode)
float|None target_temperature_high(self)
float|None target_temperature(self)
None async_set_temperature(self, **Any kwargs)
HVACAction|None hvac_action(self)
int|None current_humidity(self)
float|None current_temperature(self)
float|None target_temperature_low(self)
None __init__(self, Node node, DeviceInfo|None device_info=None)
None async_write_ha_state(self)
web.Response get(self, web.Request request, str config_key)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)
float|int|None convert_isy_value_to_hass(float|None value, str|None uom, int|str precision, int|None fallback_precision=None)