Home Assistant Unofficial Reference 2024.12.1
climate.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 from typing import Any
6 
7 from incomfortclient import Heater as InComfortHeater, Room as InComfortRoom
8 
10  ClimateEntity,
11  ClimateEntityFeature,
12  HVACAction,
13  HVACMode,
14 )
15 from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
16 from homeassistant.core import HomeAssistant
17 from homeassistant.helpers.device_registry import DeviceInfo
18 from homeassistant.helpers.entity_platform import AddEntitiesCallback
19 
20 from . import InComfortConfigEntry
21 from .const import DOMAIN
22 from .coordinator import InComfortDataCoordinator
23 from .entity import IncomfortEntity
24 
25 
27  hass: HomeAssistant,
28  entry: InComfortConfigEntry,
29  async_add_entities: AddEntitiesCallback,
30 ) -> None:
31  """Set up InComfort/InTouch climate devices."""
32  incomfort_coordinator = entry.runtime_data
33  heaters = incomfort_coordinator.data.heaters
35  InComfortClimate(incomfort_coordinator, h, r) for h in heaters for r in h.rooms
36  )
37 
38 
40  """Representation of an InComfort/InTouch climate device."""
41 
42  _attr_min_temp = 5.0
43  _attr_max_temp = 30.0
44  _attr_name = None
45  _attr_hvac_mode = HVACMode.HEAT
46  _attr_hvac_modes = [HVACMode.HEAT]
47  _attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
48  _attr_temperature_unit = UnitOfTemperature.CELSIUS
49  _enable_turn_on_off_backwards_compatibility = False
50 
51  def __init__(
52  self,
53  coordinator: InComfortDataCoordinator,
54  heater: InComfortHeater,
55  room: InComfortRoom,
56  ) -> None:
57  """Initialize the climate device."""
58  super().__init__(coordinator)
59 
60  self._heater_heater = heater
61  self._room_room = room
62 
63  self._attr_unique_id_attr_unique_id = f"{heater.serial_no}_{room.room_no}"
64  self._attr_device_info_attr_device_info = DeviceInfo(
65  identifiers={(DOMAIN, self._attr_unique_id_attr_unique_id)},
66  manufacturer="Intergas",
67  name=f"Thermostat {room.room_no}",
68  )
69 
70  @property
71  def extra_state_attributes(self) -> dict[str, Any]:
72  """Return the device state attributes."""
73  return {"status": self._room_room.status}
74 
75  @property
76  def current_temperature(self) -> float | None:
77  """Return the current temperature."""
78  return self._room_room.room_temp
79 
80  @property
81  def hvac_action(self) -> HVACAction | None:
82  """Return the actual current HVAC action."""
83  if self._heater_heater.is_burning and self._heater_heater.is_pumping:
84  return HVACAction.HEATING
85  return HVACAction.IDLE
86 
87  @property
88  def target_temperature(self) -> float | None:
89  """Return the (override)temperature we try to reach.
90 
91  As we set the override, we report back the override. The actual set point is
92  is returned at a later time.
93  Some older thermostats return 0.0 as override, in that case we fallback to
94  the actual setpoint.
95  """
96  return self._room_room.override or self._room_room.setpoint
97 
98  async def async_set_temperature(self, **kwargs: Any) -> None:
99  """Set a new target temperature for this zone."""
100  temperature = kwargs.get(ATTR_TEMPERATURE)
101  await self._room_room.set_override(temperature)
102  await self.coordinator.async_refresh()
103 
104  async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
105  """Set new target hvac mode."""
None __init__(self, InComfortDataCoordinator coordinator, InComfortHeater heater, InComfortRoom room)
Definition: climate.py:56
None async_set_hvac_mode(self, HVACMode hvac_mode)
Definition: climate.py:104
None async_setup_entry(HomeAssistant hass, InComfortConfigEntry entry, AddEntitiesCallback async_add_entities)
Definition: climate.py:30