mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Remove the google travel time update service (#21153)
This commit is contained in:
parent
d44269981b
commit
ce86fe47e3
@ -4,21 +4,21 @@ Support for Google travel time sensors.
|
|||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/sensor.google_travel_time/
|
https://home-assistant.io/components/sensor.google_travel_time/
|
||||||
"""
|
"""
|
||||||
|
import logging
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import DOMAIN, PLATFORM_SCHEMA
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity import Entity
|
import homeassistant.util.dt as dt_util
|
||||||
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_API_KEY, CONF_NAME, EVENT_HOMEASSISTANT_START, ATTR_LATITUDE,
|
CONF_API_KEY, CONF_NAME, EVENT_HOMEASSISTANT_START, ATTR_LATITUDE,
|
||||||
ATTR_LONGITUDE, CONF_MODE)
|
ATTR_LONGITUDE, CONF_MODE)
|
||||||
from homeassistant.util import Throttle
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
|
||||||
from homeassistant.helpers import location
|
from homeassistant.helpers import location
|
||||||
import homeassistant.util.dt as dt_util
|
from homeassistant.helpers.entity import Entity
|
||||||
|
from homeassistant.util import Throttle
|
||||||
|
|
||||||
REQUIREMENTS = ['googlemaps==2.5.1']
|
REQUIREMENTS = ['googlemaps==2.5.1']
|
||||||
|
|
||||||
@ -83,18 +83,16 @@ def convert_time_to_utc(timestr):
|
|||||||
def setup_platform(hass, config, add_entities_callback, discovery_info=None):
|
def setup_platform(hass, config, add_entities_callback, discovery_info=None):
|
||||||
"""Set up the Google travel time platform."""
|
"""Set up the Google travel time platform."""
|
||||||
def run_setup(event):
|
def run_setup(event):
|
||||||
"""Delay the setup until Home Assistant is fully initialized.
|
"""
|
||||||
|
Delay the setup until Home Assistant is fully initialized.
|
||||||
|
|
||||||
This allows any entities to be created already
|
This allows any entities to be created already
|
||||||
"""
|
"""
|
||||||
|
hass.data.setdefault(DATA_KEY, [])
|
||||||
options = config.get(CONF_OPTIONS)
|
options = config.get(CONF_OPTIONS)
|
||||||
|
|
||||||
if options.get('units') is None:
|
if options.get('units') is None:
|
||||||
options['units'] = hass.config.units.name
|
options['units'] = hass.config.units.name
|
||||||
if DATA_KEY not in hass.data:
|
|
||||||
hass.data[DATA_KEY] = []
|
|
||||||
hass.services.register(
|
|
||||||
DOMAIN, 'google_travel_sensor_update', update)
|
|
||||||
|
|
||||||
travel_mode = config.get(CONF_TRAVEL_MODE)
|
travel_mode = config.get(CONF_TRAVEL_MODE)
|
||||||
mode = options.get(CONF_MODE)
|
mode = options.get(CONF_MODE)
|
||||||
@ -120,14 +118,6 @@ def setup_platform(hass, config, add_entities_callback, discovery_info=None):
|
|||||||
if sensor.valid_api_connection:
|
if sensor.valid_api_connection:
|
||||||
add_entities_callback([sensor])
|
add_entities_callback([sensor])
|
||||||
|
|
||||||
def update(service):
|
|
||||||
"""Update service for manual updates."""
|
|
||||||
entity_id = service.data.get('entity_id')
|
|
||||||
for sensor in hass.data[DATA_KEY]:
|
|
||||||
if sensor.entity_id == entity_id:
|
|
||||||
sensor.update(no_throttle=True)
|
|
||||||
sensor.schedule_update_ha_state()
|
|
||||||
|
|
||||||
# Wait until start event is sent to load this component.
|
# Wait until start event is sent to load this component.
|
||||||
hass.bus.listen_once(EVENT_HOMEASSISTANT_START, run_setup)
|
hass.bus.listen_once(EVENT_HOMEASSISTANT_START, run_setup)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user