1 """Support for Toon thermostat."""
3 from __future__
import annotations
29 from .
import ToonDataUpdateCoordinator
30 from .const
import DEFAULT_MAX_TEMP, DEFAULT_MIN_TEMP, DOMAIN
31 from .entity
import ToonDisplayDeviceEntity
32 from .helpers
import toon_exception_handler
36 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
38 """Set up a Toon binary sensors based on a config entry."""
39 coordinator = hass.data[DOMAIN][entry.entry_id]
44 """Representation of a Toon climate device."""
46 _attr_hvac_mode = HVACMode.HEAT
47 _attr_icon =
"mdi:thermostat"
48 _attr_max_temp = DEFAULT_MAX_TEMP
49 _attr_min_temp = DEFAULT_MIN_TEMP
50 _attr_name =
"Thermostat"
51 _attr_supported_features = (
52 ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
54 _attr_temperature_unit = UnitOfTemperature.CELSIUS
55 _enable_turn_on_off_backwards_compatibility =
False
59 coordinator: ToonDataUpdateCoordinator,
61 """Initialize Toon climate entity."""
71 f
"{DOMAIN}_{coordinator.data.agreement.agreement_id}_climate"
76 """Return the current running hvac operation."""
77 if self.coordinator.data.thermostat.heating:
78 return HVACAction.HEATING
79 return HVACAction.IDLE
83 """Return the current preset mode, e.g., home, away, temp."""
85 ACTIVE_STATE_AWAY: PRESET_AWAY,
86 ACTIVE_STATE_COMFORT: PRESET_COMFORT,
87 ACTIVE_STATE_HOME: PRESET_HOME,
88 ACTIVE_STATE_SLEEP: PRESET_SLEEP,
90 return mapping.get(self.coordinator.data.thermostat.active_state)
94 """Return the current temperature."""
95 return self.coordinator.data.thermostat.current_display_temperature
99 """Return the temperature we try to reach."""
100 return self.coordinator.data.thermostat.current_setpoint
104 """Return the current state of the burner."""
105 return {
"heating_type": self.coordinator.data.agreement.heating_type}
107 @toon_exception_handler
109 """Change the setpoint of the thermostat."""
110 temperature = kwargs.get(ATTR_TEMPERATURE)
111 await self.coordinator.toon.set_current_setpoint(temperature)
113 @toon_exception_handler
115 """Set new preset mode."""
117 PRESET_AWAY: ACTIVE_STATE_AWAY,
118 PRESET_COMFORT: ACTIVE_STATE_COMFORT,
119 PRESET_HOME: ACTIVE_STATE_HOME,
120 PRESET_SLEEP: ACTIVE_STATE_SLEEP,
122 if preset_mode
in mapping:
123 await self.coordinator.toon.set_active_state(mapping[preset_mode])
126 """Set new target hvac mode."""
dict[str, Any] extra_state_attributes(self)
None async_set_temperature(self, **Any kwargs)
float|None current_temperature(self)
str|None preset_mode(self)
None async_set_preset_mode(self, str preset_mode)
HVACAction hvac_action(self)
None set_hvac_mode(self, HVACMode hvac_mode)
float|None target_temperature(self)
None __init__(self, ToonDataUpdateCoordinator coordinator)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)