Capturing the automations last_triggered inside the automation itself

I currently have this condition block which works great:

condition:
  - condition: or
    conditions:
      - condition: template
        value_template: "{{ trigger.payload_json['type'] == 'new' }}"
      - condition: template
        value_template: "{{ before_zones | length == 0 }}"
  - condition: time
    after: input_datetime.camera_arm_start
    before: input_datetime.camera_arm_end
  - condition: template
    value_template: >-
      {{ not state_attr('automation.frigate_alarm_driveway_night',
      'last_triggered') or (now() -
      state_attr('automation.frigate_alarm_driveway_night', 'last_triggered') >
      timedelta(minutes=int(states('input_number.camera_cooldown')))) }}

My logic and reason is that I am using this as a ‘cooling off period’ configured against a number Helper (time of 3 minutes).

Is it possible to not hard code the autonation name into the automation itself to determine last triggered?

Use this.entity_id in place of the automation’s entity_id.

state_attr(this.entity_id, 'last_triggered')

Reference

Trigger Variables - this object

1 Like

Thank you!

1 Like