Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions homeassistant/components/device_tracker/icloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,15 @@ def keep_alive(self, now):
self.api.authenticate()

currentminutes = dt_util.now().hour * 60 + dt_util.now().minute
for devicename in self.devices:
interval = self._intervals.get(devicename, 1)
if ((currentminutes % interval == 0) or
(interval > 10 and
currentminutes % interval in [2, 4])):
self.update_device(devicename)
try:
for devicename in self.devices:
interval = self._intervals.get(devicename, 1)
if ((currentminutes % interval == 0) or
(interval > 10 and
currentminutes % interval in [2, 4])):
self.update_device(devicename)
except ValueError:
_LOGGER.debug("iCloud API returned an error")

def determine_interval(self, devicename, latitude, longitude, battery):
"""Calculate new interval."""
Expand Down Expand Up @@ -397,7 +400,7 @@ def update_device(self, devicename):
self.see(**kwargs)
self.seen_devices[devicename] = True
except PyiCloudNoDevicesException:
_LOGGER.error('No iCloud Devices found!')
_LOGGER.error("No iCloud Devices found")

def lost_iphone(self, devicename):
"""Call the lost iPhone function if the device is found."""
Expand Down