1
mirror of https://github.com/home-assistant/core synced 2024-09-06 10:29:55 +02:00

Prevent AttributError for uninitilized KNX ClimateMode (#45793)

This commit is contained in:
Matthias Alphart 2021-01-31 20:56:42 +01:00 committed by GitHub
parent e506d8616f
commit 868e530cbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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)