Use SCAN_INTERVAL instead of Throttle for google travel time (#31420)

The documentation for google_travel_time was at odds with the
implementation. The documentation stated a default scan time of
5 minutes, but the implementation was using Throttle which resulted
in the sensor updating at a maximum rate of one API call every
5 minutes. This was especially at odds with a given example at
the end of the documentation, which showed updating the sensor
every 2 minutes during commute times.

This change brings the implementation in line with the docs by
adopting the `SCAN_INTERVAL` constant set to the stated default
of 5 minutes and removing the Throttle.
pull/32489/head
Paulus Schoutsen 2020-03-04 17:39:28 -08:00 committed by GitHub
parent 7b5b909f0a
commit 2d3b117cb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 3 deletions

View File

@ -19,7 +19,6 @@ from homeassistant.const import (
from homeassistant.helpers import location
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle
import homeassistant.util.dt as dt_util
_LOGGER = logging.getLogger(__name__)
@ -33,7 +32,7 @@ CONF_TRAVEL_MODE = "travel_mode"
DEFAULT_NAME = "Google Travel Time"
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=5)
SCAN_INTERVAL = timedelta(minutes=5)
ALL_LANGUAGES = [
"ar",
@ -256,7 +255,6 @@ class GoogleTravelTimeSensor(Entity):
"""Return the unit this state is expressed in."""
return self._unit_of_measurement
@Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self):
"""Get the latest data from Google."""
options_copy = self._options.copy()