mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Wunderground sensor with alerts exceeds API limits (#4070)
* Fixes issue #4067 - Wunderground sensor with alerts exceeds API limits To avoid hitting the max limit of 500 calls per day, this patch keeps weather conditions being updated each 5 minutes and weather advisories each 15 minutes. This formula will result the following: conditions -> 300 seconds -> 5 minutes -> 12 req/h -> 288 req/day alerts -> 900 seconds -> 15 minutes -> 4 req/h -> 96 req/day * Using timedelta in minutes instead seconds
This commit is contained in:
parent
4833e992fb
commit
4fb0b27310
@ -25,7 +25,8 @@ _LOGGER = logging.getLogger(__name__)
|
||||
CONF_ATTRIBUTION = "Data provided by the WUnderground weather service"
|
||||
CONF_PWS_ID = 'pws_id'
|
||||
|
||||
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=300)
|
||||
MIN_TIME_BETWEEN_UPDATES_ALERTS = timedelta(minutes=15)
|
||||
MIN_TIME_BETWEEN_UPDATES_OBSERVATION = timedelta(minutes=5)
|
||||
|
||||
# Sensor types are defined like: Name, units
|
||||
SENSOR_TYPES = {
|
||||
@ -187,7 +188,7 @@ class WUndergroundData(object):
|
||||
|
||||
return url + '.json'
|
||||
|
||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||
@Throttle(MIN_TIME_BETWEEN_UPDATES_OBSERVATION)
|
||||
def update(self):
|
||||
"""Get the latest data from WUnderground."""
|
||||
try:
|
||||
@ -202,7 +203,7 @@ class WUndergroundData(object):
|
||||
self.data = None
|
||||
raise
|
||||
|
||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||
@Throttle(MIN_TIME_BETWEEN_UPDATES_ALERTS)
|
||||
def update_alerts(self):
|
||||
"""Get the latest alerts data from WUnderground."""
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user