From 76d9c62900a012587eb6a81ac9c2ae31f8e8f09d Mon Sep 17 00:00:00 2001 From: jugla <59493499+jugla@users.noreply.github.com> Date: Tue, 30 Mar 2021 19:03:35 +0200 Subject: [PATCH] Evaluate AirVisual interval on reboot (#48392) * Reevaluate interval on reboot (and periodically) * AirVisual update interval periodically * AirVisual : update periodically interval request * AirVisual : update sever request interval periodically * AirVisual : periodically update interval for server requests * AirVisual : periodic update for server interval * Airvisual : periodic update of server interval * AirVisual : periodic update of server interval * AirVisual : periodic update of interval request * Periodic interval update of server request * AirVisual : periodic update of interval request * Reassess interval request on periodic event * ReAssess interval between 2 requests during update * ReAssess interval between 2 requests periodically * Reassess interval of server requests periodically * Reassess the interval between 2 server requests * Reassess interval between 2 server requests * Reassess server requests interval periodically * Assess interval request after inserting instance --- homeassistant/components/airvisual/__init__.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/airvisual/__init__.py b/homeassistant/components/airvisual/__init__.py index 473cf3a32dd..f02020d25b4 100644 --- a/homeassistant/components/airvisual/__init__.py +++ b/homeassistant/components/airvisual/__init__.py @@ -242,10 +242,6 @@ async def async_setup_entry(hass, config_entry): update_method=async_update_data, ) - async_sync_geo_coordinator_update_intervals( - hass, config_entry.data[CONF_API_KEY] - ) - # Only geography-based entries have options: hass.data[DOMAIN][DATA_LISTENER][ config_entry.entry_id @@ -275,6 +271,12 @@ async def async_setup_entry(hass, config_entry): hass.data[DOMAIN][DATA_COORDINATOR][config_entry.entry_id] = coordinator + # Reassess the interval between 2 server requests + if CONF_API_KEY in config_entry.data: + async_sync_geo_coordinator_update_intervals( + hass, config_entry.data[CONF_API_KEY] + ) + for platform in PLATFORMS: hass.async_create_task( hass.config_entries.async_forward_entry_setup(config_entry, platform) @@ -340,10 +342,7 @@ async def async_unload_entry(hass, config_entry): remove_listener = hass.data[DOMAIN][DATA_LISTENER].pop(config_entry.entry_id) remove_listener() - if ( - config_entry.data[CONF_INTEGRATION_TYPE] - == INTEGRATION_TYPE_GEOGRAPHY_COORDS - ): + if CONF_API_KEY in config_entry.data: # Re-calculate the update interval period for any remaining consumers of # this API key: async_sync_geo_coordinator_update_intervals(