Upgrade WazeRouteCalculator to 0.6 (#15251)

This commit is contained in:
Fabian Affolter 2018-07-01 19:02:02 +02:00 committed by Paulus Schoutsen
parent 4a4b9180d8
commit 6c77c9d372
2 changed files with 9 additions and 13 deletions

View File

@ -18,7 +18,7 @@ import homeassistant.helpers.location as location
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle from homeassistant.util import Throttle
REQUIREMENTS = ['WazeRouteCalculator==0.5'] REQUIREMENTS = ['WazeRouteCalculator==0.6']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -40,6 +40,8 @@ REGIONS = ['US', 'NA', 'EU', 'IL']
SCAN_INTERVAL = timedelta(minutes=5) SCAN_INTERVAL = timedelta(minutes=5)
TRACKABLE_DOMAINS = ['device_tracker', 'sensor', 'zone']
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_ORIGIN): cv.string, vol.Required(CONF_ORIGIN): cv.string,
vol.Required(CONF_DESTINATION): cv.string, vol.Required(CONF_DESTINATION): cv.string,
@ -49,8 +51,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_EXCL_FILTER): cv.string, vol.Optional(CONF_EXCL_FILTER): cv.string,
}) })
TRACKABLE_DOMAINS = ['device_tracker', 'sensor', 'zone']
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the Waze travel time sensor platform.""" """Set up the Waze travel time sensor platform."""
@ -72,10 +72,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
def _get_location_from_attributes(state): def _get_location_from_attributes(state):
"""Get the lat/long string from an states attributes.""" """Get the lat/long string from an states attributes."""
attr = state.attributes attr = state.attributes
return '{},{}'.format( return '{},{}'.format(attr.get(ATTR_LATITUDE), attr.get(ATTR_LONGITUDE))
attr.get(ATTR_LATITUDE),
attr.get(ATTR_LONGITUDE)
)
class WazeTravelTime(Entity): class WazeTravelTime(Entity):
@ -186,13 +183,11 @@ class WazeTravelTime(Entity):
if self._origin_entity_id is not None: if self._origin_entity_id is not None:
self._origin = self._get_location_from_entity( self._origin = self._get_location_from_entity(
self._origin_entity_id self._origin_entity_id)
)
if self._destination_entity_id is not None: if self._destination_entity_id is not None:
self._destination = self._get_location_from_entity( self._destination = self._get_location_from_entity(
self._destination_entity_id self._destination_entity_id)
)
self._destination = self._resolve_zone(self._destination) self._destination = self._resolve_zone(self._destination)
self._origin = self._resolve_zone(self._origin) self._origin = self._resolve_zone(self._origin)
@ -217,7 +212,8 @@ class WazeTravelTime(Entity):
self._state = { self._state = {
'duration': duration, 'duration': duration,
'distance': distance, 'distance': distance,
'route': route} 'route': route,
}
except WazeRouteCalculator.WRCError as exp: except WazeRouteCalculator.WRCError as exp:
_LOGGER.error("Error on retrieving data: %s", exp) _LOGGER.error("Error on retrieving data: %s", exp)
return return

View File

@ -66,7 +66,7 @@ TravisPy==0.3.5
TwitterAPI==2.5.4 TwitterAPI==2.5.4
# homeassistant.components.sensor.waze_travel_time # homeassistant.components.sensor.waze_travel_time
WazeRouteCalculator==0.5 WazeRouteCalculator==0.6
# homeassistant.components.notify.yessssms # homeassistant.components.notify.yessssms
YesssSMS==0.1.1b3 YesssSMS==0.1.1b3