Set renault quality scale to platinum (#85753)

* Set renault quality scale to platinum

* Ensure coordinators do not run at the same time

* Add comment
This commit is contained in:
epenet 2023-01-17 11:50:17 +01:00 committed by GitHub
parent 1918f21fb1
commit b7f484a84f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -7,5 +7,6 @@
"requirements": ["renault-api==0.1.11"], "requirements": ["renault-api==0.1.11"],
"codeowners": ["@epenet"], "codeowners": ["@epenet"],
"iot_class": "cloud_polling", "iot_class": "cloud_polling",
"loggers": ["renault_api"] "loggers": ["renault_api"],
"quality_scale": "platinum"
} }

View File

@ -1,6 +1,7 @@
"""Proxy to handle account communication with Renault servers.""" """Proxy to handle account communication with Renault servers."""
from __future__ import annotations from __future__ import annotations
import asyncio
from collections.abc import Awaitable, Callable from collections.abc import Awaitable, Callable
from datetime import timedelta from datetime import timedelta
import logging import logging
@ -18,6 +19,9 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, Upda
T = TypeVar("T", bound=Optional[KamereonVehicleDataAttributes]) T = TypeVar("T", bound=Optional[KamereonVehicleDataAttributes])
# We have potentially 7 coordinators per vehicle
_PARALLEL_SEMAPHORE = asyncio.Semaphore(1)
class RenaultDataUpdateCoordinator(DataUpdateCoordinator[T]): class RenaultDataUpdateCoordinator(DataUpdateCoordinator[T]):
"""Handle vehicle communication with Renault servers.""" """Handle vehicle communication with Renault servers."""
@ -47,6 +51,7 @@ class RenaultDataUpdateCoordinator(DataUpdateCoordinator[T]):
if self.update_method is None: if self.update_method is None:
raise NotImplementedError("Update method not implemented") raise NotImplementedError("Update method not implemented")
try: try:
async with _PARALLEL_SEMAPHORE:
return await self.update_method() return await self.update_method()
except AccessDeniedException as err: except AccessDeniedException as err:
# Disable because the account is not allowed to access this Renault endpoint. # Disable because the account is not allowed to access this Renault endpoint.