Skip to content
Merged
Show file tree
Hide file tree
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
20 changes: 8 additions & 12 deletions homeassistant/components/sensor/waze_travel_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle

REQUIREMENTS = ['WazeRouteCalculator==0.5']
REQUIREMENTS = ['WazeRouteCalculator==0.6']

_LOGGER = logging.getLogger(__name__)

Expand All @@ -40,6 +40,8 @@

SCAN_INTERVAL = timedelta(minutes=5)

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

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_ORIGIN): cv.string,
vol.Required(CONF_DESTINATION): cv.string,
Expand All @@ -49,8 +51,6 @@
vol.Optional(CONF_EXCL_FILTER): cv.string,
})

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


def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the Waze travel time sensor platform."""
Expand All @@ -72,10 +72,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
def _get_location_from_attributes(state):
"""Get the lat/long string from an states attributes."""
attr = state.attributes
return '{},{}'.format(
attr.get(ATTR_LATITUDE),
attr.get(ATTR_LONGITUDE)
)
return '{},{}'.format(attr.get(ATTR_LATITUDE), attr.get(ATTR_LONGITUDE))


class WazeTravelTime(Entity):
Expand Down Expand Up @@ -186,13 +183,11 @@ def update(self):

if self._origin_entity_id is not None:
self._origin = self._get_location_from_entity(
self._origin_entity_id
)
self._origin_entity_id)

if self._destination_entity_id is not None:
self._destination = self._get_location_from_entity(
self._destination_entity_id
)
self._destination_entity_id)

self._destination = self._resolve_zone(self._destination)
self._origin = self._resolve_zone(self._origin)
Expand All @@ -217,7 +212,8 @@ def update(self):
self._state = {
'duration': duration,
'distance': distance,
'route': route}
'route': route,
}
except WazeRouteCalculator.WRCError as exp:
_LOGGER.error("Error on retrieving data: %s", exp)
return
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ TravisPy==0.3.5
TwitterAPI==2.5.4

# homeassistant.components.sensor.waze_travel_time
WazeRouteCalculator==0.5
WazeRouteCalculator==0.6

# homeassistant.components.notify.yessssms
YesssSMS==0.1.1b3
Expand Down