Prevent AttributError for uninitilized KNX ClimateMode (#45793)

This commit is contained in:
Matthias Alphart
2021-02-01 22:31:00 +00:00
committed by Paulus Schoutsen
parent 53db89e13d
commit 4f73105896
+2 -2
View File
@@ -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)