1 """Support for LCN climate control."""
3 from collections.abc
import Iterable
4 from functools
import partial
5 from typing
import Any, cast
10 DOMAIN
as DOMAIN_CLIMATE,
21 CONF_UNIT_OF_MEASUREMENT,
29 ADD_ENTITIES_CALLBACKS,
37 from .entity
import LcnEntity
38 from .helpers
import InputType
44 config_entry: ConfigEntry,
45 async_add_entities: AddEntitiesCallback,
46 entity_configs: Iterable[ConfigType],
48 """Add entities for this domain."""
50 LcnClimate(entity_config, config_entry)
for entity_config
in entity_configs
58 config_entry: ConfigEntry,
59 async_add_entities: AddEntitiesCallback,
61 """Set up LCN switch entities from a config entry."""
62 add_entities = partial(
68 hass.data[DOMAIN][config_entry.entry_id][ADD_ENTITIES_CALLBACKS].
update(
69 {DOMAIN_CLIMATE: add_entities}
75 for entity_config
in config_entry.data[CONF_ENTITIES]
76 if entity_config[CONF_DOMAIN] == DOMAIN_CLIMATE
82 """Representation of a LCN climate device."""
84 _enable_turn_on_off_backwards_compatibility =
False
86 def __init__(self, config: ConfigType, config_entry: ConfigEntry) ->
None:
87 """Initialize of a LCN climate device."""
88 super().
__init__(config, config_entry)
90 self.
variablevariable = pypck.lcn_defs.Var[config[CONF_DOMAIN_DATA][CONF_SOURCE]]
91 self.
setpointsetpoint = pypck.lcn_defs.Var[config[CONF_DOMAIN_DATA][CONF_SETPOINT]]
92 self.
unitunit = pypck.lcn_defs.VarUnit.parse(
93 config[CONF_DOMAIN_DATA][CONF_UNIT_OF_MEASUREMENT]
97 self.
is_lockableis_lockable = config[CONF_DOMAIN_DATA][CONF_LOCKABLE]
98 self.
_max_temp_max_temp = config[CONF_DOMAIN_DATA][CONF_MAX_TEMP]
99 self.
_min_temp_min_temp = config[CONF_DOMAIN_DATA][CONF_MIN_TEMP]
111 ClimateEntityFeature.TURN_OFF | ClimateEntityFeature.TURN_ON
115 """Run when entity about to be added to hass."""
122 """Run when entity will be removed from hass."""
130 """Return the unit of measurement."""
132 if self.
unitunit == pypck.lcn_defs.VarUnit.FAHRENHEIT:
133 return UnitOfTemperature.FAHRENHEIT
134 return UnitOfTemperature.CELSIUS
138 """Return the current temperature."""
143 """Return the temperature we try to reach."""
148 """Return hvac operation ie. heat, cool mode.
150 Need to be one of HVAC_MODE_*.
158 """Return the maximum temperature."""
159 return cast(float, self.
_max_temp_max_temp)
163 """Return the minimum temperature."""
164 return cast(float, self.
_min_temp_min_temp)
167 """Set new target hvac mode."""
168 if hvac_mode == HVACMode.HEAT:
175 elif hvac_mode == HVACMode.OFF:
183 """Set new target temperature."""
184 if (temperature := kwargs.get(ATTR_TEMPERATURE))
is None:
195 """Set temperature value when LCN input object is received."""
196 if not isinstance(input_obj, pypck.inputs.ModStatusVar):
199 if input_obj.get_var() == self.
variablevariable:
201 elif input_obj.get_var() == self.
setpointsetpoint:
202 self.
_is_on_is_on =
not input_obj.get_value().is_locked_regulator()
list[HVACMode] hvac_modes(self)
None __init__(self, ConfigType config, ConfigEntry config_entry)
None input_received(self, InputType input_obj)
None async_set_hvac_mode(self, HVACMode hvac_mode)
None async_added_to_hass(self)
None async_set_temperature(self, **Any kwargs)
float|None target_temperature(self)
float|None current_temperature(self)
None async_will_remove_from_hass(self)
str temperature_unit(self)
None async_write_ha_state(self)
None add_entities(AsusWrtRouter router, AddEntitiesCallback async_add_entities, set[str] tracked)
IssData update(pyiss.ISS iss)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
None add_lcn_entities(ConfigEntry config_entry, AddEntitiesCallback async_add_entities, Iterable[ConfigType] entity_configs)