Google travel time don't work with new release 2022.2.x

This here is my configuration.yaml and here is the error I get when checking config via settings menu:
I am sure it´s just a completely simple newbie-mistake -.-

Integration error: cal_title - Integration ‘cal_title’ not found.
Integration error: cal_start_time - Integration ‘cal_start_time’ not found.
Integration error: cal_location - Integration ‘cal_location’ not found.


# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
input_boolean: !include input_boolean.yaml
sensor: !include sensor.yaml

switch:
  - platform: wake_on_lan
    mac: "18:C0:4D:94:B1:27"

google:
  client_id: "xxxxxxxxxxxxx"
  client_secret: "xxxxxxxxxxx"
  
cal_location:
  value_template: '{{ states.calendar.xxxxxxxx_gmail_com.attributes.location }}'
  friendly_name: 'Calendar Location'
    
    
cal_title:
  friendly_name: 'Calendar Title'
  value_template: '{{ states.calendar.xxxxxxxxx_gmail_com.attributes.message }}'
    
    
cal_start_time:
  value_template: '{{ states.calendar.xxxxxxxxxx_gmail_com.attributes.start_time }}'
  friendly_name: 'Calendar Start'
  unit_of_measurement: 'time'

edit: and if I put 2 spaces in front of all the lines the error is:

Invalid config for [google]: [cal_location] is an invalid option for [google]. Check: google->google->cal_location. (See /config/configuration.yaml, line 19).

edit2: the g-cal.yaml seems to be fine since in dev options I can view my next calendar event:

- cal_id: [email protected]
  entities:
  - device_id: xxxxx_gmail_com
    ignore_availability: true
    name: [email protected]
    track: true

if you have a sensor.yaml you have to insert

cal_location:
  value_template: '{{ states.calendar.xxxxxxxx_gmail_com.attributes.location }}'
  friendly_name: 'Calendar Location'
    
    
cal_title:
  friendly_name: 'Calendar Title'
  value_template: '{{ states.calendar.xxxxxxxxx_gmail_com.attributes.message }}'
    
    
cal_start_time:
  value_template: '{{ states.calendar.xxxxxxxxxx_gmail_com.attributes.start_time }}'
  friendly_name: 'Calendar Start'
  unit_of_measurement: 'time'

in sensor.yaml

what is the name of the entity where you can see the meeting information?
Should be cal_location:
calendar.xxxxx_gmail_com

Ah, I found the issue :smiley:

  • platform: template

was missing at the top… told you I am a total noob ^^

Now I am met with another and hopefully last issue:

The location gets read from my calendar same as it is input “Street X, ZipCode City” = sensor.cal_location

When I try to feed this to travel time I get no result, the only way to receive a travel time is if I manually input coordinates for the destination.
I also tried different ways to spell out the location “City, Country” / “street city country” etc. but the only thing that works is coordinates.
What exactly am I doing wrong here? Doest travel_time not work with “clear text” addresses?

It is currently broken in the latest release. A fix is on its way

@eifinger thanks, if it wasnt for you I would have kept looking for mistakes

@febo7011 thanks again for all the time you put into this awesome walkthrough, I am pretty sure I can get this to work as soon as travel time is fixed.
Since your writeup is so detailed it would be great to have it linked somewhere so other people can find this easier.

daKazze
Yes now for the release 2022.2.x not work well.
This is the reason for this Post.
I’m waiting for the solution but to have this procedure ok now in my HA I leave the release 2021.12.9.
I will install the new releases 2022.2.x only when the problem will be solved.

I am happy that you like my solution.
I use it every day and it wakes me up in my bedroom in the morning.

Regards

My fix got merged and will be part of the 2022.3 release: Full Changelog for Home Assistant Core 2022.3 - Home Assistant

Hi eifinger

Very good news.
Many thanks for your bug fixing.

I look forward to the new release,

Regards

Thanks for your work!

I jumped on the beta just to get this back. A bunch of my automations work off my commute time so I’m glad it’s working again…

I was also wondering if there is currently a way to get the destination coordinates from the sensor as well, not just the address?

Hey, I am sorry to bother you again but since travel time is fixed now I finally implemented the full solution but there seems to be an issue somewhere with the math…
My travel time sensor is “sensor.arbeitsweg” and when checked it reports the correct travel time in minutes. I copied your config and just changed a few names here and there.
The problem is that the “calc” sensors dont seem to substract the travel time that is provided by the travel time sensor.
For example: Prep time is set to 15min, my appointement is at 18:00, It is a 50min drive to get there and the sensor.calc_prep_time reports 17:45.
It´s the same for the other 3 calc sensors. So it does not substract the travel time as it should.

Any ideas?

  - platform: template
    sensors:
      calc_leave_time:
        value_template: '{{ ((as_timestamp(states.calendar.xxx_gmail_com.attributes.start_time) - (states.sensor.arbeitsweg | int * 60) - (states.abfahrtszeit.state | int * 60)) | timestamp_custom("%Y-%m-%d %H:%M") ) }}'
        friendly_name: 'Leave Time'
        unit_of_measurement: 'time'

      calc_last_time:
        value_template: '{{ ((as_timestamp(states.calendar.xxx_gmail_com.attributes.start_time) - (states.sensor.arbeitsweg | int * 60)  ) | timestamp_custom("%Y-%m-%d %H:%M") ) }}'
        friendly_name: 'Last Time'
        unit_of_measurement: 'time'

      calc_prep_time:
        value_template: '{{ ((as_timestamp(states.calendar.xxx_gmail_com.attributes.start_time) - (states.sensor.arbeitsweg | int * 60) - (states.input_number.vorbereitungszeit.state | int * 60) ) | timestamp_custom("%Y-%m-%d %H:%M") ) }}'
        friendly_name: 'Prep Time'
        unit_of_measurement: 'time'

      calc_warn_time:
        value_template: '{{ ((as_timestamp(states.calendar.xxx_gmail_com.attributes.start_time) - (states.sensor.arbeitsweg | int * 60) - (states.input_number.vorwarnzeit.state | int * 60) ) | timestamp_custom("%Y-%m-%d %H:%M") ) }}'
        friendly_name: 'warn Time'
        unit_of_measurement: 'time'

      sys_time:
        value_template: '{{ (as_timestamp(strptime(states.sensor.date_time.state, "%Y-%m-%d, %H:%M")))  | timestamp_custom("%Y-%m-%d %H:%M")  }}'
        friendly_name: 'Sys Time'
        unit_of_measurement: 'time'

There is an error .state is missed.
(states.sensor.arbeitsweg | int * 60)
This have to be
(states.sensor.arbeitsweg.state | int * 60)

In every sensor.

Dude I cant tell you how much you helped me - everything works like a charm now and I love it!

Since I am facing a few issues right now I would like to clear my error log:

Every time I dont have an appointment coming up that has a location specified I am getting several errors for the travel time sensor and the calcs because the location parameter is empty.
Is there anything I can do to avoid this?

And I am even getting an error when I have a “working” calendar event:

Logger: homeassistant.helpers.template
Source: helpers/template.py:1286
First occurred: 12:35:44 (18 occurrences)
Last logged: 14:15:41

Template warning: 'int' got invalid input 'unknown' when rendering template '{{ ((as_timestamp(states.calendar.xxx_gmail_com.attributes.start_time) - (states.sensor.arbeitsweg.state | int * 60) - (states.abfahrtszeit.state | int * 60)) | timestamp_custom("%Y-%m-%d %H:%M") ) }}' but no default was specified. Currently 'int' will return '0', however this template will fail to render in Home Assistant core 2022.1
Template warning: 'int' got invalid input 'None' when rendering template '{{ ((as_timestamp(states.calendar.xxx_gmail_com.attributes.start_time) - (states.sensor.arbeitsweg.state | int * 60) - (states.abfahrtszeit.state | int * 60)) | timestamp_custom("%Y-%m-%d %H:%M") ) }}' but no default was specified. Currently 'int' will return '0', however this template will fail to render in Home Assistant core 2022.1
Template warning: 'int' got invalid input 'unknown' when rendering template '{{ ((as_timestamp(states.calendar.xxx_gmail_com.attributes.start_time) - (states.sensor.arbeitsweg.state | int * 60) ) | timestamp_custom("%Y-%m-%d %H:%M") ) }}' but no default was specified. Currently 'int' will return '0', however this template will fail to render in Home Assistant core 2022.1
Template warning: 'int' got invalid input 'unknown' when rendering template '{{ ((as_timestamp(states.calendar.xxx_gmail_com.attributes.start_time) - (states.sensor.arbeitsweg.state | int * 60) - (states.input_number.vorbereitungszeit.state | int * 60) ) | timestamp_custom("%Y-%m-%d %H:%M") ) }}' but no default was specified. Currently 'int' will return '0', however this template will fail to render in Home Assistant core 2022.1
Template warning: 'int' got invalid input 'unknown' when rendering template '{{ ((as_timestamp(states.calendar.xxx_com.attributes.start_time) - (states.sensor.arbeitsweg.state | int * 60) - (states.input_number.vorwarnzeit.state | int * 60) ) | timestamp_custom("%Y-%m-%d %H:%M") ) }}' but no default was specified. Currently 'int' will return '0', however this template will fail to render in Home Assistant core 2022.1

BUT everything works… I get the correct values from these sensors…

Hi, to avoid these errors I use the event filtered with a specific keyword.
In my case is Rem.
And when I insert a Meeting to manage with the automation I insert the keyword and the position.

But I have the possibility to insert in my calendar some other meeting without the keyword and position not managed from the automation.
If I want to manage a remainder without a position (Ex. do pizza) I insert my house address in the meeting position. In this case the travel time is zero, but all the automation work well.

How to set the keyword you can check in the previous message there is the setting for the calendar.

Regards

I explain better.
This is the setting in the caledar.

  • cal_id:
    entities:
    • device_id: gmailcom
      ignore_availability: true
      name:
      track: true
      search: “Rem.”

search: “Rem.” is used to extract only the meeting that has in the title the keyword.
Ex. Work Rem.
Ex. Dinner with friends Rem.
Rem. for me stay for Reminder, but you can choose your keyword.
If the calendar meeting hasn’t the keyword, home assistant skip the meeting.

Regards

Thank you again mate, I set up the search and that works but I usually schedule my work a few days in advance so I often dont have any upcoming events at all and so I get errors because all is blank.
I just realized that I could set up a weekly reoccurring event in my calender that has an address but this would not really be a clean solution and produce a wrong alert every week.

When you insert a planning event without an address you can avoid inserting the keyword. When you have the detailed address and you update the event you can insert also the keyword.

Or you can insert your home/office address like a default address. In this way, you have travel time 0 without error.
When you have the address you can update the event with the real address.

Or you can insert only the city name at the beginning.

You have a lot of choices.

Does Google Travel Time integ work for everyone? I cannot add it all, I follow the instructions, I enable the Distance Matrix API, I get the API key, yet I always get “Failed to connect” while adding the integ. HA 2022.6.5.

Same problem, always Failed to connect.