From 1b6660d8097d97e048a36b94a5fe469659b8db9f Mon Sep 17 00:00:00 2001 From: "Alan D. Tse" Date: Sun, 31 May 2020 15:35:05 -0700 Subject: [PATCH] fix: add retry to get_vehicles get_vehicles is the first command used by the controller. In case of a transient connection error, it will retry for up to 10 seconds. --- teslajsonpy/controller.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/teslajsonpy/controller.py b/teslajsonpy/controller.py index 52656f48..3a7f2cc7 100644 --- a/teslajsonpy/controller.py +++ b/teslajsonpy/controller.py @@ -12,6 +12,7 @@ import backoff import wrapt +from aiohttp import ClientConnectorError from teslajsonpy.battery_sensor import Battery, Range from teslajsonpy.binary_sensor import ( @@ -344,6 +345,7 @@ def register_websocket_callback(self, callback) -> int: self.__websocket_listeners.append(callback) return len(self.__websocket_listeners) - 1 + @backoff.on_exception(min_expo, ClientConnectorError, max_time=10, logger=__name__) async def get_vehicles(self): """Get vehicles json from TeslaAPI.""" return (await self.__connection.get("vehicles"))["response"]