[WIP] Spread the traffic to yr.no servers and remove yr.no from the default… (#5171)

* Spread the traffic to yr.no servers and remove yr.no from the default config

* use unique address for yr.no

* update yr tests

* Wait 10 min extra before requesting new data

* Update config.py

* Update yr.py
This commit is contained in:
Daniel Høyer Iversen 2017-01-04 23:20:30 +01:00 committed by Paulus Schoutsen
parent 4ef7e08553
commit 2f907696f3
2 changed files with 9 additions and 5 deletions

View File

@ -82,8 +82,9 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
weather = YrData(hass, coordinates, dev)
# Update weather on the hour, spread seconds
async_track_utc_time_change(hass, weather.async_update, minute=0,
second=randrange(5, 25))
async_track_utc_time_change(hass, weather.async_update,
minute=randrange(1, 10),
second=randrange(0, 59))
yield from weather.async_update()
@ -139,7 +140,8 @@ class YrData(object):
def __init__(self, hass, coordinates, devices):
"""Initialize the data object."""
self._url = 'http://api.yr.no/weatherapi/locationforecast/1.9/'
self._url = 'https://aa015h6buqvih86i1.api.met.no/'\
'weatherapi/locationforecast/1.9/'
self._urlparams = coordinates
self._nextrun = None
self.devices = devices

View File

@ -14,7 +14,8 @@ NOW = datetime(2016, 6, 9, 1, tzinfo=dt_util.UTC)
@asyncio.coroutine
def test_default_setup(hass, aioclient_mock):
"""Test the default setup."""
aioclient_mock.get('http://api.yr.no/weatherapi/locationforecast/1.9/',
aioclient_mock.get('https://aa015h6buqvih86i1.api.met.no/'
'weatherapi/locationforecast/1.9/',
text=load_fixture('yr.no.json'))
config = {'platform': 'yr',
'elevation': 0}
@ -32,7 +33,8 @@ def test_default_setup(hass, aioclient_mock):
@asyncio.coroutine
def test_custom_setup(hass, aioclient_mock):
"""Test a custom setup."""
aioclient_mock.get('http://api.yr.no/weatherapi/locationforecast/1.9/',
aioclient_mock.get('https://aa015h6buqvih86i1.api.met.no/'
'weatherapi/locationforecast/1.9/',
text=load_fixture('yr.no.json'))
config = {'platform': 'yr',