Waze travel time update

Im trying to accomplish a dynamic waze time updater ,
I have in zone.yaml several zones .
i separate waze to waze,yaml
where i try to implement @petro suggestion for the templates
and also @Mariusthvdb for the sensors .

Im not sure i define the the input_select correctly as actually they are duplicated,
with just different name.
What is the automation that calculate the origin to destination ?

Is that correct if I want to use the zones i have in zone.yaml?
How
second, I’m working on some telegram actionable notifications
which later i want add the option to get the expected arrival time
from the current location to desire destination ,
is some1 done something similar?

my waze.yaml

sensor:
  - platform: template
    sensors:
      destination_address:
        friendly_name: Destination
        value_template: >
          {% set entity_id = states('input_select.waze_destination') %}
          {% set lat = state_attr(entity_id, 'latitude') %}
          {% set lon = state_attr(entity_id, 'longitude') %}
          {{ lat }}, {{ lon }}
        icon_template: mdi:map-marker-path

      origin_address:
        friendly_name: Origin
        value_template: >
          {% set entity_id = states('input_select.waze_origin') %}
          {% set lat = state_attr(entity_id, 'latitude') %}
          {% set lon = state_attr(entity_id, 'longitude') %}
          {{ lat }}, {{ lon }}
        icon_template: mdi:map-marker

  - platform: waze_travel_time
    name: 'Select Origin Destination'
    origin: sensor.origin_address
    destination: sensor.destination_address
    region: 'IL'
         
         
            
input_select:
  waze_origin:
    name: waze_origin
    options:
      - Home
      - Avi Work
      - Karin Work
      
  waze_destination:
    name: waze_destination
    options:
      - Home
      - Avi Work
      - Karin Work      


I check the code:

Imitate available variables:
 {% set entity_id = states('zone.karin_Work') %}
          {% set lat = state_attr('zone.karin_Work', 'latitude') %}
          {% set lon = state_attr('zone.karin_Work', 'longitude') %}
          {{ lat }}, {{ lon }}

The lan and lon are {{ lat }} {{ lon }}

return:
"The lan and lon are xx.82405 yy.081299"

so it does work with zone correctly
The problem from some reason the sensor don’t get this values

sensor:

      origin_address:
        friendly_name: Origin
        value_template: >
          {% set entity_id = states('input_select.waze_origin') %}
          {% set lat = state_attr('entity_id', 'latitude') %}
          {% set lon = state_attr('entity_id', 'longitude') %}
          {{ lat }}, {{ lon }}
        icon_template: mdi:map-marker

It’s look in the developer states as “none,none”

Any idea?

You have to use entity_id’s in your input_selects. You can’t use friendly names. That’s your problem.

1 Like

Thanks @petro - nice catch !

now both sensors destination and origin holds the lan,lon values,
and select_origin_destination - return the time and destination.
But it’s not being refresh in reasonable time (about ~3-4 minute),
is there an way get trigger it faster?

I want to create automation which send notification automatically when i leave predefined zone.

You can try to call the service homeassistant.update_entity.

yep, that’s what I use:

script:
  update_waze_dynamic:
    alias: Update Waze dynamic
    icon: mdi:update
    sequence:
      - service: homeassistant.update_entity
        entity_id: sensor.select_origin_destination

and sensors:

  - platform: template
    sensors:
      destination_address:
        friendly_name: Destination
        value_template: >
          {% set destination = states('input_select.waze_destination') %}
          {% set lat = state_attr(destination, 'latitude') %}
          {% set lon = state_attr(destination, 'longitude') %}
          {{ lat }}, {{ lon }}
        icon_template: mdi:map-marker-path

      origin_address:
        friendly_name: Origin
        value_template: >
          {% set origin = states('input_select.waze_origin') %}
          {% set lat = state_attr(origin, 'latitude') %}
          {% set lon = state_attr(origin, 'longitude') %}
          {{ lat }}, {{ lon }}
        icon_template: mdi:map-marker


  - platform: waze_travel_time
    name: 'Select Origin Destination'
    origin: sensor.origin_address
    destination: sensor.destination_address
    region: 'EU'

Lovelace:

  - type: entities
    title: Dynamic Waze travels
    show_header_toggle: false
    entities:
      - input_select.waze_origin
      - input_select.waze_destination
      - sensor.origin_address
      - sensor.destination_address
      - entity: script.update_waze_dynamic
        action_name: Update
      - type: custom:waze-card
        title: Travel time
        entities:
          - entity: sensor.select_origin_destination

note the elevated Travel time Waze card. I purposely didn’t style it, because I kind of like the effect right now.

5 Likes

Thanks @Mariusthvdb , @eifinger ,@petro
I added the homeassistant.update_entity and it works perfectly ,

@Mariusthvdb
for the UI part, I see u are using some custom card,
is it possible to install it via hacks?

probably, but I don’t use HACS, sorry

yes it is, just look for the card in hacs

Can you change the log level to warning or even info? if it is expected than it is not probably error. I can suppress the error but then I will not see real errors …

Hi, I’m staying in Asia and may i know what region should i put? It seems doesn’t have options for Asia region.

you can do that through logger.

The rest of the world for Waze works off “EU” for this api for some reason.

1 Like

Ok. I will try it out and report the result here. Thanks

If that doesn’t work, also try NA. The api is really limited. It’s clear that it wasn’t meant to be used this way.

Hi, the ‘EU’ region is working in Malaysia. Thanks alot.

@Mariusthvdb thank you for sharing your amazing card.
I do wonder if it is possible to change the fields to a friendly_name of a sort,
meaning zone.XXXX will show a zone name instead.
Origin - will show full address, instead of coordinates,
and under Travel time Name will be presented origin location and destination location?

I guess anything is possible… you need to create a few ‘mappers’, ie, template sensors that map the name to the state (for the zone), and maybe you can do the same for the frontend representation of the gps coordinates.

about the name: I only now notice that doesnt change indeed :wink: hmm. must have a look when I can find the opportunity…anytime soon. This is a Waze-card issue with the Waze sensor, so will have to go back to that (havent seen it in a while now). As I see it now, it show this sensor:

  - platform: waze_travel_time
    name: Select Origin Destination
    origin: sensor.origin_address
    destination: sensor.destination_address
    region: EU

which name you can set of course, to your liking. It won’t change given the gps coordinates. Quickly changed it to Route Planner for now:

1 Like

@Mariusthvdb Thank you for explaining, i did not know about the mappers option, so thank you for education me about it, though working a long while on making it work was unsuccessful.
could you please point me to where should i use mappers in this case?
changing sensor template using mapper return the name instead {{ lat }}, {{ lon }} and break the results of waze, as far as i know lovelace yaml cannot have template, there for i am a bit lost on the how to…
as for my config - it is basically similar to your implantation above.

Tried both NA and EU but keep getting status Unknown and I’m in Thailand.
Any suggestions?