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