Bump pywaze to 1.2.3 and close Waze clients on unload (#183923)

This commit is contained in:
Kevin Stillhammer
2026-10-05 11:54:45 +00:00
committed by Franck Nijhof
parent 46866445f3
commit 31bf909d36
5 changed files with 27 additions and 26 deletions
@@ -49,6 +49,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
client = WazeRouteCalculator(
region=config_entry.data[CONF_REGION].upper(), client=httpx_client
)
config_entry.async_on_unload(client.close)
coordinator = WazeTravelTimeCoordinator(hass, config_entry, client)
config_entry.runtime_data = coordinator
@@ -38,10 +38,10 @@ async def is_valid_config_entry(
resolved_origin = find_coordinates(hass, origin)
resolved_destination = find_coordinates(hass, destination)
httpx_client = get_async_client(hass)
client = WazeRouteCalculator(region=region, client=httpx_client)
try:
await client.calc_routes(resolved_origin, resolved_destination)
except WRCError as error:
_LOGGER.error("Error trying to validate entry: %s", error)
return False
async with WazeRouteCalculator(region=region, client=httpx_client) as client:
try:
await client.calc_routes(resolved_origin, resolved_destination)
except WRCError as error:
_LOGGER.error("Error trying to validate entry: %s", error)
return False
return True
@@ -7,5 +7,5 @@
"integration_type": "service",
"iot_class": "cloud_polling",
"loggers": ["pywaze", "homeassistant.helpers.location"],
"requirements": ["pywaze==1.2.1"]
"requirements": ["pywaze==1.2.3"]
}
@@ -113,9 +113,6 @@ SERVICE_GET_TRAVEL_TIMES_SCHEMA = probatio.Schema(
async def async_get_travel_times_service(service: ServiceCall) -> ServiceResponse:
"""Get travel times."""
httpx_client = get_async_client(service.hass)
client = WazeRouteCalculator(
region=service.data[CONF_REGION].upper(), client=httpx_client
)
origin_coordinates = find_coordinates(service.hass, service.data[CONF_ORIGIN])
destination_coordinates = find_coordinates(
@@ -135,21 +132,24 @@ async def async_get_travel_times_service(service: ServiceCall) -> ServiceRespons
/ 60
)
response = await async_get_travel_times(
client=client,
origin=origin,
destination=destination,
vehicle_type=service.data[CONF_VEHICLE_TYPE],
avoid_toll_roads=service.data[CONF_AVOID_TOLL_ROADS],
avoid_subscription_roads=service.data[CONF_AVOID_SUBSCRIPTION_ROADS],
avoid_ferries=service.data[CONF_AVOID_FERRIES],
realtime=service.data[CONF_REALTIME],
units=service.data[CONF_UNITS],
incl_filters=service.data.get(CONF_INCL_FILTER, DEFAULT_FILTER),
excl_filters=service.data.get(CONF_EXCL_FILTER, DEFAULT_FILTER),
time_delta=time_delta,
base_coordinates=base_coordinates,
)
async with WazeRouteCalculator(
region=service.data[CONF_REGION].upper(), client=httpx_client
) as client:
response = await async_get_travel_times(
client=client,
origin=origin,
destination=destination,
vehicle_type=service.data[CONF_VEHICLE_TYPE],
avoid_toll_roads=service.data[CONF_AVOID_TOLL_ROADS],
avoid_subscription_roads=service.data[CONF_AVOID_SUBSCRIPTION_ROADS],
avoid_ferries=service.data[CONF_AVOID_FERRIES],
realtime=service.data[CONF_REALTIME],
units=service.data[CONF_UNITS],
incl_filters=service.data.get(CONF_INCL_FILTER, DEFAULT_FILTER),
excl_filters=service.data.get(CONF_EXCL_FILTER, DEFAULT_FILTER),
time_delta=time_delta,
base_coordinates=base_coordinates,
)
return {"routes": [vars(route) for route in response]}
+1 -1
View File
@@ -2887,7 +2887,7 @@ pyvlx==0.2.36
pyvolumio==0.1.5
# homeassistant.components.waze_travel_time
pywaze==1.2.1
pywaze==1.2.3
# homeassistant.components.weatherflow
pyweatherflowudp==1.6.3