Update WazeRouteCalculator, add config options, fix subscription (#27963)
* Update WazeRouteCalculator to 0.11 * Update WazeRouteCalculator to 0.11 * Adding new config options to Waze * Fixing avoid subscription option * Update WazeRouteCalculator to 0.12 There was an error in the underlying lib * Update WazeRouteCalculator to 0.12
This commit is contained in:
parent
44e708f72b
commit
9e971495f7
3 changed files with 39 additions and 5 deletions
|
@ -3,7 +3,7 @@
|
|||
"name": "Waze travel time",
|
||||
"documentation": "https://www.home-assistant.io/integrations/waze_travel_time",
|
||||
"requirements": [
|
||||
"WazeRouteCalculator==0.10"
|
||||
"WazeRouteCalculator==0.12"
|
||||
],
|
||||
"dependencies": [],
|
||||
"codeowners": []
|
||||
|
|
|
@ -38,10 +38,16 @@ CONF_EXCL_FILTER = "excl_filter"
|
|||
CONF_REALTIME = "realtime"
|
||||
CONF_UNITS = "units"
|
||||
CONF_VEHICLE_TYPE = "vehicle_type"
|
||||
CONF_AVOID_TOLL_ROADS = "avoid_toll_roads"
|
||||
CONF_AVOID_SUBSCRIPTION_ROADS = "avoid_subscription_roads"
|
||||
CONF_AVOID_FERRIES = "avoid_ferries"
|
||||
|
||||
DEFAULT_NAME = "Waze Travel Time"
|
||||
DEFAULT_REALTIME = True
|
||||
DEFAULT_VEHICLE_TYPE = "car"
|
||||
DEFAULT_AVOID_TOLL_ROADS = False
|
||||
DEFAULT_AVOID_SUBSCRIPTION_ROADS = False
|
||||
DEFAULT_AVOID_FERRIES = False
|
||||
|
||||
ICON = "mdi:car"
|
||||
|
||||
|
@ -65,6 +71,13 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||
VEHICLE_TYPES
|
||||
),
|
||||
vol.Optional(CONF_UNITS): vol.In(UNITS),
|
||||
vol.Optional(
|
||||
CONF_AVOID_TOLL_ROADS, default=DEFAULT_AVOID_TOLL_ROADS
|
||||
): cv.boolean,
|
||||
vol.Optional(
|
||||
CONF_AVOID_SUBSCRIPTION_ROADS, default=DEFAULT_AVOID_SUBSCRIPTION_ROADS
|
||||
): cv.boolean,
|
||||
vol.Optional(CONF_AVOID_FERRIES, default=DEFAULT_AVOID_FERRIES): cv.boolean,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -79,10 +92,23 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||
excl_filter = config.get(CONF_EXCL_FILTER)
|
||||
realtime = config.get(CONF_REALTIME)
|
||||
vehicle_type = config.get(CONF_VEHICLE_TYPE)
|
||||
avoid_toll_roads = config.get(CONF_AVOID_TOLL_ROADS)
|
||||
avoid_subscription_roads = config.get(CONF_AVOID_SUBSCRIPTION_ROADS)
|
||||
avoid_ferries = config.get(CONF_AVOID_FERRIES)
|
||||
units = config.get(CONF_UNITS, hass.config.units.name)
|
||||
|
||||
data = WazeTravelTimeData(
|
||||
None, None, region, incl_filter, excl_filter, realtime, units, vehicle_type
|
||||
None,
|
||||
None,
|
||||
region,
|
||||
incl_filter,
|
||||
excl_filter,
|
||||
realtime,
|
||||
units,
|
||||
vehicle_type,
|
||||
avoid_toll_roads,
|
||||
avoid_subscription_roads,
|
||||
avoid_ferries,
|
||||
)
|
||||
|
||||
sensor = WazeTravelTime(name, origin, destination, data)
|
||||
|
@ -236,6 +262,9 @@ class WazeTravelTimeData:
|
|||
realtime,
|
||||
units,
|
||||
vehicle_type,
|
||||
avoid_toll_roads,
|
||||
avoid_subscription_roads,
|
||||
avoid_ferries,
|
||||
):
|
||||
"""Set up WazeRouteCalculator."""
|
||||
|
||||
|
@ -251,6 +280,9 @@ class WazeTravelTimeData:
|
|||
self.duration = None
|
||||
self.distance = None
|
||||
self.route = None
|
||||
self.avoid_toll_roads = avoid_toll_roads
|
||||
self.avoid_subscription_roads = avoid_subscription_roads
|
||||
self.avoid_ferries = avoid_ferries
|
||||
|
||||
# Currently WazeRouteCalc only supports PRIVATE, TAXI, MOTORCYCLE.
|
||||
if vehicle_type.upper() == "CAR":
|
||||
|
@ -268,7 +300,9 @@ class WazeTravelTimeData:
|
|||
self.destination,
|
||||
self.region,
|
||||
self.vehicle_type,
|
||||
log_lvl=logging.DEBUG,
|
||||
self.avoid_toll_roads,
|
||||
self.avoid_subscription_roads,
|
||||
self.avoid_ferries,
|
||||
)
|
||||
routes = params.calc_all_routes_info(real_time=self.realtime)
|
||||
|
||||
|
@ -286,7 +320,7 @@ class WazeTravelTimeData:
|
|||
if self.exclude.lower() not in k.lower()
|
||||
}
|
||||
|
||||
route = sorted(routes, key=(lambda key: routes[key][0]))[0]
|
||||
route = list(routes)[0]
|
||||
|
||||
self.duration, distance = routes[route]
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ TwitterAPI==2.5.10
|
|||
# VL53L1X2==0.1.5
|
||||
|
||||
# homeassistant.components.waze_travel_time
|
||||
WazeRouteCalculator==0.10
|
||||
WazeRouteCalculator==0.12
|
||||
|
||||
# homeassistant.components.yessssms
|
||||
YesssSMS==0.4.1
|
||||
|
|
Loading…
Add table
Reference in a new issue