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
This commit is contained in:
Raman Gupta 2021-04-30 02:33:15 -04:00 committed by GitHub
parent dcaefe9f5a
commit 1b6cd9e0f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 17 deletions

View file

@ -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)

View file

@ -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")