From 1b6cd9e0f39b551d56f86a996c18887956c7776c Mon Sep 17 00:00:00 2001 From: Raman Gupta <7243222+raman325@users.noreply.github.com> Date: Fri, 30 Apr 2021 02:33:15 -0400 Subject: [PATCH] Don't validate inputs on platform setup for Google/Waze travel time (#49886) * Don't validate inputs on platform setup for Google/Waze travel time * feedback from other PR --- .../components/google_travel_time/sensor.py | 11 +++-------- homeassistant/components/waze_travel_time/sensor.py | 13 ++++--------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/homeassistant/components/google_travel_time/sensor.py b/homeassistant/components/google_travel_time/sensor.py index 7256697fe03..2b347679420 100644 --- a/homeassistant/components/google_travel_time/sensor.py +++ b/homeassistant/components/google_travel_time/sensor.py @@ -20,7 +20,6 @@ from homeassistant.const import ( TIME_MINUTES, ) from homeassistant.core import CoreState, HomeAssistant -from homeassistant.exceptions import ConfigEntryNotReady import homeassistant.helpers.config_validation as cv import homeassistant.util.dt as dt_util @@ -40,6 +39,7 @@ from .const import ( CONF_TRANSIT_ROUTING_PREFERENCE, CONF_TRAVEL_MODE, CONF_UNITS, + DEFAULT_NAME, DOMAIN, TRACKABLE_DOMAINS, TRANSIT_PREFS, @@ -48,7 +48,7 @@ from .const import ( TRAVEL_MODEL, UNITS, ) -from .helpers import get_location_from_entity, is_valid_config_entry, resolve_zone +from .helpers import get_location_from_entity, resolve_zone _LOGGER = logging.getLogger(__name__) @@ -126,12 +126,7 @@ async def async_setup_entry( api_key = config_entry.data[CONF_API_KEY] origin = config_entry.data[CONF_ORIGIN] destination = config_entry.data[CONF_DESTINATION] - name = config_entry.data[CONF_NAME] - - if not await hass.async_add_executor_job( - is_valid_config_entry, hass, _LOGGER, api_key, origin, destination - ): - raise ConfigEntryNotReady + name = config_entry.data.get(CONF_NAME, DEFAULT_NAME) client = Client(api_key, timeout=10) diff --git a/homeassistant/components/waze_travel_time/sensor.py b/homeassistant/components/waze_travel_time/sensor.py index 965cd5c8a37..2e93ee2a85a 100644 --- a/homeassistant/components/waze_travel_time/sensor.py +++ b/homeassistant/components/waze_travel_time/sensor.py @@ -20,7 +20,6 @@ from homeassistant.const import ( TIME_MINUTES, ) from homeassistant.core import Config, CoreState, HomeAssistant -from homeassistant.exceptions import ConfigEntryNotReady import homeassistant.helpers.config_validation as cv from .const import ( @@ -43,6 +42,7 @@ from .const import ( DEFAULT_AVOID_FERRIES, DEFAULT_AVOID_SUBSCRIPTION_ROADS, DEFAULT_AVOID_TOLL_ROADS, + DEFAULT_NAME, DEFAULT_REALTIME, DEFAULT_VEHICLE_TYPE, DOMAIN, @@ -52,7 +52,7 @@ from .const import ( UNITS, VEHICLE_TYPES, ) -from .helpers import get_location_from_entity, is_valid_config_entry, resolve_zone +from .helpers import get_location_from_entity, resolve_zone _LOGGER = logging.getLogger(__name__) @@ -142,12 +142,7 @@ async def async_setup_entry( destination = config_entry.data[CONF_DESTINATION] origin = config_entry.data[CONF_ORIGIN] region = config_entry.data[CONF_REGION] - name = config_entry.data[CONF_NAME] - - if not await hass.async_add_executor_job( - is_valid_config_entry, hass, _LOGGER, origin, destination, region - ): - raise ConfigEntryNotReady + name = config_entry.data.get(CONF_NAME, DEFAULT_NAME) data = WazeTravelTimeData( None, @@ -331,7 +326,7 @@ class WazeTravelTimeData: if excl_filter.lower() not in k.lower() } - if len(routes) > 0: + if routes: route = list(routes)[0] else: _LOGGER.warning("No routes found")