I am struggling writing a template and notification to know when a server watched with tailscale has been over 600 seconds since last seen.
I have ‘sensor.synback_last_seen’ that is device class time stamp
outputs like this
2024-03-19T01:43:46+00:00
what is the easiest way to write a template and also have a trigger for an automation
I put this below in my templates.yaml that outputs something like this for ‘SynBackUptime’
0:02:06
but not sure how to evaluate it to know if it is greater than x seconds
- sensor:
- name: "SynBackUptime"
unique_id: "SynBackUptime"
state: >-
{% set boot = as_timestamp(states('sensor.synback_last_seen'))|int %}
{% set duration = as_timestamp(utcnow())|int - boot %}
{{ timedelta(seconds=duration) }}