Waze time travel - multiple origin tracker sensors

Does anyone know how to configure the Waze travel time sensor to use multiple device tracker sensors as the “origin”? I tried to use input select like you can with destinations but couldn’t get the config to recognize the input data as a sensor and not state. Here’s the basic Waze config:

  - platform: waze_travel_time
    name: "Me to destination"
    origin: device_tracker.iphone
    destination: sensor.dest_address
    region: 'US'

Any input is appreciated!

So you want to replace device_tracker.iphone with a dynamic changing location or device tracker?

My goal is to use different device_tracker sources as an “origin” for Waze travel time. I have 3 smartphones setup as device tracker sensors and want to be able to switch them in (based on their current location) for travel duration estimates. The Waze component settings explain how to do this for the “destination” using an input_select list with various destination addresses. I attempted the same configuration listing the 3 device_trackers as sources but it didn’t work. I’m not sure this approach is the right way to accomplish my goal above anyway.

Any thoughts how to do this?

because the device trackers do not have an address as the list. Information pulled from the device tracker is the latitude and longitude. You need to make those values into a comma separated string.

{% set trackers = {
  'Person1':'device_tracker.person1',
  'Person2':'device_tracker.person2',
  'Person3':'device_tracker.person3'} %}
{% set key = states('input_select.listed_trackers') %}
{% if key in trackers.keys() %}
{{ state_attr(trackers[key],'latitude') }}, {{ state_attr(trackers[key],'longitude') }}
{% else %}
unknown
{% endif %}

That should work as long as you have the exact same selections. If you don’t understand dictionaries in Jinja, then you can move to if statements. But the above code should work copy/paste as long as you change the device tracker names, the key names that match with the device trackers and the input select.

Ha, I had not seen this before, which is too bad really, since i nw have created all dedicated sensors…

wouldn’t the dynamic selection be easier if we used zones, vs the full address specs of the doc’s example?

step1: select a tracker
step 2: select a designation
step 3: hit calculate.

a bit like this:

57

script:
  set_hue_scene:
    alias: Set Hue scene
    sequence:
      service: hue.hue_activate_scene
      data_template:
        group_name: >
          {{ states('input_select.hue_groups')}}
        scene_name: >
          {{ states('input_select.hue_scenes')}}

but then with trackers and zones (the later also allowed to being another tracker to calculate the travel-time between them)

The sensor needs to output the address or the lat and lon. That’s the only way a sensor will work in the configuration of waze. Waze does not look at the sensor, see that it’s an entity_id string and move forward. It looks at the sensor, tries to use the string as a lat/lon or address.

sure, I guess I should have added the creation of that sensor for zones, based on an input select too.

input_select.who_is_travelling selects a device_tracker which is then used in your value_template and input for origin
input_select.travelling_to selects a zone, or other device.tracker, used in a second value_template and input for destination.

hit calculate and the waze travel time is displayed?

Yeah that could work

ok, only thing Im a bit uncertain of is the service to call. What would that be using the waze component?

script:
  calculate_waze_travel_time:
    alias: Calculate waze travel time
    sequence:
      service: ??
      data_template:
        origin: >
          {{ states('input_select.who_is_travelling)}}
        destination: >
          {{ states('input_select.travelling_to')}}

above should use sensors, sorry:

script:
  calculate_waze_travel_time:
    alias: Calculate waze travel time
    sequence:
      service: ??
      data_template:
        origin: >
          {{ states(sensor.who_is_travelling)}}
        destination: >
          {{ states('sensor.travelling_to')}}

The service would be a notification service. You’d have to create a waze component that reads from both sensors. Then your ‘calculate’ button would just push a notification to something.

  - platform: waze_travel_time
    name: "Me to destination"
    origin: sensor.orig_lat_long
    destination: sensor.dest_lat_long
    region: 'EU'

gotta remember, this is a sensor, sensors don’t have service calls.

of course…
so, first create the waze component, which then uses the input of the sensors, that use the input of the inout selects. As soon as either of the selects is changed the waze component immediately updates its state…right?

Not sure, I don’t remember what i did. It might only update every 5 minutes.

had completely forgotten about my google travel time package since I try to prevent using that as much as possible now, and replace Google with Waze…
Didn’t update this package yet accordingly. Will do shortly!

rewrote the sensors in the meantime to:

  - platform: template
    sensors:
      select_travel_destination:
        value_template: >
          {{states('input_select.travel_destination')}}
      select_travel_origin:
        value_template: >
          {{states('input_select.travel_origin.state')}}
      select_travel_mode:
        value_template: >
          {{states('input_select.travel_mode.state')}}

      distance_selected_destination:
        value_template: >
          {{state_attr('sensor.travel_destination','distance')}}
      duration_selected_destination:
        value_template: >
          {{state_attr('sensor.travel_destination','duration')}}
      duration_in_traffic_selected_destination:
        value_template: >
          {{state_attr('sensor.travel_destination','duration_in_traffic')}}

      input_travel_origin:
        value_template: >
          {{states('input_text.travel_origin')}}
      input_travel_destination:
        value_template: >
          {{states('input_text.travel_destination')}}

as of version 0.80.0 we can add the update on demand to this Google travel time sensor, Google Maps Travel Time - Home Assistant
will see if and how I can fit that in my package quickly, but the package itself already took care of preventing unnecessary lookups… :wink:

Dang, unfortunately I can’t seem to get this working. I think I get the logic of everything you stated but one thing that throws me off is that you can use a single device_tracker in the Waze config with no problem, so I’m not sure why the need to do all the lat/long conversion when the Waze config seems to know how to do that for a single phone at least.

Here is what I tried - from configuration.yaml (sanitized addresses):

input_select:
  destination:
    name: destination
    options:
      - Home
      - LizWork
      - TonyWork
      - DayCare
      - RockGym
  origin:
    name: origin
    options:
      - TonyPhone
      - LizPhone
      - AlainaPhone

    sensor:
    # Waze input select
      - platform: template
        sensors:
           dest_address:
             value_template: >-
                {%- if is_state("input_select.destination", "Home")  -%}
                  1600 Pennsylvania Ave NW, Washington, DC 20500, USA
                {%- elif is_state("input_select.destination", "LizWork")  -%}
                  1600 Pennsylvania Ave NW, Washington, DC 20500, USA
                {%- elif is_state("input_select.destination", "TonyWork")  -%}
                  1600 Pennsylvania Ave NW, Washington, DC 20500, USA
                {%- elif is_state("input_select.destination", "DayCare")  -%}
                  1600 Pennsylvania Ave NW, Washington, DC 20500, USA
                {%- elif is_state("input_select.destination", "RockGym")  -%}
                  1600 Pennsylvania Ave NW, Washington, DC 20500, USA
                {%- else -%}
                  Unknown
                {%- endif %}
           start_address:
             value_template: >-
                {% set trackers = {
                  'TonyPhone':'device_tracker.tonysiphone',
                  'LizPhone':'device_tracker.elizabethsiphone6s',
                  'AlainaPhone':'device_tracker.alainasiphone6'} %}
                {% set key = states('input_select.listed_trackers') %}
                {% if key in trackers.keys() %}
                {{ state_attr(trackers[key],'latitude') }}, {{ state_attr(trackers[key],'longitude') }}
                {% else %}
                unknown
                {% endif %}

             
      - platform: waze_travel_time
        name: "Me to destination"
        origin: sensor.start_address
        destination: sensor.dest_address
        region: 'US'

This results in 2 nice input select lists.
54%20PM

The sensor.start_address never seems to update with the input select and the Waze calculations don’t work.

My intention is to call the two input select lists via automation using the input_select.select_option to change the origin and destination for Waze to produce travel timers, which I can then send out via notifications.

have you tried waiting a full 5 minutes after changing the drop down lists?

wiat, the problem is your origin input_select

{% set key = states('input_select.listed_trackers') %}

should be

{% set key = states('input_select.origin') %}

I have followed the sample above for multiple destination tracking. Seems to be working. I am fine tuning the setup.

input_select:

  duc_destination_waze:
    name: Duc Destination Waze
    options: 
      - home
      - school
      - jcb
    initial: jcb

platform: waze_travel_time

  - platform: waze_travel_time
    name: Duc Destinations
    origin: device_tracker.id
    destination: sensor.duc_destination_waze
    region: 'EU'

template sensor: (works better and accurate to use lat,long rather address)

  - platform: template
    sensors:
      duc_destination_waze:
        value_template: >-
                {%- if is_state("input_select.duc_destination_waze", "home")  -%}
                  LAT, LONG
                {%- elif is_state("input_select.duc_destination_waze", "school")  -%}
                  LAT, LONG
                {%- elif is_state("input_select.duc_destination_waze", "jcb")  -%}
                  LAT, LONG
                {%- else -%}
                  Unknown
                {%- endif %}

customize:

sensor.duc_destinations:
  templates:
    icon: >
        if (entities['input_select.duc_destination_waze'].state === 'home') return 'mdi:home-import-outline';
        if (entities['input_select.duc_destination_waze'].state === 'school') return 'mdi:chair-school';
        if (entities['input_select.duc_destination_waze'].state === 'jcb') return 'mdi:train';
        return 'mdi:train';

For my template sensor, I want to hide my LAT,LONG data. How can I?