Notified when automation is triggered more than 2 days ago

Hi,
I’ve got the following automation and would like to get notified when the last triggered is more than 2 days ago. is that possible?

{{ state_attr(‘automation.to_the_gym’, ‘last_triggered’) }}

You can create a template based sensor to find the difference of now and last triggered and if it is more than 2 days, trigger the automation.

As a backup (your home assistant might miss the trigger) i could run it on a fixed time everyday with condition of template sensor is greater than 2 days :slight_smile:

I would personally go with the second one only, if it doesn’t have to be just on time.

Make it part of the automation to set a date time helper ti the value of now + 2 days
Then use that helper to trigger the notification.

You can use a Template Trigger.

alias: example
trigger:
  - platform: template
    value_template: "{{ now() - state_attr('automation.to_the_gym', 'last_triggered') > timedelta(days=2) }}"
condition: []
action:
  ...etc...

Would this be triggerred continuously given that delta will be always 2 days, after first trigger.

Assuming that automation_to_gym is a different automation.

To trigger a Template Trigger, it must change state from false to true. Once it’s true, it must return to false before it can trigger again.

1 Like