Skip to content

Commit

Permalink
Fix waze_travel_time component ERROR on startup (#20316)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
VirtualL authored and balloob committed Feb 10, 2019
1 parent 180689f commit b5e4066
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion homeassistant/components/sensor/waze_travel_time.py
Expand Up @@ -16,6 +16,7 @@
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']

Expand All @@ -40,6 +41,7 @@
REGIONS = ['US', 'NA', 'EU', 'IL', 'AU']

SCAN_INTERVAL = timedelta(minutes=5)
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=5)

TRACKABLE_DOMAINS = ['device_tracker', 'sensor', 'zone']

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -182,6 +184,7 @@ def _resolve_zone(self, friendly_name):

return friendly_name

@Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self):
"""Fetch new state data for the sensor."""
import WazeRouteCalculator
Expand Down

0 comments on commit b5e4066

Please sign in to comment.