Fix exception after removing Shelly config entry and stopping HA (#51321)

* Fix device shutdown twice

* Change if logic
This commit is contained in:
Maciej Bieniek 2021-06-01 10:41:34 +02:00 committed by GitHub
parent b91696c139
commit ed9b199372
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -288,8 +288,10 @@ class ShellyDeviceWrapper(update_coordinator.DataUpdateCoordinator):
def shutdown(self):
"""Shutdown the wrapper."""
self.device.shutdown()
self._async_remove_device_updates_handler()
if self.device:
self.device.shutdown()
self._async_remove_device_updates_handler()
self.device = None
@callback
def _handle_ha_stop(self, _):