mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +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."""
|
"""Update iCloud devices."""
|
||||||
if self.api is None:
|
if self.api is None:
|
||||||
return
|
return
|
||||||
|
_LOGGER.debug("Updating devices")
|
||||||
|
|
||||||
if self.api.requires_2fa:
|
if self.api.requires_2fa:
|
||||||
self._require_reauth()
|
self._require_reauth()
|
||||||
@ -173,11 +174,7 @@ class IcloudAccount:
|
|||||||
_LOGGER.error("Unknown iCloud error: %s", err)
|
_LOGGER.error("Unknown iCloud error: %s", err)
|
||||||
self._fetch_interval = 2
|
self._fetch_interval = 2
|
||||||
dispatcher_send(self.hass, self.signal_device_update)
|
dispatcher_send(self.hass, self.signal_device_update)
|
||||||
track_point_in_utc_time(
|
self._schedule_next_fetch()
|
||||||
self.hass,
|
|
||||||
self.keep_alive,
|
|
||||||
utcnow() + timedelta(minutes=self._fetch_interval),
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# Gets devices infos
|
# Gets devices infos
|
||||||
@ -223,11 +220,7 @@ class IcloudAccount:
|
|||||||
if new_device:
|
if new_device:
|
||||||
dispatcher_send(self.hass, self.signal_device_new)
|
dispatcher_send(self.hass, self.signal_device_new)
|
||||||
|
|
||||||
track_point_in_utc_time(
|
self._schedule_next_fetch()
|
||||||
self.hass,
|
|
||||||
self.keep_alive,
|
|
||||||
utcnow() + timedelta(minutes=self._fetch_interval),
|
|
||||||
)
|
|
||||||
|
|
||||||
def _require_reauth(self):
|
def _require_reauth(self):
|
||||||
"""Require the user to log in again."""
|
"""Require the user to log in again."""
|
||||||
@ -306,6 +299,14 @@ class IcloudAccount:
|
|||||||
self._max_interval,
|
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:
|
def keep_alive(self, now=None) -> None:
|
||||||
"""Keep the API alive."""
|
"""Keep the API alive."""
|
||||||
if self.api is None:
|
if self.api is None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user