From 868e530cbb04ca500a266ea60283c58a3e287b9d Mon Sep 17 00:00:00 2001 From: Matthias Alphart Date: Sun, 31 Jan 2021 20:56:42 +0100 Subject: [PATCH] Prevent AttributError for uninitilized KNX ClimateMode (#45793) --- homeassistant/components/knx/knx_entity.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/knx/knx_entity.py b/homeassistant/components/knx/knx_entity.py index 296bcb2f540..f4597ad230e 100644 --- a/homeassistant/components/knx/knx_entity.py +++ b/homeassistant/components/knx/knx_entity.py @@ -40,12 +40,12 @@ class KnxEntity(Entity): """Store register state change callback.""" self._device.register_device_updated_cb(self.after_update_callback) - if isinstance(self._device, XknxClimate): + 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): + if isinstance(self._device, XknxClimate) and self._device.mode is not None: self._device.mode.unregister_device_updated_cb(self.after_update_callback)