From 4d61f6f8c2526b9b9e49563ef0e2d2c77c390ea4 Mon Sep 17 00:00:00 2001 From: jugla <59493499+jugla@users.noreply.github.com> Date: Sun, 14 Mar 2021 16:04:08 +0100 Subject: [PATCH] Reduce number of iqair request (#47890) --- homeassistant/components/airvisual/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/airvisual/__init__.py b/homeassistant/components/airvisual/__init__.py index 6254d533a0f..7450ff2afcf 100644 --- a/homeassistant/components/airvisual/__init__.py +++ b/homeassistant/components/airvisual/__init__.py @@ -80,9 +80,9 @@ def async_get_cloud_api_update_interval(hass, api_key, num_consumers): This will shift based on the number of active consumers, thus keeping the user under the monthly API limit. """ - # Assuming 10,000 calls per month and a "smallest possible month" of 28 days; note + # Assuming 10,000 calls per month and a "largest possible month" of 31 days; note # that we give a buffer of 1500 API calls for any drift, restarts, etc.: - minutes_between_api_calls = ceil(1 / (8500 / 28 / 24 / 60 / num_consumers)) + minutes_between_api_calls = ceil(num_consumers * 31 * 24 * 60 / 8500) LOGGER.debug( "Leveling API key usage (%s): %s consumers, %s minutes between updates",