Prevent iCloud exceptions in logfile (#9179)
* Prevent iCloud exceptions in logfile With this change ValueError exceptions in the logfile caused by this component will disappear. These errors are caused by the iCloud API returning an HTTP 450 error and the external lib throwing a ValueError because of it. A PR has been raised against the external library, but that fix did not yet make it into a new version of the library. This will catch the exception in the mean time.... https://github.com/picklepete/pyicloud/pull/138 * Align log messages
This commit is contained in:
parent
924290adb0
commit
cc18b5af3d
1 changed files with 10 additions and 7 deletions
|
@ -307,12 +307,15 @@ class Icloud(DeviceScanner):
|
||||||
self.api.authenticate()
|
self.api.authenticate()
|
||||||
|
|
||||||
currentminutes = dt_util.now().hour * 60 + dt_util.now().minute
|
currentminutes = dt_util.now().hour * 60 + dt_util.now().minute
|
||||||
for devicename in self.devices:
|
try:
|
||||||
interval = self._intervals.get(devicename, 1)
|
for devicename in self.devices:
|
||||||
if ((currentminutes % interval == 0) or
|
interval = self._intervals.get(devicename, 1)
|
||||||
(interval > 10 and
|
if ((currentminutes % interval == 0) or
|
||||||
currentminutes % interval in [2, 4])):
|
(interval > 10 and
|
||||||
self.update_device(devicename)
|
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):
|
def determine_interval(self, devicename, latitude, longitude, battery):
|
||||||
"""Calculate new interval."""
|
"""Calculate new interval."""
|
||||||
|
@ -397,7 +400,7 @@ class Icloud(DeviceScanner):
|
||||||
self.see(**kwargs)
|
self.see(**kwargs)
|
||||||
self.seen_devices[devicename] = True
|
self.seen_devices[devicename] = True
|
||||||
except PyiCloudNoDevicesException:
|
except PyiCloudNoDevicesException:
|
||||||
_LOGGER.error('No iCloud Devices found!')
|
_LOGGER.error("No iCloud Devices found")
|
||||||
|
|
||||||
def lost_iphone(self, devicename):
|
def lost_iphone(self, devicename):
|
||||||
"""Call the lost iPhone function if the device is found."""
|
"""Call the lost iPhone function if the device is found."""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue