From ed9b1993727a9a3967f5c667c8f0ad23b224e744 Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Tue, 1 Jun 2021 10:41:34 +0200 Subject: [PATCH] Fix exception after removing Shelly config entry and stopping HA (#51321) * Fix device shutdown twice * Change if logic --- homeassistant/components/shelly/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/shelly/__init__.py b/homeassistant/components/shelly/__init__.py index ab0facea920..4d7b8654720 100644 --- a/homeassistant/components/shelly/__init__.py +++ b/homeassistant/components/shelly/__init__.py @@ -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, _):