mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Respect icloud Enable polling updates
(#117984)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
def27a082c
commit
213bbae63c
@ -161,6 +161,7 @@ class IcloudAccount:
|
||||
"""Update iCloud devices."""
|
||||
if self.api is None:
|
||||
return
|
||||
_LOGGER.debug("Updating devices")
|
||||
|
||||
if self.api.requires_2fa:
|
||||
self._require_reauth()
|
||||
@ -173,11 +174,7 @@ class IcloudAccount:
|
||||
_LOGGER.error("Unknown iCloud error: %s", err)
|
||||
self._fetch_interval = 2
|
||||
dispatcher_send(self.hass, self.signal_device_update)
|
||||
track_point_in_utc_time(
|
||||
self.hass,
|
||||
self.keep_alive,
|
||||
utcnow() + timedelta(minutes=self._fetch_interval),
|
||||
)
|
||||
self._schedule_next_fetch()
|
||||
return
|
||||
|
||||
# Gets devices infos
|
||||
@ -223,11 +220,7 @@ class IcloudAccount:
|
||||
if new_device:
|
||||
dispatcher_send(self.hass, self.signal_device_new)
|
||||
|
||||
track_point_in_utc_time(
|
||||
self.hass,
|
||||
self.keep_alive,
|
||||
utcnow() + timedelta(minutes=self._fetch_interval),
|
||||
)
|
||||
self._schedule_next_fetch()
|
||||
|
||||
def _require_reauth(self):
|
||||
"""Require the user to log in again."""
|
||||
@ -306,6 +299,14 @@ class IcloudAccount:
|
||||
self._max_interval,
|
||||
)
|
||||
|
||||
def _schedule_next_fetch(self) -> None:
|
||||
if not self._config_entry.pref_disable_polling:
|
||||
track_point_in_utc_time(
|
||||
self.hass,
|
||||
self.keep_alive,
|
||||
utcnow() + timedelta(minutes=self._fetch_interval),
|
||||
)
|
||||
|
||||
def keep_alive(self, now=None) -> None:
|
||||
"""Keep the API alive."""
|
||||
if self.api is None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user