use correct exception

This commit is contained in:
Thomas Protzner
2024-08-12 17:14:19 +00:00
parent 052aa3e203
commit b10ce49222

View File

@@ -8,6 +8,7 @@ from aioautomower.exceptions import (
ApiException,
AuthException,
HusqvarnaWSServerHandshakeError,
TimeoutException,
)
from aioautomower.model import MowerAttributes
from aioautomower.session import AutomowerSession
@@ -73,11 +74,16 @@ class AutomowerDataUpdateCoordinator(DataUpdateCoordinator[dict[str, MowerAttrib
await automower_client.auth.websocket_connect()
await automower_client.start_listening() # Ensure we catch errors here too
self.reconnect_time = DEFAULT_RECONNECT_TIME # Reset reconnect time after successful connection
except (HusqvarnaWSServerHandshakeError, Exception) as err:
except HusqvarnaWSServerHandshakeError as err:
_LOGGER.debug(
"Failed to connect to websocket. Trying to reconnect: %s",
err,
)
except TimeoutException as err:
_LOGGER.debug(
"Failed to listen to websocket. Trying to reconnect: %s",
err,
)
if not hass.is_stopping:
await asyncio.sleep(self.reconnect_time)
self.reconnect_time = min(self.reconnect_time * 2, MAX_WS_RECONNECT_TIME)