From b7f484a84f6b136d6d0d30439376d9e29b38c346 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 17 Jan 2023 11:50:17 +0100 Subject: [PATCH] Set renault quality scale to platinum (#85753) * Set renault quality scale to platinum * Ensure coordinators do not run at the same time * Add comment --- homeassistant/components/renault/manifest.json | 3 ++- homeassistant/components/renault/renault_coordinator.py | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/renault/manifest.json b/homeassistant/components/renault/manifest.json index a9f65197502..8c75d93c2f8 100644 --- a/homeassistant/components/renault/manifest.json +++ b/homeassistant/components/renault/manifest.json @@ -7,5 +7,6 @@ "requirements": ["renault-api==0.1.11"], "codeowners": ["@epenet"], "iot_class": "cloud_polling", - "loggers": ["renault_api"] + "loggers": ["renault_api"], + "quality_scale": "platinum" } diff --git a/homeassistant/components/renault/renault_coordinator.py b/homeassistant/components/renault/renault_coordinator.py index 7db5ed0c4e1..22a98e0ab8e 100644 --- a/homeassistant/components/renault/renault_coordinator.py +++ b/homeassistant/components/renault/renault_coordinator.py @@ -1,6 +1,7 @@ """Proxy to handle account communication with Renault servers.""" from __future__ import annotations +import asyncio from collections.abc import Awaitable, Callable from datetime import timedelta import logging @@ -18,6 +19,9 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, Upda T = TypeVar("T", bound=Optional[KamereonVehicleDataAttributes]) +# We have potentially 7 coordinators per vehicle +_PARALLEL_SEMAPHORE = asyncio.Semaphore(1) + class RenaultDataUpdateCoordinator(DataUpdateCoordinator[T]): """Handle vehicle communication with Renault servers.""" @@ -47,7 +51,8 @@ class RenaultDataUpdateCoordinator(DataUpdateCoordinator[T]): if self.update_method is None: raise NotImplementedError("Update method not implemented") try: - return await self.update_method() + async with _PARALLEL_SEMAPHORE: + return await self.update_method() except AccessDeniedException as err: # Disable because the account is not allowed to access this Renault endpoint. self.update_interval = None