I'm trying to sync one lock to another lock with an automation with a condition based on the automations last_triggered attribute. the problem is when the automation triggers the condition always fails. the same condition seems to work correctly when used in either a template under dev tools or when using 'test' on the automation trigger page.
I've tried using both
this.attributes.last_triggered
and
state_attr('automation.nfc_lock_frontdoor', 'last_triggered')
but both fail on the condition.
any suggestions?
alias: NFC Lock State change
description: ""
triggers:
- entity_id:
- lock.homekey_frontdoor_homekey_front_door
trigger: state
conditions:
- condition: template
value_template: >-
{{ this.attributes.last_triggered is not defined or now() -
this.attributes.last_triggered >= timedelta(seconds=10)}}
enabled: true
actions:
- if:
- condition: state
entity_id: lock.homekey_frontdoor_homekey_front_door
state:
- unlocked
then:
- action: lock.unlock
metadata: {}
data: {}
target:
entity_id: lock.front_door_lock
else:
- if:
- condition: state
entity_id: lock.homekey_frontdoor_homekey_front_door
state: locked
then:
- action: lock.lock
metadata: {}
data: {}
target:
entity_id: lock.front_door_lock
mode: single