Fix waze_travel_time component ERROR on startup (#20316)

* Fix waze_travel_time component ERROR on startup

Fix the unhandled exception with Waze Travel Time sensor upon startup,
by adding Throttle before update_interval are starting.

* add missing whitespace after ','

* fix line too long (80 > 79 characters)

* lint

* fix interval to use const

* Change to Throttle as a decorator to update

Change to Throttle as a decorator to update instead of self.update = Throttle(interval)(self.update)
remove unnecessary code.

* fix  indentations

* Update waze_travel_time.py

* Update waze_travel_time.py

* Update waze_travel_time.py
pull/20930/head
Eliran Turgeman 2019-02-06 12:42:11 +02:00 committed by Paulus Schoutsen
parent 180689fb04
commit b5e40669c9
1 changed files with 4 additions and 1 deletions

View File

@ -16,6 +16,7 @@ from homeassistant.const import (
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers import location
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle
REQUIREMENTS = ['WazeRouteCalculator==0.6']
@ -40,6 +41,7 @@ ICON = 'mdi:car'
REGIONS = ['US', 'NA', 'EU', 'IL', 'AU']
SCAN_INTERVAL = timedelta(minutes=5)
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=5)
TRACKABLE_DOMAINS = ['device_tracker', 'sensor', 'zone']
@ -67,7 +69,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
sensor = WazeTravelTime(name, origin, destination, region,
incl_filter, excl_filter, realtime)
add_entities([sensor])
add_entities([sensor], True)
# Wait until start event is sent to load this component.
hass.bus.listen_once(
@ -182,6 +184,7 @@ class WazeTravelTime(Entity):
return friendly_name
@Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self):
"""Fetch new state data for the sensor."""
import WazeRouteCalculator