Prevent AttributError for uninitilized KNX ClimateMode (#45793)
parent
e506d8616f
commit
868e530cbb
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue