Handle ConnectionClosedException from System Bridge (#89654)

Handle unretrieved ConnectionClosedException from System Bridge
pull/86328/head
Aidan Timson 2023-03-14 00:55:37 +00:00 committed by GitHub
parent 6809bd3029
commit a99f6f7124
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -186,6 +186,12 @@ class SystemBridgeDataUpdateCoordinator(
await self.websocket_client.connect(
session=async_get_clientsession(self.hass),
)
self.hass.async_create_task(self._listen_for_data())
await self.websocket_client.register_data_listener(
RegisterDataListener(modules=MODULES)
)
except AuthenticationException as exception:
self.last_update_success = False
self.logger.error("Authentication failed for %s: %s", self.title, exception)
@ -211,12 +217,6 @@ class SystemBridgeDataUpdateCoordinator(
self.last_update_success = False
self.async_update_listeners()
self.hass.async_create_task(self._listen_for_data())
await self.websocket_client.register_data_listener(
RegisterDataListener(modules=MODULES)
)
self.last_update_success = True
self.async_update_listeners()