diff --git a/homeassistant/components/knx/climate.py b/homeassistant/components/knx/climate.py index 298ae391fe4..1a4b15c4265 100644 --- a/homeassistant/components/knx/climate.py +++ b/homeassistant/components/knx/climate.py @@ -324,3 +324,15 @@ class KNXClimate(KnxEntity, ClimateEntity): knx_operation_mode = HVACOperationMode(PRESET_MODES_INV.get(preset_mode)) await self._device.mode.set_operation_mode(knx_operation_mode) self.async_write_ha_state() + + async def async_added_to_hass(self) -> None: + """Store register state change callback.""" + super().async_added_to_hass() + if self._device.mode is not None: + self._device.mode.register_device_updated_cb(self.after_update_callback) + + async def async_will_remove_from_hass(self) -> None: + """Disconnect device object when removed.""" + super().async_will_remove_from_hass() + if self._device.mode is not None: + self._device.mode.unregister_device_updated_cb(self.after_update_callback) diff --git a/homeassistant/components/knx/knx_entity.py b/homeassistant/components/knx/knx_entity.py index 1e374250bba..a85fb2a561f 100644 --- a/homeassistant/components/knx/knx_entity.py +++ b/homeassistant/components/knx/knx_entity.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import cast -from xknx.devices import Climate as XknxClimate, Device as XknxDevice +from xknx.devices import Device as XknxDevice from homeassistant.helpers.entity import Entity @@ -52,12 +52,6 @@ class KnxEntity(Entity): """Store register state change callback.""" self._device.register_device_updated_cb(self.after_update_callback) - if isinstance(self._device, XknxClimate) and self._device.mode is not None: - self._device.mode.register_device_updated_cb(self.after_update_callback) - async def async_will_remove_from_hass(self) -> None: """Disconnect device object when removed.""" self._device.unregister_device_updated_cb(self.after_update_callback) - - if isinstance(self._device, XknxClimate) and self._device.mode is not None: - self._device.mode.unregister_device_updated_cb(self.after_update_callback) diff --git a/homeassistant/components/knx/manifest.json b/homeassistant/components/knx/manifest.json index e9a76a4ef57..8f46f904466 100644 --- a/homeassistant/components/knx/manifest.json +++ b/homeassistant/components/knx/manifest.json @@ -2,7 +2,7 @@ "domain": "knx", "name": "KNX", "documentation": "https://www.home-assistant.io/integrations/knx", - "requirements": ["xknx==0.18.6"], + "requirements": ["xknx==0.18.7"], "codeowners": ["@Julius2342", "@farmio", "@marvin-w"], "quality_scale": "silver", "iot_class": "local_push" diff --git a/requirements_all.txt b/requirements_all.txt index 136dad05b50..86625ff62f9 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2380,7 +2380,7 @@ xbox-webapi==2.0.11 xboxapi==2.0.1 # homeassistant.components.knx -xknx==0.18.6 +xknx==0.18.7 # homeassistant.components.bluesound # homeassistant.components.rest diff --git a/requirements_test_all.txt b/requirements_test_all.txt index aa4d61cc095..e67f854571e 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1292,7 +1292,7 @@ wolf_smartset==0.1.11 xbox-webapi==2.0.11 # homeassistant.components.knx -xknx==0.18.6 +xknx==0.18.7 # homeassistant.components.bluesound # homeassistant.components.rest