Home Assistant Unofficial Reference 2024.12.1
water_heater.py
Go to the documentation of this file.
1 """Support for an Intergas boiler via an InComfort/Intouch Lan2RF gateway."""
2 
3 from __future__ import annotations
4 
5 import logging
6 from typing import Any
7 
8 from incomfortclient import Heater as InComfortHeater
9 
10 from homeassistant.components.water_heater import WaterHeaterEntity
11 from homeassistant.const import UnitOfTemperature
12 from homeassistant.core import HomeAssistant
13 from homeassistant.helpers.entity_platform import AddEntitiesCallback
14 
15 from . import InComfortConfigEntry
16 from .coordinator import InComfortDataCoordinator
17 from .entity import IncomfortBoilerEntity
18 
19 _LOGGER = logging.getLogger(__name__)
20 
21 HEATER_ATTRS = ["display_code", "display_text", "is_burning"]
22 
23 
25  hass: HomeAssistant,
26  entry: InComfortConfigEntry,
27  async_add_entities: AddEntitiesCallback,
28 ) -> None:
29  """Set up an InComfort/InTouch water_heater device."""
30  incomfort_coordinator = entry.runtime_data
31  heaters = incomfort_coordinator.data.heaters
32  async_add_entities(IncomfortWaterHeater(incomfort_coordinator, h) for h in heaters)
33 
34 
36  """Representation of an InComfort/Intouch water_heater device."""
37 
38  _attr_min_temp = 30.0
39  _attr_max_temp = 80.0
40  _attr_name = None
41  _attr_temperature_unit = UnitOfTemperature.CELSIUS
42  _attr_translation_key = "boiler"
43 
44  def __init__(
45  self, coordinator: InComfortDataCoordinator, heater: InComfortHeater
46  ) -> None:
47  """Initialize the water_heater device."""
48  super().__init__(coordinator, heater)
49  self._attr_unique_id_attr_unique_id = heater.serial_no
50 
51  @property
52  def extra_state_attributes(self) -> dict[str, Any]:
53  """Return the device state attributes."""
54  return {k: v for k, v in self._heater_heater.status.items() if k in HEATER_ATTRS}
55 
56  @property
57  def current_temperature(self) -> float | None:
58  """Return the current temperature."""
59  if self._heater_heater.is_tapping:
60  return self._heater_heater.tap_temp
61  if self._heater_heater.is_pumping:
62  return self._heater_heater.heater_temp
63  if self._heater_heater.heater_temp is None:
64  return self._heater_heater.tap_temp
65  if self._heater_heater.tap_temp is None:
66  return self._heater_heater.heater_temp
67  return max(self._heater_heater.heater_temp, self._heater_heater.tap_temp)
68 
69  @property
70  def current_operation(self) -> str | None:
71  """Return the current operation mode."""
72  return self._heater_heater.display_text
None __init__(self, InComfortDataCoordinator coordinator, InComfortHeater heater)
Definition: water_heater.py:46
None async_setup_entry(HomeAssistant hass, InComfortConfigEntry entry, AddEntitiesCallback async_add_entities)
Definition: water_heater.py:28