From 315febe165d2c5ead154abd4c2125199c4a77fc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Seux?= Date: Sat, 14 Dec 2024 18:00:58 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=AD=20Compatibility=20with=20HA=202025?= =?UTF-8?q?.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/home-assistant/core/pull/132888 broke backward compatibility. This patch will make this integration compatible with 2025.1 and still be backward compatible with earlier version --- custom_components/aquarea/water_heater.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/custom_components/aquarea/water_heater.py b/custom_components/aquarea/water_heater.py index a16a0da..6412c12 100644 --- a/custom_components/aquarea/water_heater.py +++ b/custom_components/aquarea/water_heater.py @@ -11,12 +11,19 @@ from homeassistant.components.mqtt.client import async_publish from homeassistant.components.water_heater import ( - WaterHeaterEntityEntityDescription, WaterHeaterEntity, WaterHeaterEntityFeature, STATE_ECO, STATE_PERFORMANCE, ) +try: + from homeassistant.components.water_heater import WaterHeaterEntityDescription +except ImportError: + # compatibility code for HA < 2025.1 + from homeassistant.components.water_heater import WaterHeaterEntityEntityDescription + WaterHeaterEntityDescription = WaterHeaterEntityEntityDescription + + from .definitions import OperatingMode from . import build_device_info @@ -37,7 +44,7 @@ async def async_setup_entry( f"Starting bootstrap of water heater entities with prefix '{discovery_prefix}'" ) """Set up HeishaMon water heater from config entry.""" - description = WaterHeaterEntityEntityDescription( + description = WaterHeaterEntityDescription( key=f"{discovery_prefix}main/DHW_Target_Temp", name="Aquarea Domestic Water Heater", ) @@ -62,7 +69,7 @@ class HeishaMonDHW(WaterHeaterEntity): def __init__( self, hass: HomeAssistant, - description: WaterHeaterEntityEntityDescription, + description: WaterHeaterEntityDescription, config_entry: ConfigEntry, ) -> None: """Initialize the water heater entity."""