2019-05-07 21:53:55 +00:00
|
|
|
"""Support for an Intergas boiler via an InComfort/Intouch Lan2RF gateway."""
|
2024-03-08 13:52:48 +00:00
|
|
|
|
2021-03-18 09:02:00 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2019-05-07 21:53:55 +00:00
|
|
|
import logging
|
2021-03-18 09:02:00 +00:00
|
|
|
from typing import Any
|
2019-05-07 21:53:55 +00:00
|
|
|
|
2024-06-05 08:45:01 +00:00
|
|
|
from incomfortclient import Heater as InComfortHeater
|
2019-10-20 18:48:52 +00:00
|
|
|
|
2024-06-03 06:32:05 +00:00
|
|
|
from homeassistant.components.water_heater import WaterHeaterEntity
|
2022-12-05 10:42:15 +00:00
|
|
|
from homeassistant.const import UnitOfTemperature
|
2022-01-03 15:26:14 +00:00
|
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
2019-05-07 21:53:55 +00:00
|
|
|
|
2024-06-05 08:45:01 +00:00
|
|
|
from . import InComfortConfigEntry
|
|
|
|
from .coordinator import InComfortDataCoordinator
|
2024-06-05 11:09:24 +00:00
|
|
|
from .entity import IncomfortBoilerEntity
|
2019-05-07 21:53:55 +00:00
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
2019-09-30 08:31:35 +00:00
|
|
|
HEATER_ATTRS = ["display_code", "display_text", "is_burning"]
|
2019-05-07 21:53:55 +00:00
|
|
|
|
|
|
|
|
2024-06-03 18:37:48 +00:00
|
|
|
async def async_setup_entry(
|
2022-01-03 15:26:14 +00:00
|
|
|
hass: HomeAssistant,
|
2024-06-05 08:45:01 +00:00
|
|
|
entry: InComfortConfigEntry,
|
2022-01-03 15:26:14 +00:00
|
|
|
async_add_entities: AddEntitiesCallback,
|
|
|
|
) -> None:
|
2024-06-03 18:37:48 +00:00
|
|
|
"""Set up an InComfort/InTouch water_heater device."""
|
2024-06-05 08:45:01 +00:00
|
|
|
incomfort_coordinator = entry.runtime_data
|
|
|
|
heaters = incomfort_coordinator.data.heaters
|
|
|
|
async_add_entities(IncomfortWaterHeater(incomfort_coordinator, h) for h in heaters)
|
2019-05-07 21:53:55 +00:00
|
|
|
|
|
|
|
|
2024-06-05 11:09:24 +00:00
|
|
|
class IncomfortWaterHeater(IncomfortBoilerEntity, WaterHeaterEntity):
|
2019-05-07 21:53:55 +00:00
|
|
|
"""Representation of an InComfort/Intouch water_heater device."""
|
|
|
|
|
2024-06-03 06:32:05 +00:00
|
|
|
_attr_min_temp = 30.0
|
|
|
|
_attr_max_temp = 80.0
|
2024-06-03 19:30:13 +00:00
|
|
|
_attr_name = None
|
2024-06-03 06:32:05 +00:00
|
|
|
_attr_temperature_unit = UnitOfTemperature.CELSIUS
|
2024-06-10 05:46:07 +00:00
|
|
|
_attr_translation_key = "boiler"
|
2024-06-03 06:32:05 +00:00
|
|
|
|
2024-06-05 08:45:01 +00:00
|
|
|
def __init__(
|
|
|
|
self, coordinator: InComfortDataCoordinator, heater: InComfortHeater
|
|
|
|
) -> None:
|
2019-05-07 21:53:55 +00:00
|
|
|
"""Initialize the water_heater device."""
|
2024-06-05 11:09:24 +00:00
|
|
|
super().__init__(coordinator, heater)
|
2024-06-03 06:32:05 +00:00
|
|
|
self._attr_unique_id = heater.serial_no
|
|
|
|
|
2019-05-07 21:53:55 +00:00
|
|
|
@property
|
2021-03-18 09:02:00 +00:00
|
|
|
def extra_state_attributes(self) -> dict[str, Any]:
|
2019-05-07 21:53:55 +00:00
|
|
|
"""Return the device state attributes."""
|
2019-09-30 08:31:35 +00:00
|
|
|
return {k: v for k, v in self._heater.status.items() if k in HEATER_ATTRS}
|
2019-05-07 21:53:55 +00:00
|
|
|
|
|
|
|
@property
|
2024-10-31 13:57:09 +00:00
|
|
|
def current_temperature(self) -> float | None:
|
2019-05-07 21:53:55 +00:00
|
|
|
"""Return the current temperature."""
|
|
|
|
if self._heater.is_tapping:
|
|
|
|
return self._heater.tap_temp
|
2019-06-19 16:03:18 +00:00
|
|
|
if self._heater.is_pumping:
|
|
|
|
return self._heater.heater_temp
|
2024-10-31 13:57:09 +00:00
|
|
|
if self._heater.heater_temp is None:
|
|
|
|
return self._heater.tap_temp
|
|
|
|
if self._heater.tap_temp is None:
|
|
|
|
return self._heater.heater_temp
|
2019-06-19 16:03:18 +00:00
|
|
|
return max(self._heater.heater_temp, self._heater.tap_temp)
|
2019-05-07 21:53:55 +00:00
|
|
|
|
|
|
|
@property
|
2024-06-10 17:30:12 +00:00
|
|
|
def current_operation(self) -> str | None:
|
2019-05-07 21:53:55 +00:00
|
|
|
"""Return the current operation mode."""
|
|
|
|
return self._heater.display_text
|