From 5bc4db5ef96236c4365012f78068abc02b0c8d12 Mon Sep 17 00:00:00 2001 From: Shay Levy Date: Wed, 27 Jan 2021 15:15:56 +0200 Subject: [PATCH] Fix exception when last Shelly device is removed (#45476) --- homeassistant/components/shelly/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/homeassistant/components/shelly/utils.py b/homeassistant/components/shelly/utils.py index 2a78343440b..97d8bda609b 100644 --- a/homeassistant/components/shelly/utils.py +++ b/homeassistant/components/shelly/utils.py @@ -172,6 +172,9 @@ def get_input_triggers( def get_device_wrapper(hass: HomeAssistant, device_id: str): """Get a Shelly device wrapper for the given device id.""" + if not hass.data.get(DOMAIN): + return None + for config_entry in hass.data[DOMAIN][DATA_CONFIG_ENTRY]: wrapper = hass.data[DOMAIN][DATA_CONFIG_ENTRY][config_entry][COAP]