mirror of
https://github.com/home-assistant/core
synced 2024-09-03 08:14:07 +02:00
Use climate enums in tolo (#70743)
This commit is contained in:
parent
b9379b5a88
commit
24b7d1f47b
@ -5,20 +5,13 @@ from typing import Any
|
||||
|
||||
from tololib.const import Calefaction
|
||||
|
||||
from homeassistant.components.climate import (
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_OFF,
|
||||
ClimateEntity,
|
||||
ClimateEntityFeature,
|
||||
)
|
||||
from homeassistant.components.climate import ClimateEntity
|
||||
from homeassistant.components.climate.const import (
|
||||
CURRENT_HVAC_DRY,
|
||||
CURRENT_HVAC_HEAT,
|
||||
CURRENT_HVAC_IDLE,
|
||||
CURRENT_HVAC_OFF,
|
||||
FAN_OFF,
|
||||
FAN_ON,
|
||||
HVAC_MODE_DRY,
|
||||
ClimateEntityFeature,
|
||||
HVACAction,
|
||||
HVACMode,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_TEMPERATURE, PRECISION_WHOLE, TEMP_CELSIUS
|
||||
@ -49,7 +42,7 @@ class SaunaClimate(ToloSaunaCoordinatorEntity, ClimateEntity):
|
||||
"""Sauna climate control."""
|
||||
|
||||
_attr_fan_modes = [FAN_ON, FAN_OFF]
|
||||
_attr_hvac_modes = [HVAC_MODE_OFF, HVAC_MODE_HEAT, HVAC_MODE_DRY]
|
||||
_attr_hvac_modes = [HVACMode.OFF, HVACMode.HEAT, HVACMode.DRY]
|
||||
_attr_max_humidity = DEFAULT_MAX_HUMIDITY
|
||||
_attr_max_temp = DEFAULT_MAX_TEMP
|
||||
_attr_min_humidity = DEFAULT_MIN_HUMIDITY
|
||||
@ -93,28 +86,28 @@ class SaunaClimate(ToloSaunaCoordinatorEntity, ClimateEntity):
|
||||
return self.coordinator.data.settings.target_humidity
|
||||
|
||||
@property
|
||||
def hvac_mode(self) -> str:
|
||||
def hvac_mode(self) -> HVACMode:
|
||||
"""Get current HVAC mode."""
|
||||
if self.coordinator.data.status.power_on:
|
||||
return HVAC_MODE_HEAT
|
||||
return HVACMode.HEAT
|
||||
if (
|
||||
not self.coordinator.data.status.power_on
|
||||
and self.coordinator.data.status.fan_on
|
||||
):
|
||||
return HVAC_MODE_DRY
|
||||
return HVAC_MODE_OFF
|
||||
return HVACMode.DRY
|
||||
return HVACMode.OFF
|
||||
|
||||
@property
|
||||
def hvac_action(self) -> str | None:
|
||||
def hvac_action(self) -> HVACAction | None:
|
||||
"""Execute HVAC action."""
|
||||
if self.coordinator.data.status.calefaction == Calefaction.HEAT:
|
||||
return CURRENT_HVAC_HEAT
|
||||
return HVACAction.HEATING
|
||||
if self.coordinator.data.status.calefaction == Calefaction.KEEP:
|
||||
return CURRENT_HVAC_IDLE
|
||||
return HVACAction.IDLE
|
||||
if self.coordinator.data.status.calefaction == Calefaction.INACTIVE:
|
||||
if self.coordinator.data.status.fan_on:
|
||||
return CURRENT_HVAC_DRY
|
||||
return CURRENT_HVAC_OFF
|
||||
return HVACAction.DRYING
|
||||
return HVACAction.OFF
|
||||
return None
|
||||
|
||||
@property
|
||||
@ -124,13 +117,13 @@ class SaunaClimate(ToloSaunaCoordinatorEntity, ClimateEntity):
|
||||
return FAN_ON
|
||||
return FAN_OFF
|
||||
|
||||
def set_hvac_mode(self, hvac_mode: str) -> None:
|
||||
def set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||
"""Set HVAC mode."""
|
||||
if hvac_mode == HVAC_MODE_OFF:
|
||||
if hvac_mode == HVACMode.OFF:
|
||||
self._set_power_and_fan(False, False)
|
||||
if hvac_mode == HVAC_MODE_HEAT:
|
||||
if hvac_mode == HVACMode.HEAT:
|
||||
self._set_power_and_fan(True, False)
|
||||
if hvac_mode == HVAC_MODE_DRY:
|
||||
if hvac_mode == HVACMode.DRY:
|
||||
self._set_power_and_fan(False, True)
|
||||
|
||||
def set_fan_mode(self, fan_mode: str) -> None:
|
||||
|
Loading…
Reference in New Issue
Block a user