1 """The water heater platform for the A. O. Smith integration."""
5 from py_aosmith.models
import OperationMode
as AOSmithOperationMode
13 WaterHeaterEntityFeature,
20 from .
import AOSmithConfigEntry
21 from .coordinator
import AOSmithStatusCoordinator
22 from .entity
import AOSmithStatusEntity
24 MODE_HA_TO_AOSMITH = {
25 STATE_ECO: AOSmithOperationMode.HYBRID,
26 STATE_ELECTRIC: AOSmithOperationMode.ELECTRIC,
27 STATE_HEAT_PUMP: AOSmithOperationMode.HEAT_PUMP,
28 STATE_OFF: AOSmithOperationMode.VACATION,
30 MODE_AOSMITH_TO_HA = {
31 AOSmithOperationMode.ELECTRIC: STATE_ELECTRIC,
32 AOSmithOperationMode.HEAT_PUMP: STATE_HEAT_PUMP,
33 AOSmithOperationMode.HYBRID: STATE_ECO,
34 AOSmithOperationMode.VACATION: STATE_OFF,
39 DEFAULT_OPERATION_MODE_PRIORITY = [
40 AOSmithOperationMode.HYBRID,
41 AOSmithOperationMode.HEAT_PUMP,
42 AOSmithOperationMode.ELECTRIC,
48 entry: AOSmithConfigEntry,
49 async_add_entities: AddEntitiesCallback,
51 """Set up A. O. Smith water heater platform."""
52 data = entry.runtime_data
56 for junction_id
in data.status_coordinator.data
61 """The water heater entity for the A. O. Smith integration."""
64 _attr_temperature_unit = UnitOfTemperature.FAHRENHEIT
69 coordinator: AOSmithStatusCoordinator,
72 """Initialize the entity."""
73 super().
__init__(coordinator, junction_id)
78 """Return the list of supported operation modes."""
80 for supported_mode
in self.
devicedevice.supported_modes:
81 ha_mode = MODE_AOSMITH_TO_HA.get(supported_mode.mode)
84 if ha_mode
is not None and ha_mode != STATE_OFF:
85 ha_modes.append(ha_mode)
91 """Return the list of supported features."""
92 supports_vacation_mode = any(
93 supported_mode.mode == AOSmithOperationMode.VACATION
94 for supported_mode
in self.
devicedevice.supported_modes
97 support_flags = WaterHeaterEntityFeature.TARGET_TEMPERATURE
101 support_flags |= WaterHeaterEntityFeature.OPERATION_MODE
103 if supports_vacation_mode:
104 support_flags |= WaterHeaterEntityFeature.AWAY_MODE
110 """Return the temperature we try to reach."""
111 return self.
devicedevice.status.temperature_setpoint
115 """Return the maximum temperature."""
116 return self.
devicedevice.status.temperature_setpoint_maximum
120 """Return the current operation mode."""
121 return MODE_AOSMITH_TO_HA.get(self.
devicedevice.status.current_mode, STATE_OFF)
125 """Return True if away mode is on."""
126 return self.
devicedevice.status.current_mode == AOSmithOperationMode.VACATION
129 """Set new target operation mode."""
133 aosmith_mode = MODE_HA_TO_AOSMITH.get(operation_mode)
134 if aosmith_mode
is not None:
135 await self.
clientclient.update_mode(self.junction_id, aosmith_mode)
140 """Set new target temperature."""
141 temperature = kwargs.get(
"temperature")
142 if temperature
is not None:
143 await self.
clientclient.update_setpoint(self.junction_id, temperature)
148 """Turn away mode on."""
149 await self.
clientclient.update_mode(self.junction_id, AOSmithOperationMode.VACATION)
154 """Turn away mode off."""
155 supported_aosmith_modes = [x.mode
for x
in self.
devicedevice.supported_modes]
157 for mode
in DEFAULT_OPERATION_MODE_PRIORITY:
158 if mode
in supported_aosmith_modes:
159 await self.
clientclient.update_mode(self.junction_id, mode)
AOSmithDevice device(self)
None async_turn_away_mode_on(self)
float|None target_temperature(self)
str current_operation(self)
WaterHeaterEntityFeature supported_features(self)
list[str] operation_list(self)
def is_away_mode_on(self)
None __init__(self, AOSmithStatusCoordinator coordinator, str junction_id)
None async_turn_away_mode_off(self)
None async_set_temperature(self, **Any kwargs)
None async_set_operation_mode(self, str operation_mode)
list[str]|None operation_list(self)
None async_request_refresh(self)
None async_setup_entry(HomeAssistant hass, AOSmithConfigEntry entry, AddEntitiesCallback async_add_entities)