1 """Support for WaterHeater entities of the Evohome integration."""
3 from __future__
import annotations
6 from typing
import TYPE_CHECKING, Any
8 import evohomeasync2
as evo
9 from evohomeasync2.schema.const
import (
15 SZ_TEMPERATURE_STATUS,
20 WaterHeaterEntityFeature,
34 from .const
import DOMAIN, EVO_FOLLOW, EVO_PERMOVER
35 from .entity
import EvoChild
38 from .
import EvoBroker
41 _LOGGER = logging.getLogger(__name__)
45 HA_STATE_TO_EVO = {STATE_AUTO:
"", STATE_ON: SZ_ON, STATE_OFF: SZ_OFF}
46 EVO_STATE_TO_HA = {v: k
for k, v
in HA_STATE_TO_EVO.items()
if k !=
""}
48 STATE_ATTRS_DHW = [SZ_DHW_ID, SZ_ACTIVE_FAULTS, SZ_STATE_STATUS, SZ_TEMPERATURE_STATUS]
54 async_add_entities: AddEntitiesCallback,
55 discovery_info: DiscoveryInfoType |
None =
None,
57 """Create a DHW controller."""
58 if discovery_info
is None:
61 broker: EvoBroker = hass.data[DOMAIN][
"broker"]
63 assert broker.tcs.hotwater
is not None
66 "Adding: DhwController (%s), id=%s",
67 broker.tcs.hotwater.TYPE,
68 broker.tcs.hotwater.dhwId,
71 new_entity =
EvoDHW(broker, broker.tcs.hotwater)
77 """Base for any evohome-compatible DHW controller."""
79 _attr_name =
"DHW controller"
80 _attr_icon =
"mdi:thermometer-lines"
81 _attr_operation_list =
list(HA_STATE_TO_EVO)
82 _attr_temperature_unit = UnitOfTemperature.CELSIUS
84 _evo_device: evo.HotWater
86 def __init__(self, evo_broker: EvoBroker, evo_device: evo.HotWater) ->
None:
87 """Initialize an evohome-compatible DHW controller."""
89 super().
__init__(evo_broker, evo_device)
96 PRECISION_TENTHS
if evo_broker.client_v1
else PRECISION_WHOLE
99 WaterHeaterEntityFeature.AWAY_MODE | WaterHeaterEntityFeature.OPERATION_MODE
104 """Return the current operating mode (Auto, On, or Off)."""
107 if (device_state := self.
_evo_device_evo_device.state)
is None:
109 return EVO_STATE_TO_HA[device_state]
113 """Return True if away mode is on."""
116 is_off = EVO_STATE_TO_HA[self.
_evo_device_evo_device.state] == STATE_OFF
117 is_permanent = self.
_evo_device_evo_device.mode == EVO_PERMOVER
118 return is_off
and is_permanent
121 """Set new operation mode for a DHW controller.
123 Except for Auto, the mode is only until the next SetPoint.
125 if operation_mode == STATE_AUTO:
129 until = dt_util.parse_datetime(self.
setpointssetpoints.
get(
"next_sp_from",
""))
130 until = dt_util.as_utc(until)
if until
else None
132 if operation_mode == STATE_ON:
142 """Turn away mode on."""
146 """Turn away mode off."""
158 """Get the latest state data for a DHW controller."""
161 for attr
in STATE_ATTRS_DHW:
None _update_schedule(self)
dict[str, Any] setpoints(self)
None async_turn_away_mode_on(self)
str|None current_operation(self)
None async_turn_away_mode_off(self)
None __init__(self, EvoBroker evo_broker, evo.HotWater evo_device)
None async_set_operation_mode(self, str operation_mode)
bool|None is_away_mode_on(self)
None async_turn_on(self, **Any kwargs)
None async_turn_off(self, **Any kwargs)
web.Response get(self, web.Request request, str config_key)
None async_setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback async_add_entities, DiscoveryInfoType|None discovery_info=None)