mirror of
https://github.com/home-assistant/core.git
synced 2025-08-24 15:01:36 +02:00
use correct exception
This commit is contained in:
@@ -8,6 +8,7 @@ from aioautomower.exceptions import (
|
|||||||
ApiException,
|
ApiException,
|
||||||
AuthException,
|
AuthException,
|
||||||
HusqvarnaWSServerHandshakeError,
|
HusqvarnaWSServerHandshakeError,
|
||||||
|
TimeoutException,
|
||||||
)
|
)
|
||||||
from aioautomower.model import MowerAttributes
|
from aioautomower.model import MowerAttributes
|
||||||
from aioautomower.session import AutomowerSession
|
from aioautomower.session import AutomowerSession
|
||||||
@@ -73,11 +74,16 @@ class AutomowerDataUpdateCoordinator(DataUpdateCoordinator[dict[str, MowerAttrib
|
|||||||
await automower_client.auth.websocket_connect()
|
await automower_client.auth.websocket_connect()
|
||||||
await automower_client.start_listening() # Ensure we catch errors here too
|
await automower_client.start_listening() # Ensure we catch errors here too
|
||||||
self.reconnect_time = DEFAULT_RECONNECT_TIME # Reset reconnect time after successful connection
|
self.reconnect_time = DEFAULT_RECONNECT_TIME # Reset reconnect time after successful connection
|
||||||
except (HusqvarnaWSServerHandshakeError, Exception) as err:
|
except HusqvarnaWSServerHandshakeError as err:
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Failed to connect to websocket. Trying to reconnect: %s",
|
"Failed to connect to websocket. Trying to reconnect: %s",
|
||||||
err,
|
err,
|
||||||
)
|
)
|
||||||
|
except TimeoutException as err:
|
||||||
|
_LOGGER.debug(
|
||||||
|
"Failed to listen to websocket. Trying to reconnect: %s",
|
||||||
|
err,
|
||||||
|
)
|
||||||
if not hass.is_stopping:
|
if not hass.is_stopping:
|
||||||
await asyncio.sleep(self.reconnect_time)
|
await asyncio.sleep(self.reconnect_time)
|
||||||
self.reconnect_time = min(self.reconnect_time * 2, MAX_WS_RECONNECT_TIME)
|
self.reconnect_time = min(self.reconnect_time * 2, MAX_WS_RECONNECT_TIME)
|
||||||
|
Reference in New Issue
Block a user