From 64b91022064cd1caf05af7c10a98afd6feea9d58 Mon Sep 17 00:00:00 2001 From: Leonardo Merza Date: Mon, 15 Jul 2019 22:51:51 -0400 Subject: [PATCH] Add travel time attribution/coordinates (#24956) * add google travel time attribution * add origin/destination * update waze origin/destination * add attribution and origin/destination * add google attribution --- homeassistant/components/google_travel_time/sensor.py | 7 ++++++- homeassistant/components/waze_travel_time/sensor.py | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/google_travel_time/sensor.py b/homeassistant/components/google_travel_time/sensor.py index ef4fc76f53e..1a6d347ad7f 100644 --- a/homeassistant/components/google_travel_time/sensor.py +++ b/homeassistant/components/google_travel_time/sensor.py @@ -10,13 +10,15 @@ import homeassistant.util.dt as dt_util from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_API_KEY, CONF_NAME, EVENT_HOMEASSISTANT_START, ATTR_LATITUDE, - ATTR_LONGITUDE, CONF_MODE) + ATTR_LONGITUDE, ATTR_ATTRIBUTION, CONF_MODE) from homeassistant.helpers import location from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) +ATTRIBUTION = "Powered by Google" + CONF_DESTINATION = 'destination' CONF_OPTIONS = 'options' CONF_ORIGIN = 'origin' @@ -181,6 +183,9 @@ class GoogleTravelTimeSensor(Entity): res['duration'] = _data['duration']['text'] if 'distance' in _data: res['distance'] = _data['distance']['text'] + res['origin'] = self._origin + res['destination'] = self._destination + res[ATTR_ATTRIBUTION] = ATTRIBUTION return res @property diff --git a/homeassistant/components/waze_travel_time/sensor.py b/homeassistant/components/waze_travel_time/sensor.py index 5a925623b90..b22084cba44 100644 --- a/homeassistant/components/waze_travel_time/sensor.py +++ b/homeassistant/components/waze_travel_time/sensor.py @@ -16,8 +16,10 @@ from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) +ATTR_DESTINATION = 'destination' ATTR_DURATION = 'duration' ATTR_DISTANCE = 'distance' +ATTR_ORIGIN = 'origin' ATTR_ROUTE = 'route' ATTRIBUTION = "Powered by Waze" @@ -147,6 +149,8 @@ class WazeTravelTime(Entity): res[ATTR_DURATION] = self._waze_data.duration res[ATTR_DISTANCE] = self._waze_data.distance res[ATTR_ROUTE] = self._waze_data.route + res[ATTR_ORIGIN] = self._waze_data.origin + res[ATTR_DESTINATION] = self._waze_data.destination return res def _get_location_from_entity(self, entity_id):