Increasing scan interval. Moved imports.

This commit is contained in:
Daren Lord 2015-12-04 09:08:46 -07:00
parent b6342ed848
commit e3d4e3ad4d

View File

@ -18,12 +18,9 @@ import logging
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD from homeassistant.const import CONF_USERNAME, CONF_PASSWORD
from homeassistant.helpers.event import track_utc_time_change 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 import re
SCAN_INTERVAL = 60 SCAN_INTERVAL = 1800
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -36,6 +33,9 @@ def setup_scanner(hass, config, see):
""" """
Set up the iCloud Scanner 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 # Get the username and password from the configuration
username = config[CONF_USERNAME] username = config[CONF_USERNAME]
@ -47,10 +47,11 @@ def setup_scanner(hass, config, see):
api = PyiCloudService(username, api = PyiCloudService(username,
password, password,
verify=True) verify=True)
except PyiCloudFailedLoginException as e: except PyiCloudFailedLoginException as error:
_LOGGER.exception( _LOGGER.exception(
'Error logging into iCloud Service: {0}'.format(str(e)) 'Error logging into iCloud Service: {0}'.format(error)
) )
return
def update_icloud(now): def update_icloud(now):
""" """
@ -79,7 +80,7 @@ def setup_scanner(hass, config, see):
# No location found for the device so continue # No location found for the device so continue
continue continue
except PyiCloudNoDevicesException: except PyiCloudNoDevicesException:
_LOGGER.exception('No iCloud Devices found!') _LOGGER.info('No iCloud Devices found!')
track_utc_time_change( track_utc_time_change(
hass, hass,