mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
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
This commit is contained in:
parent
dcb12a992a
commit
64b9102206
@ -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
|
||||
|
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user