Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions homeassistant/components/sensor/waze_travel_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
CONF_ORIGIN = 'origin'
CONF_INCL_FILTER = 'incl_filter'
CONF_EXCL_FILTER = 'excl_filter'
CONF_REALTIME = 'realtime'

DEFAULT_NAME = 'Waze Travel Time'
DEFAULT_REALTIME = True

ICON = 'mdi:car'

Expand All @@ -47,6 +49,7 @@
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_INCL_FILTER): cv.string,
vol.Optional(CONF_EXCL_FILTER): cv.string,
vol.Optional(CONF_REALTIME, default=DEFAULT_REALTIME): cv.boolean,
})

TRACKABLE_DOMAINS = ['device_tracker', 'sensor', 'zone']
Expand All @@ -60,9 +63,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
region = config.get(CONF_REGION)
incl_filter = config.get(CONF_INCL_FILTER)
excl_filter = config.get(CONF_EXCL_FILTER)
realtime = config.get(CONF_REALTIME)

sensor = WazeTravelTime(name, origin, destination, region,
incl_filter, excl_filter)
incl_filter, excl_filter, realtime)

add_devices([sensor], True)

Expand All @@ -82,12 +86,13 @@ class WazeTravelTime(Entity):
"""Representation of a Waze travel time sensor."""

def __init__(self, name, origin, destination, region,
incl_filter, excl_filter):
incl_filter, excl_filter, realtime):
"""Initialize the Waze travel time sensor."""
self._name = name
self._region = region
self._incl_filter = incl_filter
self._excl_filter = excl_filter
self._realtime = realtime
self._state = None
self._origin_entity_id = None
self._destination_entity_id = None
Expand Down Expand Up @@ -201,7 +206,7 @@ def update(self):
try:
params = WazeRouteCalculator.WazeRouteCalculator(
self._origin, self._destination, self._region)
routes = params.calc_all_routes_info()
routes = params.calc_all_routes_info(real_time=self._realtime)

if self._incl_filter is not None:
routes = {k: v for k, v in routes.items() if
Expand Down