Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use climate enums in tolo #70743

Merged
merged 1 commit into from Apr 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 18 additions & 25 deletions homeassistant/components/tolo/climate.py
Expand Up @@ -5,20 +5,13 @@

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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -93,28 +86,28 @@ def target_humidity(self) -> int:
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
Expand All @@ -124,13 +117,13 @@ def fan_mode(self) -> str:
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:
Expand Down