From c659be7e17249597f60fc90b85dd3c846b0c8c35 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 25 Jul 2015 23:45:49 -0700 Subject: [PATCH] Sun component will work now without internet --- homeassistant/components/sun.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/sun.py b/homeassistant/components/sun.py index fd2cfa46b72..af4a93825ac 100644 --- a/homeassistant/components/sun.py +++ b/homeassistant/components/sun.py @@ -21,6 +21,7 @@ The sun event need to have the type 'sun', which service to call, which event """ import logging from datetime import timedelta +import urllib import homeassistant.util as util import homeassistant.util.dt as dt_util @@ -129,8 +130,13 @@ def setup(hass, config): if elevation is None: google = GoogleGeocoder() - google._get_elevation(location) # pylint: disable=protected-access - _LOGGER.info('Retrieved elevation from Google: %s', location.elevation) + try: + google._get_elevation(location) # pylint: disable=protected-access + _LOGGER.info( + 'Retrieved elevation from Google: %s', location.elevation) + except urllib.error.URLError: + # If no internet connection available etc. + pass sun = Sun(hass, location) sun.point_in_time_listener(dt_util.utcnow())