mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Sun component will work now without internet
This commit is contained in:
parent
e277decd4c
commit
c659be7e17
@ -21,6 +21,7 @@ The sun event need to have the type 'sun', which service to call, which event
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
import urllib
|
||||||
|
|
||||||
import homeassistant.util as util
|
import homeassistant.util as util
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
@ -129,8 +130,13 @@ def setup(hass, config):
|
|||||||
|
|
||||||
if elevation is None:
|
if elevation is None:
|
||||||
google = GoogleGeocoder()
|
google = GoogleGeocoder()
|
||||||
google._get_elevation(location) # pylint: disable=protected-access
|
try:
|
||||||
_LOGGER.info('Retrieved elevation from Google: %s', location.elevation)
|
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 = Sun(hass, location)
|
||||||
sun.point_in_time_listener(dt_util.utcnow())
|
sun.point_in_time_listener(dt_util.utcnow())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user