Waze Location from Google Calendar

I want to create a Waze Time Distance from a google calendar location event. It seems to accept the entity person.lambo as the GPS location fine and calendar.jetstar with no issues. But when I connect the calendar API from google into the waze location it gives me a rather bizarre and very incorrect distance. It shouldn’t be any more than 3km and about 7 mins. How do I fix this?

Calendar:

calendar.jetstar
JQ
State: off	
message: DPS - 
all_day: false
start_time: 2023-03-16 05:25:00
end_time: 2023-03-16 12:50:00
location: Adelaide Airport Long Term Car Parking, Sir Richard Williams Ave, Adelaide Airport SA 5950, Australia
description: JQ1
offset_reached: false
friendly_name: Jetstar
supported_features: 3

Waze Distance:

sensor.jetstar_shift
Jetstar Shift
State: 469	
state_class: measurement
duration: 469.3666666666667
distance: 724.507
route: Best-M8 - Western Fwy
origin: **MY LOCATION**
destination: calendar.jetstar
unit_of_measurement: min
attribution: Powered by Waze
device_class: duration
icon: mdi:car
friendly_name: Jetstar Shift

I’m facing the same issues…

Using Calendar as the origin or destination for waze is currently not supported.

It’s on my todo list. I cannot give an eta yet.


To explain what is happening here:

Waze can work with a lot of entities. Some of them like a device_tracker or a zone have attributes for the GPS coordinates. For all other entities it uses the current state. This only works if this state is are comma separated latitude and longitude or an address.

So if it takes the current state of your calendar entity, which is off it will try to find any location on the world with the name “off”, take the first result and calculate a route to it.

You can do something like this to create a sensor entity with the location of the next upcoming calendar event, then use this as the destination for Waze:

When we get service response values working for waze, we’ll have more approaches we can use for this, but this works pretty good right now.

1 Like

@allenporter Can you give more details on how to implement this please. Because I don’t really know whether to create an automation or a script or both.
Thanks

Hi, this is a template entity. You create this either in configuration.yaml or a file included from it and then it will register this entity that is occasionally updated based on the trigger criteria. The reason this is a little confusing is that it does in fact look similar to how you’d be build an automation that gets the same data, but the difference is that it has the sensor field for creating the entity rather than taking some other action like an automation might.

1 Like

@ski_maniac also here is a blog post from the release with more context: See 2023.9: New climate entity dialogs, lots of tile features, and template sensors from the UI! - Home Assistant

You can see it was a fairly recently added feature.

1 Like

Thanks! I will take a look a that.

@allenporter I created the template location entities but the Waze Travel Integration still can’t translate the address from the location template.

Hello,

I’m trying to build off the snippet from Allen Porter, but running into a snag. I get the following two errors in my logs, and my sensors show nothing, or “unknown”.

log errors
Logger: homeassistant.components.sensor.helpers
Source: components/sensor/helpers.py:23
integration: Sensor (documentation, issues)
First occurred: 22:41:47 (1 occurrences)
Last logged: 22:41:47

sensor.next_location_start rendered invalid timestamp:

Logger: homeassistant.helpers.template
Source: helpers/template.py:2748
First occurred: 22:41:47 (3 occurrences)
Last logged: 22:41:48

Template variable warning: 'dict object' has no attribute 'events' when rendering '{{ agenda.events | rejectattr('location', 'undefined') | list }}'
Template variable warning: 'schedule_set' is undefined when rendering '{{ schedule_set }}'
Problem Info

I did make two changes to the sensor;

  • service > action
  • calendar.list_events > calendar.get_events

Anyone still using this successfully and willing to takes peak? Thanks!

- trigger:
    - platform: homeassistant
      event: start
    - platform: time_pattern
      hours: "/6"
  action:
    - action: calendar.get_events
      target:
        entity_id: calendar.s_schedule
      data:
        duration:
          hours: 168
          minutes: 0
          seconds: 0
      response_variable: agenda
    - alias: Find upcoming events with locations
      variables:
        upcoming: "{{ agenda.events | rejectattr('location', 'undefined') | list }}"
  sensor:
    - name: "Next Location"
      state: >
        {% if upcoming|length > 0 %}
          {{ upcoming[0].location }}
        {% endif %}
    - name: "Next Location Summary"
      state: >
        {% if upcoming|length > 0 %}
          {{ upcoming[0].summary }}
        {% endif %}
    - name: "Next Location Start"
      state: >
        {% if upcoming|length > 0 %}
          {{ upcoming[0].start }}
        {% endif %}
      device_class: timestamp

- trigger:
    platform: event
    event_type: tasker_event
  sensor:
    - name: Tasker State
      state: "{{trigger.event.data.state}}"

Solution:

variables:
        upcoming: "{{ agenda['calendar.schedule']['events'] | rejectattr('location', 'undefined') | list }}"

Per