From e3d4e3ad4db6ad32ee6ff16a08e8be656343e1e4 Mon Sep 17 00:00:00 2001 From: Daren Lord Date: Fri, 4 Dec 2015 09:08:46 -0700 Subject: [PATCH] Increasing scan interval. Moved imports. --- homeassistant/components/device_tracker/icloud.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/device_tracker/icloud.py b/homeassistant/components/device_tracker/icloud.py index 5968d7d8ac8..2986bbec595 100644 --- a/homeassistant/components/device_tracker/icloud.py +++ b/homeassistant/components/device_tracker/icloud.py @@ -18,12 +18,9 @@ import logging from homeassistant.const import CONF_USERNAME, CONF_PASSWORD from homeassistant.helpers.event import track_utc_time_change -from pyicloud import PyiCloudService -from pyicloud.exceptions import PyiCloudFailedLoginException -from pyicloud.exceptions import PyiCloudNoDevicesException import re -SCAN_INTERVAL = 60 +SCAN_INTERVAL = 1800 _LOGGER = logging.getLogger(__name__) @@ -36,6 +33,9 @@ def setup_scanner(hass, config, see): """ Set up the iCloud Scanner """ + from pyicloud import PyiCloudService + from pyicloud.exceptions import PyiCloudFailedLoginException + from pyicloud.exceptions import PyiCloudNoDevicesException # Get the username and password from the configuration username = config[CONF_USERNAME] @@ -47,10 +47,11 @@ def setup_scanner(hass, config, see): api = PyiCloudService(username, password, verify=True) - except PyiCloudFailedLoginException as e: + except PyiCloudFailedLoginException as error: _LOGGER.exception( - 'Error logging into iCloud Service: {0}'.format(str(e)) + 'Error logging into iCloud Service: {0}'.format(error) ) + return def update_icloud(now): """ @@ -79,7 +80,7 @@ def setup_scanner(hass, config, see): # No location found for the device so continue continue except PyiCloudNoDevicesException: - _LOGGER.exception('No iCloud Devices found!') + _LOGGER.info('No iCloud Devices found!') track_utc_time_change( hass,