doesn’t this answer your own question. causing this:
(now() - state_attr('automation.new_automation_test', 'last_triggered') < timedelta(seconds = 5)
to be true?
if you’re not sure, try this to illuminate what’s going on:
alias: New automation test
description: ""
trigger:
- platform: state
entity_id:
- input_button.test
condition: []
action:
- if:
- condition: template
value_template: >-
{{ (now() - state_attr('automation.new_automation_test',
'last_triggered') > timedelta(minutes = 5))
or (now() - state_attr('automation.new_automation_test', 'last_triggered') < timedelta(seconds = 5)) }}
then:
- service: notify.laptop_zac
metadata: {}
data:
message: |
run
last triggered {{ state_attr('automation.new_automation_test', 'last_triggered') }}
timedelta {{ now() - state_attr('automation.new_automation_test','last_triggered') }}
condition1 {{ (now() - state_attr('automation.new_automation_test', 'last_triggered') > timedelta(minutes = 5)) }}
condition2 {{ (now() - state_attr('automation.new_automation_test', 'last_triggered') < timedelta(seconds = 5)) }}
else:
- service: notify.laptop_zac
metadata: {}
data:
message: |
ignore
last triggered {{ state_attr('automation.new_automation_test', 'last_triggered') }}
timedelta {{ now() - state_attr('automation.new_automation_test','last_triggered') }}
condition1 {{ (now() - state_attr('automation.new_automation_test', 'last_triggered') > timedelta(minutes = 5)) }}
condition2 {{ (now() - state_attr('automation.new_automation_test', 'last_triggered') < timedelta(seconds = 5)) }}
mode: single
but to actually solve your original in tent… if you dont’ want the automation to run for 5 minutes ,you could do this:
alias: New automation test
description: ""
trigger:
- platform: state
entity_id:
- input_button.test
condition: []
action:
- if:
- condition: template
value_template: >-
{{ (now() - state_attr('automation.new_automation_test',
'last_triggered') > timedelta(minutes = 5))
or (now() - state_attr('automation.new_automation_test', 'last_triggered') < timedelta(seconds = 5)) }}
then:
- service: notify.laptop_zac
metadata: {}
data:
message: >
run
last triggered {{ state_attr('automation.new_automation_test',
'last_triggered') }}
timedelta {{ now() - state_attr('automation.new_automation_test','last_triggered') }}
condition1 {{ (now() - state_attr('automation.new_automation_test',
'last_triggered') > timedelta(minutes = 5)) }}
condition2 {{ (now() - state_attr('automation.new_automation_test',
'last_triggered') < timedelta(seconds = 5)) }}
else:
- service: notify.laptop_zac
metadata: {}
data:
message: >
ignore
last triggered {{ state_attr('automation.new_automation_test',
'last_triggered') }}
timedelta {{ now() - state_attr('automation.new_automation_test','last_triggered') }}
condition1 {{ (now() - state_attr('automation.new_automation_test',
'last_triggered') > timedelta(minutes = 5)) }}
condition2 {{ (now() - state_attr('automation.new_automation_test',
'last_triggered') < timedelta(seconds = 5)) }}
- delay:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
mode: single
i put a 5 minute delay at the end… combined with mode:single, this will prevent it from running for 5 minutes. note that it’ll be 5 minutes plus a touch… for whatever code to execute before it gets to that delay. if that’s important, it’s solvable too…