From 5650b390b9f39121e1e94f8ff4757e2975fdecc8 Mon Sep 17 00:00:00 2001 From: jjlawren Date: Wed, 25 Mar 2020 18:03:26 -0500 Subject: [PATCH] Schedule Unifi shutdown callback earlier (#33257) --- homeassistant/components/unifi/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/unifi/__init__.py b/homeassistant/components/unifi/__init__.py index 27a11760461..e9f534360d7 100644 --- a/homeassistant/components/unifi/__init__.py +++ b/homeassistant/components/unifi/__init__.py @@ -40,6 +40,8 @@ async def async_setup_entry(hass, config_entry): controller_id = get_controller_id_from_config_entry(config_entry) hass.data[DOMAIN][controller_id] = controller + hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, controller.shutdown) + if controller.mac is None: return True @@ -53,8 +55,6 @@ async def async_setup_entry(hass, config_entry): # sw_version=config.raw['swversion'], ) - hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, controller.shutdown) - return True