Home Assistant Unofficial Reference 2024.12.1
water_heater.py
Go to the documentation of this file.
1 """ATAG water heater component."""
2 
3 from typing import Any
4 
6  STATE_ECO,
7  STATE_PERFORMANCE,
8  WaterHeaterEntity,
9 )
10 from homeassistant.const import ATTR_TEMPERATURE, STATE_OFF, Platform, UnitOfTemperature
11 from homeassistant.core import HomeAssistant
12 from homeassistant.helpers.entity_platform import AddEntitiesCallback
13 
14 from .coordinator import AtagConfigEntry
15 from .entity import AtagEntity
16 
17 OPERATION_LIST = [STATE_OFF, STATE_ECO, STATE_PERFORMANCE]
18 
19 
21  hass: HomeAssistant,
22  config_entry: AtagConfigEntry,
23  async_add_entities: AddEntitiesCallback,
24 ) -> None:
25  """Initialize DHW device from config entry."""
27  [AtagWaterHeater(config_entry.runtime_data, Platform.WATER_HEATER)]
28  )
29 
30 
32  """Representation of an ATAG water heater."""
33 
34  _attr_operation_list = OPERATION_LIST
35  _attr_temperature_unit = UnitOfTemperature.CELSIUS
36 
37  @property
39  """Return the current temperature."""
40  return self.coordinator.atag.dhw.temperature
41 
42  @property
43  def current_operation(self):
44  """Return current operation."""
45  operation = self.coordinator.atag.dhw.current_operation
46  return operation if operation in self.operation_listoperation_list else STATE_OFF
47 
48  async def async_set_temperature(self, **kwargs: Any) -> None:
49  """Set new target temperature."""
50  if await self.coordinator.atag.dhw.set_temp(kwargs.get(ATTR_TEMPERATURE)):
51  self.async_write_ha_stateasync_write_ha_state()
52 
53  @property
54  def target_temperature(self):
55  """Return the setpoint if water demand, otherwise return base temp (comfort level)."""
56  return self.coordinator.atag.dhw.target_temperature
57 
58  @property
59  def max_temp(self) -> float:
60  """Return the maximum temperature."""
61  return self.coordinator.atag.dhw.max_temp
62 
63  @property
64  def min_temp(self) -> float:
65  """Return the minimum temperature."""
66  return self.coordinator.atag.dhw.min_temp
None async_setup_entry(HomeAssistant hass, AtagConfigEntry config_entry, AddEntitiesCallback async_add_entities)
Definition: water_heater.py:24