Do not stop fetching iCloud data after service error (#31069)
parent
58973d5265
commit
bc600995c1
|
@ -262,14 +262,14 @@ class IcloudAccount:
|
||||||
|
|
||||||
self._icloud_dir = icloud_dir
|
self._icloud_dir = icloud_dir
|
||||||
|
|
||||||
self.api = None
|
self.api: PyiCloudService = None
|
||||||
self._owner_fullname = None
|
self._owner_fullname = None
|
||||||
self._family_members_fullname = {}
|
self._family_members_fullname = {}
|
||||||
self._devices = {}
|
self._devices = {}
|
||||||
|
|
||||||
self.unsub_device_tracker = None
|
self.unsub_device_tracker = None
|
||||||
|
|
||||||
def setup(self):
|
def setup(self) -> None:
|
||||||
"""Set up an iCloud account."""
|
"""Set up an iCloud account."""
|
||||||
try:
|
try:
|
||||||
self.api = PyiCloudService(
|
self.api = PyiCloudService(
|
||||||
|
@ -285,7 +285,8 @@ class IcloudAccount:
|
||||||
# Gets device owners infos
|
# Gets device owners infos
|
||||||
user_info = self.api.devices.response["userInfo"]
|
user_info = self.api.devices.response["userInfo"]
|
||||||
except PyiCloudNoDevicesException:
|
except PyiCloudNoDevicesException:
|
||||||
_LOGGER.error("No iCloud Devices found")
|
_LOGGER.error("No iCloud device found")
|
||||||
|
return
|
||||||
|
|
||||||
self._owner_fullname = f"{user_info['firstName']} {user_info['lastName']}"
|
self._owner_fullname = f"{user_info['firstName']} {user_info['lastName']}"
|
||||||
|
|
||||||
|
@ -308,7 +309,18 @@ class IcloudAccount:
|
||||||
try:
|
try:
|
||||||
api_devices = self.api.devices
|
api_devices = self.api.devices
|
||||||
except PyiCloudNoDevicesException:
|
except PyiCloudNoDevicesException:
|
||||||
_LOGGER.error("No iCloud Devices found")
|
_LOGGER.error("No iCloud device found")
|
||||||
|
return
|
||||||
|
except Exception as err: # pylint: disable=broad-except
|
||||||
|
_LOGGER.error("Unknown iCloud error: %s", err)
|
||||||
|
self._fetch_interval = 5
|
||||||
|
dispatcher_send(self.hass, SERVICE_UPDATE)
|
||||||
|
track_point_in_utc_time(
|
||||||
|
self.hass,
|
||||||
|
self.keep_alive,
|
||||||
|
utcnow() + timedelta(minutes=self._fetch_interval),
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
# Gets devices infos
|
# Gets devices infos
|
||||||
for device in api_devices:
|
for device in api_devices:
|
||||||
|
@ -330,8 +342,8 @@ class IcloudAccount:
|
||||||
self._devices[device_id] = IcloudDevice(self, device, status)
|
self._devices[device_id] = IcloudDevice(self, device, status)
|
||||||
self._devices[device_id].update(status)
|
self._devices[device_id].update(status)
|
||||||
|
|
||||||
dispatcher_send(self.hass, SERVICE_UPDATE)
|
|
||||||
self._fetch_interval = self._determine_interval()
|
self._fetch_interval = self._determine_interval()
|
||||||
|
dispatcher_send(self.hass, SERVICE_UPDATE)
|
||||||
track_point_in_utc_time(
|
track_point_in_utc_time(
|
||||||
self.hass,
|
self.hass,
|
||||||
self.keep_alive,
|
self.keep_alive,
|
||||||
|
|
Loading…
Reference in New Issue