1 """Climate platform for Tessie integration."""
3 from __future__
import annotations
7 from tessie_api
import (
8 set_climate_keeper_mode,
10 start_climate_preconditioning,
24 from .
import TessieConfigEntry
25 from .const
import TessieClimateKeeper
26 from .entity
import TessieEntity
27 from .models
import TessieVehicleData
34 entry: TessieConfigEntry,
35 async_add_entities: AddEntitiesCallback,
37 """Set up the Tessie Climate platform from a config entry."""
38 data = entry.runtime_data
44 """Vehicle Location Climate Class."""
46 _attr_precision = PRECISION_HALVES
49 _attr_temperature_unit = UnitOfTemperature.CELSIUS
50 _attr_hvac_modes = [HVACMode.HEAT_COOL, HVACMode.OFF]
51 _attr_supported_features = (
52 ClimateEntityFeature.TURN_ON
53 | ClimateEntityFeature.TURN_OFF
54 | ClimateEntityFeature.TARGET_TEMPERATURE
55 | ClimateEntityFeature.PRESET_MODE
57 _attr_preset_modes: list = [
58 TessieClimateKeeper.OFF,
59 TessieClimateKeeper.ON,
60 TessieClimateKeeper.DOG,
61 TessieClimateKeeper.CAMP,
63 _enable_turn_on_off_backwards_compatibility =
False
67 vehicle: TessieVehicleData,
69 """Initialize the Climate entity."""
74 """Return hvac operation ie. heat, cool mode."""
75 if self.
getget(
"climate_state_is_climate_on"):
76 return HVACMode.HEAT_COOL
81 """Return the current temperature."""
82 return self.
getget(
"climate_state_inside_temp")
86 """Return the temperature we try to reach."""
87 return self.
getget(
"climate_state_driver_temp_setting")
91 """Return the maximum temperature."""
92 return self.
getget(
"climate_state_max_avail_temp", self.
_attr_max_temp_attr_max_temp)
96 """Return the minimum temperature."""
97 return self.
getget(
"climate_state_min_avail_temp", self.
_attr_min_temp_attr_min_temp)
101 """Return the current preset mode."""
102 return self.
getget(
"climate_state_climate_keeper_mode")
105 """Set the climate state to on."""
106 await self.
runrun(start_climate_preconditioning)
107 self.
setset((
"climate_state_is_climate_on",
True))
110 """Set the climate state to off."""
111 await self.
runrun(stop_climate)
113 (
"climate_state_is_climate_on",
False),
114 (
"climate_state_climate_keeper_mode",
"off"),
118 """Set the climate temperature."""
119 if mode := kwargs.get(ATTR_HVAC_MODE):
122 if temp := kwargs.get(ATTR_TEMPERATURE):
123 await self.
runrun(set_temperature, temperature=temp)
124 self.
setset((
"climate_state_driver_temp_setting", temp))
127 """Set the climate mode and state."""
128 if hvac_mode == HVACMode.OFF:
134 """Set the climate preset mode."""
136 set_climate_keeper_mode, mode=self._attr_preset_modes.index(preset_mode)
140 "climate_state_climate_keeper_mode",
144 "climate_state_is_climate_on",
145 preset_mode != self._attr_preset_modes[0],
None async_set_hvac_mode(self, HVACMode hvac_mode)
None async_turn_off(self)
None async_set_hvac_mode(self, HVACMode hvac_mode)
None async_set_temperature(self, **Any kwargs)
str|None preset_mode(self)
None __init__(self, TessieVehicleData vehicle)
float|None target_temperature(self)
None async_set_preset_mode(self, str preset_mode)
None async_turn_off(self)
float|None current_temperature(self)
Any get(self, str|None key=None, Any|None default=None)
None set(self, *Any args)
None run(self, Callable[..., Awaitable[dict[str, Any]]] func, **Any kargs)
None async_setup_entry(HomeAssistant hass, TessieConfigEntry entry, AddEntitiesCallback async_add_entities)