Google Time Travel Automation help

Hi, I’m trying to get a simple notification from google time travel. But it doesn’t trigger. Here the automation. Have I to use a time trigger?

- id: alertTimeToWork
  alias: Time to Work
  trigger:
  - platform: numeric_state
    entity_id: sensor.Home_To_Work
    above: 5
  condition:
  - condition: time
    after: '06:00:00'
    before: '08:20:00'  
  action:
  - service: notify.telegram
    data_template:
      message: 'Much traffic on the road to work. {{ states("sensor.Home_To_Work")
        }} min. '

And here the google time travel object:

- platform: google_travel_time
    name: Home_To_Work
    api_key: !secret GOOGLE_API_KEY
    origin: zone.home
    destination: zone.work
    data_template:
      scan_interval: >
        {% if is_state('sensor.traveltime2work.state', 'true') %} 300
        {% else %} 600
        {% endif %}

I don’t think that will work. should be :slight_smile:

        {% if is_state('sensor.traveltime2work', 'true') %} 300
        {% else %} 600
        {% endif %}

Thanks, but that should affect the if else block only, shouldn’t it? So if every 300 or 600 seconds (the latter will be 3600) the notification should be sent.
Anyhow I will correct it and check if it change.
As of now the notification is sent only on restart.

sorry Having had a quick glance at your code that’s what I picked up first :slight_smile:
I’ve set up my notification slightly differently, in case you want to have a go:

- alias: Tell Lolo of a long drive home
  trigger:
    - platform: state
      entity_id: sensor.lolo_to_home
  condition:
    - condition: time
      after: '15:30:00'
      before: '18:00:00'
    - condition: template
      value_template: '{{ states.sensor.lolo_to_home.state |int(0) >= 65 }}'
    - condition: template
      value_template: '{{ (as_timestamp(now()) - as_timestamp(states.automation.tell_lolo_of_a_long_drive_home.attributes.last_triggered | default(0)) | int > 3600)}}'
  action:
    - service: notify.gmaillolo
      data_template:
        message: 'There is a long drive home ({{states.sensor.lolo_to_home.state |int(0)}} min)...'
1 Like

Don’t worry you’ll never know, often is just a “detail” that stops a process to work, so I’m not excluding that mine will work after your correction, and I surely will try yours, cause that’s more or less the outcome I’m looking for. It’s just that I was trying to write it from scratch! So I hope to debug it first. :slight_smile:

1 Like

I’ve fixed that error and even changed the platform from numeric_state to state and then used an if block, still the automation triggers only on HA restart.
I now think the google time travel doesn’t work as I thought, apparently it doesn’t trigger by “itself”, so I need to find a trigger, like a time trigger, and put the sensor into the condition block. Any suggestions? I mean, it’s the right way or not?

the above automation works well for me so it does trigger.
Is your google sensor moving from below to above your 5min target?
Can you share your automation

The automation is the one I posted in the first post. But to answer your question no, my sensor is always above 5 minutes target. I thought to put a lower value to make it always trigger. Does it trigger only when it moves from below to above the value? I thought it would trigger each time the sensor pinged google server and found that the value was above.
Basically what I’m trying to do, for now, is to have a message that tells me the duration regardless the above value in a window of time.