1 """Support for AVM FRITZ!SmartHome thermostat devices."""
3 from __future__
import annotations
26 ATTR_STATE_BATTERY_LOW,
27 ATTR_STATE_HOLIDAY_MODE,
28 ATTR_STATE_SUMMER_MODE,
29 ATTR_STATE_WINDOW_OPEN,
33 from .coordinator
import FritzboxConfigEntry, FritzboxDataUpdateCoordinator
34 from .entity
import FritzBoxDeviceEntity
35 from .model
import ClimateExtraAttributes
36 from .sensor
import value_scheduled_preset
38 HVAC_MODES = [HVACMode.HEAT, HVACMode.OFF]
39 PRESET_HOLIDAY =
"holiday"
40 PRESET_SUMMER =
"summer"
41 PRESET_MODES = [PRESET_ECO, PRESET_COMFORT]
42 SUPPORTED_FEATURES = (
43 ClimateEntityFeature.TARGET_TEMPERATURE
44 | ClimateEntityFeature.PRESET_MODE
45 | ClimateEntityFeature.TURN_OFF
46 | ClimateEntityFeature.TURN_ON
53 ON_API_TEMPERATURE = 127.0
54 OFF_API_TEMPERATURE = 126.5
55 ON_REPORT_SET_TEMPERATURE = 30.0
56 OFF_REPORT_SET_TEMPERATURE = 0.0
61 entry: FritzboxConfigEntry,
62 async_add_entities: AddEntitiesCallback,
64 """Set up the FRITZ!SmartHome thermostat from ConfigEntry."""
65 coordinator = entry.runtime_data
68 def _add_entities(devices: set[str] |
None =
None) ->
None:
71 devices = coordinator.new_devices
77 if coordinator.data.devices[ain].has_thermostat
80 entry.async_on_unload(coordinator.async_add_listener(_add_entities))
82 _add_entities(set(coordinator.data.devices))
86 """The thermostat class for FRITZ!SmartHome thermostats."""
88 _attr_precision = PRECISION_HALVES
89 _attr_temperature_unit = UnitOfTemperature.CELSIUS
90 _attr_translation_key =
"thermostat"
91 _enable_turn_on_off_backwards_compatibility =
False
95 coordinator: FritzboxDataUpdateCoordinator,
98 """Initialize the thermostat."""
106 """Write the state to the HASS state machine."""
123 """Return the current temperature."""
130 """Return the temperature we try to reach."""
132 return ON_REPORT_SET_TEMPERATURE
134 return OFF_REPORT_SET_TEMPERATURE
138 """Set new target temperature."""
139 target_temp = kwargs.get(ATTR_TEMPERATURE)
140 hvac_mode = kwargs.get(ATTR_HVAC_MODE)
141 if hvac_mode == HVACMode.OFF:
143 elif target_temp
is not None:
144 await self.
hasshasshass.async_add_executor_job(
153 """Return the current operation mode."""
159 OFF_REPORT_SET_TEMPERATURE,
167 """Set new operation mode."""
170 translation_domain=DOMAIN,
171 translation_key=
"change_hvac_while_active_mode",
175 "%s is already in requested hvac mode %s", self.
namenamename, hvac_mode
178 if hvac_mode == HVACMode.OFF:
189 """Return current preset mode."""
191 return PRESET_HOLIDAY
195 return PRESET_COMFORT
201 """Set preset mode."""
204 translation_domain=DOMAIN,
205 translation_key=
"change_preset_while_active_mode",
207 if preset_mode == PRESET_COMFORT:
209 elif preset_mode == PRESET_ECO:
214 """Return the minimum temperature."""
215 return MIN_TEMPERATURE
219 """Return the maximum temperature."""
220 return MAX_TEMPERATURE
224 """Return the device specific state attributes."""
225 attrs: ClimateExtraAttributes = {
None async_set_temperature(self, **Any kwargs)
None async_set_hvac_mode(self, HVACMode hvac_mode)
HVACMode|None hvac_mode(self)
float target_temperature(self)
ClimateExtraAttributes extra_state_attributes(self)
None __init__(self, FritzboxDataUpdateCoordinator coordinator, str ain)
None async_write_ha_state(self)
float current_temperature(self)
None async_set_preset_mode(self, str preset_mode)
None async_set_hvac_mode(self, HVACMode hvac_mode)
None async_set_temperature(self, **Any kwargs)
str|None preset_mode(self)
FritzhomeDevice data(self)
FritzhomeEntityBase data(self)
str|UndefinedType|None name(self)
None async_setup_entry(HomeAssistant hass, FritzboxConfigEntry entry, AddEntitiesCallback async_add_entities)
str|None value_scheduled_preset(FritzhomeDevice device)