From 9b41bb09a74785d332af23c3f65a7e729a9c4930 Mon Sep 17 00:00:00 2001 From: Brett Adams Date: Mon, 15 Dec 2025 12:34:11 +1000 Subject: [PATCH] Bump Tesla Fleet to 1.3.0 (#159048) --- .../components/tesla_fleet/__init__.py | 24 ++++++++----------- .../components/tesla_fleet/manifest.json | 2 +- .../components/teslemetry/manifest.json | 2 +- homeassistant/components/tessie/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 6 files changed, 15 insertions(+), 19 deletions(-) diff --git a/homeassistant/components/tesla_fleet/__init__.py b/homeassistant/components/tesla_fleet/__init__.py index 3e14e5ad2b2..38a5900fcc1 100644 --- a/homeassistant/components/tesla_fleet/__init__.py +++ b/homeassistant/components/tesla_fleet/__init__.py @@ -1,6 +1,5 @@ """Tesla Fleet integration.""" -import asyncio from typing import Final from aiohttp.client_exceptions import ClientResponseError @@ -83,29 +82,26 @@ async def async_setup_entry(hass: HomeAssistant, entry: TeslaFleetConfigEntry) - region: str = token["ou_code"].lower() oauth_session = OAuth2Session(hass, entry, implementation) - refresh_lock = asyncio.Lock() - async def _refresh_token() -> str: - async with refresh_lock: - try: - await oauth_session.async_ensure_token_valid() - except ClientResponseError as e: - if e.status == 401: - raise ConfigEntryAuthFailed from e - raise ConfigEntryNotReady from e - token: str = oauth_session.token[CONF_ACCESS_TOKEN] - return token + async def _get_access_token() -> str: + try: + await oauth_session.async_ensure_token_valid() + except ClientResponseError as e: + if e.status == 401: + raise ConfigEntryAuthFailed from e + raise ConfigEntryNotReady from e + token: str = oauth_session.token[CONF_ACCESS_TOKEN] + return token # Create API connection tesla = TeslaFleetApi( session=session, - access_token=access_token, + access_token=_get_access_token, region=region, charging_scope=False, partner_scope=False, energy_scope=Scope.ENERGY_DEVICE_DATA in scopes, vehicle_scope=Scope.VEHICLE_DEVICE_DATA in scopes, - refresh_hook=_refresh_token, ) try: products = (await tesla.products())["response"] diff --git a/homeassistant/components/tesla_fleet/manifest.json b/homeassistant/components/tesla_fleet/manifest.json index 549f0a29ac2..b05722af3e1 100644 --- a/homeassistant/components/tesla_fleet/manifest.json +++ b/homeassistant/components/tesla_fleet/manifest.json @@ -8,5 +8,5 @@ "integration_type": "hub", "iot_class": "cloud_polling", "loggers": ["tesla-fleet-api"], - "requirements": ["tesla-fleet-api==1.2.7"] + "requirements": ["tesla-fleet-api==1.3.0"] } diff --git a/homeassistant/components/teslemetry/manifest.json b/homeassistant/components/teslemetry/manifest.json index b40a67dbff0..c67cc6463b1 100644 --- a/homeassistant/components/teslemetry/manifest.json +++ b/homeassistant/components/teslemetry/manifest.json @@ -7,5 +7,5 @@ "integration_type": "hub", "iot_class": "cloud_polling", "loggers": ["tesla-fleet-api"], - "requirements": ["tesla-fleet-api==1.2.7", "teslemetry-stream==0.7.10"] + "requirements": ["tesla-fleet-api==1.3.0", "teslemetry-stream==0.7.10"] } diff --git a/homeassistant/components/tessie/manifest.json b/homeassistant/components/tessie/manifest.json index a81197445a0..2025c9c2eae 100644 --- a/homeassistant/components/tessie/manifest.json +++ b/homeassistant/components/tessie/manifest.json @@ -7,5 +7,5 @@ "integration_type": "hub", "iot_class": "cloud_polling", "loggers": ["tessie", "tesla-fleet-api"], - "requirements": ["tessie-api==0.1.1", "tesla-fleet-api==1.2.7"] + "requirements": ["tessie-api==0.1.1", "tesla-fleet-api==1.3.0"] } diff --git a/requirements_all.txt b/requirements_all.txt index 98e28a0af99..14d24d7d621 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2978,7 +2978,7 @@ temperusb==1.6.1 # homeassistant.components.tesla_fleet # homeassistant.components.teslemetry # homeassistant.components.tessie -tesla-fleet-api==1.2.7 +tesla-fleet-api==1.3.0 # homeassistant.components.powerwall tesla-powerwall==0.5.2 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 31ae7f58a85..1488a9dbd13 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -2478,7 +2478,7 @@ temperusb==1.6.1 # homeassistant.components.tesla_fleet # homeassistant.components.teslemetry # homeassistant.components.tessie -tesla-fleet-api==1.2.7 +tesla-fleet-api==1.3.0 # homeassistant.components.powerwall tesla-powerwall==0.5.2