1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-19 18:38:58 +00:00

Bump Tesla Fleet to 1.3.0 (#159048)

This commit is contained in:
Brett Adams
2025-12-15 12:34:11 +10:00
committed by GitHub
parent e58fc6976d
commit 9b41bb09a7
6 changed files with 15 additions and 19 deletions

View File

@@ -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"]

View File

@@ -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"]
}

View File

@@ -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"]
}

View File

@@ -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"]
}

2
requirements_all.txt generated
View File

@@ -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

View File

@@ -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