1 """Platform for climate integration."""
3 from __future__
import annotations
7 from smarttub
import Spa
23 from .const
import DEFAULT_MAX_TEMP, DEFAULT_MIN_TEMP, DOMAIN, SMARTTUB_CONTROLLER
24 from .entity
import SmartTubEntity
27 PRESET_READY =
"ready"
30 Spa.HeatMode.AUTO: PRESET_NONE,
31 Spa.HeatMode.ECONOMY: PRESET_ECO,
32 Spa.HeatMode.DAY: PRESET_DAY,
33 Spa.HeatMode.READY: PRESET_READY,
36 HEAT_MODES = {v: k
for k, v
in PRESET_MODES.items()}
39 "OFF": HVACAction.IDLE,
40 "ON": HVACAction.HEATING,
45 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
47 """Set up climate entity for the thermostat in the tub."""
49 controller = hass.data[DOMAIN][entry.entry_id][SMARTTUB_CONTROLLER]
59 """The target water temperature for the spa."""
63 _attr_hvac_mode = HVACMode.HEAT
64 _attr_hvac_modes = [HVACMode.HEAT]
66 _attr_supported_features = (
67 ClimateEntityFeature.PRESET_MODE | ClimateEntityFeature.TARGET_TEMPERATURE
69 _attr_temperature_unit = UnitOfTemperature.CELSIUS
70 _attr_preset_modes =
list(PRESET_MODES.values())
71 _enable_turn_on_off_backwards_compatibility =
False
74 """Initialize the entity."""
75 super().
__init__(coordinator, spa,
"Thermostat")
79 """Return the current running hvac operation."""
80 return HVAC_ACTIONS.get(self.
spa_statusspa_status.heater)
83 """Set new target hvac mode.
85 As with hvac_mode, we don't really have an option here.
87 if hvac_mode == HVACMode.HEAT:
89 raise NotImplementedError(hvac_mode)
93 """Return the minimum temperature."""
94 min_temp = DEFAULT_MIN_TEMP
95 return TemperatureConverter.convert(
101 """Return the maximum temperature."""
102 max_temp = DEFAULT_MAX_TEMP
103 return TemperatureConverter.convert(
109 """Return the current preset mode."""
110 return PRESET_MODES[self.
spa_statusspa_status.heat_mode]
114 """Return the current water temperature."""
115 return self.
spa_statusspa_status.water.temperature
119 """Return the target water temperature."""
120 return self.
spa_statusspa_status.set_temperature
123 """Set new target temperature."""
124 temperature = kwargs[ATTR_TEMPERATURE]
126 await self.coordinator.async_refresh()
129 """Activate the specified preset mode."""
130 heat_mode = HEAT_MODES[preset_mode]
131 await self.
spaspa.set_heat_mode(heat_mode)
132 await self.coordinator.async_refresh()
None set_temperature(self, **Any kwargs)
str temperature_unit(self)
def __init__(self, coordinator, spa)
HVACAction|None hvac_action(self)
None async_set_preset_mode(self, str preset_mode)
None async_set_temperature(self, **Any kwargs)
def target_temperature(self)
def current_temperature(self)
None async_set_hvac_mode(self, HVACMode hvac_mode)
smarttub.SpaState spa_status(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)