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

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.

Same error here.

My PR
got merged. In the next version we should at least understand the problems.

Do you still encounter the error and have a log message now?