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
This commit is contained in:
jugla 2021-03-30 19:03:35 +02:00 committed by GitHub
parent f5d9713bd5
commit 76d9c62900
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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(