.last_triggered, true valid?

Anybody know if there is a preferred way of doing this?

value_template: '{{ (as_timestamp(now()) - as_timestamp(states.automation.breakfast_boolean.attributes.last_triggered, true | default(0)) | int > 12800)}}'

Claude code reckons “This template has a syntax error. The true parameter is misplaced. The as_timestamp() function doesn’t take a second boolean argument - it looks like true was accidentally inserted.

value_template: '{{ (as_timestamp(now()) - as_timestamp(states.automation.breakfast_boolean.attributes.last_triggered) | default(0)) | int > 12800 }}'

"{{ now() - this.attributes.last_triggered|default(as_datetime(0),1) > timedelta(hours=3) }}"

great, a third way! :smiley:

but yes, yours does seem much clearer. Thanks

ah just realised, it doesn’t work for this approach:-

  - alias: garyonthemove
    trigger:
      - platform: state
        entity_id: binary_sensor.gary_room_occupancy
        to: 'on'
        from: 'off'
    condition:
      condition: and
      conditions:
        - condition: template
          value_template: '{{ (as_timestamp(now()) - as_timestamp(states.automation.steveonthemove.attributes.last_triggered, true | default(0)) | int > 1200)}}'
        - condition: template
          value_template: '{{ (as_timestamp(now()) - as_timestamp(states.automation.marjorieonthemove.attributes.last_triggered, true | default(0)) | int > 1200)}}'

Try:

      conditions:
        - condition: template
          value_template: "{{ as_timestamp(now()) - as_timestamp(state_attr('automation.steveonthemove','last_triggered'),0) > 1200 }}"
        - condition: template
          value_template: "{{ as_timestamp(now()) - as_timestamp(state_attr('automation.marjorieonthemove','last_triggered'),0) > 1200 }}"