hass-core/homeassistant/components/incomfort/climate.py
Jan Bouwhuis dd1dd4c6a3
Migrate Intergas InComfort/Intouch Lan2RF gateway YAML to config flow (#118642)
* Add config flow

* Make sure the device is polled - refactor

* Fix

* Add tests config flow

* Update test requirements

* Ensure dispatcher has a unique signal per heater

* Followup on review

* Follow up comments

* One more docstr

* Make specific try blocks and refactoring

* Handle import exceptions

* Restore removed lines

* Move initial heater update in try block

* Raise issue failed import

* Update test codeowners

* Remove entity device info

* Remove entity device info

* Appy suggestions from code review

* Remove broad exception handling from entry setup

* Test coverage
2024-06-03 20:37:48 +02:00

84 lines
2.6 KiB
Python

"""Support for an Intergas boiler via an InComfort/InTouch Lan2RF gateway."""
from __future__ import annotations
from typing import Any
from incomfortclient import (
Gateway as InComfortGateway,
Heater as InComfortHeater,
Room as InComfortRoom,
)
from homeassistant.components.climate import (
ClimateEntity,
ClimateEntityFeature,
HVACMode,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import DATA_INCOMFORT, IncomfortEntity
async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up InComfort/InTouch climate devices."""
incomfort_data = hass.data[DATA_INCOMFORT][entry.entry_id]
async_add_entities(
InComfortClimate(incomfort_data.client, h, r)
for h in incomfort_data.heaters
for r in h.rooms
)
class InComfortClimate(IncomfortEntity, ClimateEntity):
"""Representation of an InComfort/InTouch climate device."""
_attr_min_temp = 5.0
_attr_max_temp = 30.0
_attr_hvac_mode = HVACMode.HEAT
_attr_hvac_modes = [HVACMode.HEAT]
_attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
_attr_temperature_unit = UnitOfTemperature.CELSIUS
_enable_turn_on_off_backwards_compatibility = False
def __init__(
self, client: InComfortGateway, heater: InComfortHeater, room: InComfortRoom
) -> None:
"""Initialize the climate device."""
super().__init__()
self._client = client
self._room = room
self._attr_unique_id = f"{heater.serial_no}_{room.room_no}"
self._attr_name = f"Thermostat {room.room_no}"
@property
def extra_state_attributes(self) -> dict[str, Any]:
"""Return the device state attributes."""
return {"status": self._room.status}
@property
def current_temperature(self) -> float | None:
"""Return the current temperature."""
return self._room.room_temp
@property
def target_temperature(self) -> float | None:
"""Return the temperature we try to reach."""
return self._room.setpoint
async def async_set_temperature(self, **kwargs: Any) -> None:
"""Set a new target temperature for this zone."""
temperature = kwargs.get(ATTR_TEMPERATURE)
await self._room.set_override(temperature)
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
"""Set new target hvac mode."""