Automation Condition Always Failing when using last triggered

Trying to prevent an automation from running repeatedly by incorporating a delay (5 minutes) between subsequent runs. I’m using the following condition statement which I learned after looking through similar questions.

    - condition: template # only notify once every 5 minutes at most
      value_template: "{{ ( as_timestamp(now()) - as_timestamp(state_attr('automation.driveway_notify_on_interest', 'last_triggered')) |int(0) ) > 300}}"

Unfortunately with this condition, my automation never runs stating that the condition failed.

Is it b/c when the automation is first triggered, it updates the last_triggered variable and as such it will always fail? I would think the last_triggered time would be from the previous automation run not the one currently running.

Thanks in advance.

If your automation is running in the default ‘single’ mode which only allows one instance of the automation to run at a time, just put a delay at the end of your actions and delete that condition.

The delay will prevent the automation running again until it has expired.

- delay: 
    minutes: 5

This will generate an ‘already running’ warning in your log, unless you set max_exceeded to silent.

Personally I like to see the warnings so I know if an automation is trying to run repeatedly but being blocked.

This works great. I was definitely over complicating things.