Use climate enums in evohome (#70639)
This commit is contained in:
parent
d52234a57a
commit
0cdfd386a7
1 changed files with 9 additions and 10 deletions
|
@ -4,15 +4,14 @@ from __future__ import annotations
|
|||
from datetime import datetime as dt
|
||||
import logging
|
||||
|
||||
from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
|
||||
from homeassistant.components.climate import ClimateEntity
|
||||
from homeassistant.components.climate.const import (
|
||||
HVAC_MODE_AUTO,
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_OFF,
|
||||
PRESET_AWAY,
|
||||
PRESET_ECO,
|
||||
PRESET_HOME,
|
||||
PRESET_NONE,
|
||||
ClimateEntityFeature,
|
||||
HVACMode,
|
||||
)
|
||||
from homeassistant.const import PRECISION_TENTHS
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -51,7 +50,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||
PRESET_RESET = "Reset" # reset all child zones to EVO_FOLLOW
|
||||
PRESET_CUSTOM = "Custom"
|
||||
|
||||
HA_HVAC_TO_TCS = {HVAC_MODE_OFF: EVO_HEATOFF, HVAC_MODE_HEAT: EVO_AUTO}
|
||||
HA_HVAC_TO_TCS = {HVACMode.OFF: EVO_HEATOFF, HVACMode.HEAT: EVO_AUTO}
|
||||
|
||||
TCS_PRESET_TO_HA = {
|
||||
EVO_AWAY: PRESET_AWAY,
|
||||
|
@ -199,9 +198,9 @@ class EvoZone(EvoChild, EvoClimateEntity):
|
|||
def hvac_mode(self) -> str:
|
||||
"""Return the current operating mode of a Zone."""
|
||||
if self._evo_tcs.systemModeStatus["mode"] in (EVO_AWAY, EVO_HEATOFF):
|
||||
return HVAC_MODE_AUTO
|
||||
return HVACMode.AUTO
|
||||
is_off = self.target_temperature <= self.min_temp
|
||||
return HVAC_MODE_OFF if is_off else HVAC_MODE_HEAT
|
||||
return HVACMode.OFF if is_off else HVACMode.HEAT
|
||||
|
||||
@property
|
||||
def target_temperature(self) -> float:
|
||||
|
@ -264,11 +263,11 @@ class EvoZone(EvoChild, EvoClimateEntity):
|
|||
regardless of any override mode, e.g. 'HeatingOff', Zones to (by default) 5C,
|
||||
and 'Away', Zones to (by default) 12C.
|
||||
"""
|
||||
if hvac_mode == HVAC_MODE_OFF:
|
||||
if hvac_mode == HVACMode.OFF:
|
||||
await self._evo_broker.call_client_api(
|
||||
self._evo_device.set_temperature(self.min_temp, until=None)
|
||||
)
|
||||
else: # HVAC_MODE_HEAT
|
||||
else: # HVACMode.HEAT
|
||||
await self._evo_broker.call_client_api(
|
||||
self._evo_device.cancel_temp_override()
|
||||
)
|
||||
|
@ -365,7 +364,7 @@ class EvoController(EvoClimateEntity):
|
|||
def hvac_mode(self) -> str:
|
||||
"""Return the current operating mode of a Controller."""
|
||||
tcs_mode = self._evo_tcs.systemModeStatus["mode"]
|
||||
return HVAC_MODE_OFF if tcs_mode == EVO_HEATOFF else HVAC_MODE_HEAT
|
||||
return HVACMode.OFF if tcs_mode == EVO_HEATOFF else HVACMode.HEAT
|
||||
|
||||
@property
|
||||
def current_temperature(self) -> float | None:
|
||||
|
|
Loading…
Add table
Reference in a new issue