I have a script on my laptop at work to trigger a gpslogger webhook regularly with the GPS coordinates of my work place. The question is now how to set not_at_work when leaving.
I thought about an automation which is triggered when the device was not updated x minutes. But could this be done?
You could use a template_trigger, but the docs say it’s dangerous to use now() in it.
I prefer a time_pattern trigger that runs every few minutes and checks the sensors last update.
- alias: your alias here
trigger:
- platform: time_pattern
minutes: '/5'
seconds: 00
condition:
- condition: template
value_template: >
{{ (as_timestamp(now())-as_timestamp(states.sensor.your_sensor.last_updated))
> 7200 }}
action:
...
This runs every 5 minutes and runs the action if the sensor has not updated for 2 hours.
Thanks, the states page do not show the last_updated value. So I was not aware it’s there.
But I have now an other problem: the device_tracker.see service denies any of my used dev_ids. Where to get the correct one for a device_registry entry?