Move SmartTub climate constants to module level (#47190)
This commit is contained in:
parent
bab66a5cb9
commit
c6223873f4
1 changed files with 17 additions and 17 deletions
|
@ -23,6 +23,19 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
PRESET_DAY = "day"
|
PRESET_DAY = "day"
|
||||||
|
|
||||||
|
PRESET_MODES = {
|
||||||
|
Spa.HeatMode.AUTO: PRESET_NONE,
|
||||||
|
Spa.HeatMode.ECONOMY: PRESET_ECO,
|
||||||
|
Spa.HeatMode.DAY: PRESET_DAY,
|
||||||
|
}
|
||||||
|
|
||||||
|
HEAT_MODES = {v: k for k, v in PRESET_MODES.items()}
|
||||||
|
|
||||||
|
HVAC_ACTIONS = {
|
||||||
|
"OFF": CURRENT_HVAC_IDLE,
|
||||||
|
"ON": CURRENT_HVAC_HEAT,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, entry, async_add_entities):
|
async def async_setup_entry(hass, entry, async_add_entities):
|
||||||
"""Set up climate entity for the thermostat in the tub."""
|
"""Set up climate entity for the thermostat in the tub."""
|
||||||
|
@ -39,19 +52,6 @@ async def async_setup_entry(hass, entry, async_add_entities):
|
||||||
class SmartTubThermostat(SmartTubEntity, ClimateEntity):
|
class SmartTubThermostat(SmartTubEntity, ClimateEntity):
|
||||||
"""The target water temperature for the spa."""
|
"""The target water temperature for the spa."""
|
||||||
|
|
||||||
PRESET_MODES = {
|
|
||||||
Spa.HeatMode.AUTO: PRESET_NONE,
|
|
||||||
Spa.HeatMode.ECONOMY: PRESET_ECO,
|
|
||||||
Spa.HeatMode.DAY: PRESET_DAY,
|
|
||||||
}
|
|
||||||
|
|
||||||
HEAT_MODES = {v: k for k, v in PRESET_MODES.items()}
|
|
||||||
|
|
||||||
HVAC_ACTIONS = {
|
|
||||||
"OFF": CURRENT_HVAC_IDLE,
|
|
||||||
"ON": CURRENT_HVAC_HEAT,
|
|
||||||
}
|
|
||||||
|
|
||||||
def __init__(self, coordinator, spa):
|
def __init__(self, coordinator, spa):
|
||||||
"""Initialize the entity."""
|
"""Initialize the entity."""
|
||||||
super().__init__(coordinator, spa, "thermostat")
|
super().__init__(coordinator, spa, "thermostat")
|
||||||
|
@ -64,7 +64,7 @@ class SmartTubThermostat(SmartTubEntity, ClimateEntity):
|
||||||
@property
|
@property
|
||||||
def hvac_action(self):
|
def hvac_action(self):
|
||||||
"""Return the current running hvac operation."""
|
"""Return the current running hvac operation."""
|
||||||
return self.HVAC_ACTIONS.get(self.spa_status.heater)
|
return HVAC_ACTIONS.get(self.spa_status.heater)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hvac_modes(self):
|
def hvac_modes(self):
|
||||||
|
@ -112,12 +112,12 @@ class SmartTubThermostat(SmartTubEntity, ClimateEntity):
|
||||||
@property
|
@property
|
||||||
def preset_mode(self):
|
def preset_mode(self):
|
||||||
"""Return the current preset mode."""
|
"""Return the current preset mode."""
|
||||||
return self.PRESET_MODES[self.spa_status.heat_mode]
|
return PRESET_MODES[self.spa_status.heat_mode]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def preset_modes(self):
|
def preset_modes(self):
|
||||||
"""Return the available preset modes."""
|
"""Return the available preset modes."""
|
||||||
return list(self.PRESET_MODES.values())
|
return list(PRESET_MODES.values())
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_temperature(self):
|
def current_temperature(self):
|
||||||
|
@ -137,6 +137,6 @@ class SmartTubThermostat(SmartTubEntity, ClimateEntity):
|
||||||
|
|
||||||
async def async_set_preset_mode(self, preset_mode: str):
|
async def async_set_preset_mode(self, preset_mode: str):
|
||||||
"""Activate the specified preset mode."""
|
"""Activate the specified preset mode."""
|
||||||
heat_mode = self.HEAT_MODES[preset_mode]
|
heat_mode = HEAT_MODES[preset_mode]
|
||||||
await self.spa.set_heat_mode(heat_mode)
|
await self.spa.set_heat_mode(heat_mode)
|
||||||
await self.coordinator.async_refresh()
|
await self.coordinator.async_refresh()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue