mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 14:57:09 +00:00
Use climate enums in evohome (#70639)
This commit is contained in:
parent
d52234a57a
commit
0cdfd386a7
@ -4,15 +4,14 @@ from __future__ import annotations
|
|||||||
from datetime import datetime as dt
|
from datetime import datetime as dt
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
|
from homeassistant.components.climate import ClimateEntity
|
||||||
from homeassistant.components.climate.const import (
|
from homeassistant.components.climate.const import (
|
||||||
HVAC_MODE_AUTO,
|
|
||||||
HVAC_MODE_HEAT,
|
|
||||||
HVAC_MODE_OFF,
|
|
||||||
PRESET_AWAY,
|
PRESET_AWAY,
|
||||||
PRESET_ECO,
|
PRESET_ECO,
|
||||||
PRESET_HOME,
|
PRESET_HOME,
|
||||||
PRESET_NONE,
|
PRESET_NONE,
|
||||||
|
ClimateEntityFeature,
|
||||||
|
HVACMode,
|
||||||
)
|
)
|
||||||
from homeassistant.const import PRECISION_TENTHS
|
from homeassistant.const import PRECISION_TENTHS
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -51,7 +50,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
PRESET_RESET = "Reset" # reset all child zones to EVO_FOLLOW
|
PRESET_RESET = "Reset" # reset all child zones to EVO_FOLLOW
|
||||||
PRESET_CUSTOM = "Custom"
|
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 = {
|
TCS_PRESET_TO_HA = {
|
||||||
EVO_AWAY: PRESET_AWAY,
|
EVO_AWAY: PRESET_AWAY,
|
||||||
@ -199,9 +198,9 @@ class EvoZone(EvoChild, EvoClimateEntity):
|
|||||||
def hvac_mode(self) -> str:
|
def hvac_mode(self) -> str:
|
||||||
"""Return the current operating mode of a Zone."""
|
"""Return the current operating mode of a Zone."""
|
||||||
if self._evo_tcs.systemModeStatus["mode"] in (EVO_AWAY, EVO_HEATOFF):
|
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
|
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
|
@property
|
||||||
def target_temperature(self) -> float:
|
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,
|
regardless of any override mode, e.g. 'HeatingOff', Zones to (by default) 5C,
|
||||||
and 'Away', Zones to (by default) 12C.
|
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(
|
await self._evo_broker.call_client_api(
|
||||||
self._evo_device.set_temperature(self.min_temp, until=None)
|
self._evo_device.set_temperature(self.min_temp, until=None)
|
||||||
)
|
)
|
||||||
else: # HVAC_MODE_HEAT
|
else: # HVACMode.HEAT
|
||||||
await self._evo_broker.call_client_api(
|
await self._evo_broker.call_client_api(
|
||||||
self._evo_device.cancel_temp_override()
|
self._evo_device.cancel_temp_override()
|
||||||
)
|
)
|
||||||
@ -365,7 +364,7 @@ class EvoController(EvoClimateEntity):
|
|||||||
def hvac_mode(self) -> str:
|
def hvac_mode(self) -> str:
|
||||||
"""Return the current operating mode of a Controller."""
|
"""Return the current operating mode of a Controller."""
|
||||||
tcs_mode = self._evo_tcs.systemModeStatus["mode"]
|
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
|
@property
|
||||||
def current_temperature(self) -> float | None:
|
def current_temperature(self) -> float | None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user