From 76f88459dd288d3e5617b4bbb6fa531aacf1cb12 Mon Sep 17 00:00:00 2001 From: Aaron Bach Date: Thu, 15 Oct 2020 22:13:45 -0600 Subject: [PATCH] Fix incorrect SimpliSafe websocket disconnect listener (#41923) --- homeassistant/components/simplisafe/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/simplisafe/__init__.py b/homeassistant/components/simplisafe/__init__.py index 37fa1761c6b..241d7d48026 100644 --- a/homeassistant/components/simplisafe/__init__.py +++ b/homeassistant/components/simplisafe/__init__.py @@ -449,8 +449,13 @@ class SimpliSafe: async def async_init(self): """Initialize the data class.""" asyncio.create_task(self.websocket.async_connect()) + + async def async_websocket_disconnect(_): + """Define an event handler to disconnect from the websocket.""" + await self.websocket.async_disconnect() + self._hass.bus.async_listen_once( - EVENT_HOMEASSISTANT_STOP, self.websocket.async_disconnect() + EVENT_HOMEASSISTANT_STOP, async_websocket_disconnect ) self.systems = await self._api.get_systems()