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
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)...'
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.
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.