Throttle Arlo api calls (#13143)

This commit is contained in:
Alok Saboo 2018-03-12 16:56:33 -04:00 committed by Paulus Schoutsen
parent 51b0cbefe3
commit 95a528a75f

View file

@ -5,11 +5,13 @@ For more details about this component, please refer to the documentation at
https://home-assistant.io/components/arlo/
"""
import logging
from datetime import timedelta
import voluptuous as vol
from requests.exceptions import HTTPError, ConnectTimeout
from homeassistant.helpers import config_validation as cv
from homeassistant.util import Throttle
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD
REQUIREMENTS = ['pyarlo==0.1.2']
@ -45,6 +47,7 @@ def setup(hass, config):
arlo = PyArlo(username, password, preload=False)
if not arlo.is_connected:
return False
arlo.update = Throttle(timedelta(seconds=10))(arlo.update)
hass.data[DATA_ARLO] = arlo
except (ConnectTimeout, HTTPError) as ex:
_LOGGER.error("Unable to connect to Netgear Arlo: %s", str(ex))