mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Only allow one Mazda vehicle status request at a time (#53736)
This commit is contained in:
parent
7ae158f9a1
commit
96b02153b9
@ -28,7 +28,6 @@ from homeassistant.helpers.update_coordinator import (
|
||||
DataUpdateCoordinator,
|
||||
UpdateFailed,
|
||||
)
|
||||
from homeassistant.util.async_ import gather_with_concurrency
|
||||
|
||||
from .const import DATA_CLIENT, DATA_COORDINATOR, DATA_VEHICLES, DOMAIN, SERVICES
|
||||
|
||||
@ -143,14 +142,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
try:
|
||||
vehicles = await with_timeout(mazda_client.get_vehicles())
|
||||
|
||||
vehicle_status_tasks = [
|
||||
with_timeout(mazda_client.get_vehicle_status(vehicle["id"]))
|
||||
for vehicle in vehicles
|
||||
]
|
||||
statuses = await gather_with_concurrency(5, *vehicle_status_tasks)
|
||||
|
||||
for vehicle, status in zip(vehicles, statuses):
|
||||
vehicle["status"] = status
|
||||
# The Mazda API can throw an error when multiple simultaneous requests are
|
||||
# made for the same account, so we can only make one request at a time here
|
||||
for vehicle in vehicles:
|
||||
vehicle["status"] = await with_timeout(
|
||||
mazda_client.get_vehicle_status(vehicle["id"])
|
||||
)
|
||||
|
||||
hass.data[DOMAIN][entry.entry_id][DATA_VEHICLES] = vehicles
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user