mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
[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:
parent
4ef7e08553
commit
2f907696f3
@ -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
|
||||
|
@ -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',
|
||||
|
Loading…
x
Reference in New Issue
Block a user