Understanding automations with time delays and how to control them

I tried this, but I got an error with the input_datetime.set_datetime function in the action section:

Error rendering data template: UndefinedError: 'datetime.timedelta object' has no attribute 'timestamp'

Something changed in HA syntax?

There are missing parentheses in that example’s template. It would appear you are the first person to detect that error in over 2 years!

Change this:

{{ (now() + timedelta(minutes=30).timestamp()) | int(0) }}

to this:

{{ ((now() + timedelta(minutes=30)).timestamp()) | int(0) }}

So I revisited my automation and I guess I don’t do any of what was originally sorted out in this thread. Here’s my current “run the air filter for 30 mins” code, along with the ability to stop it with an additional button press. I just use a timer to countdown the time.

alias: "Master bedroom: Air filter 30 minutes"
description: ""
trigger:
  - platform: device
    domain: mqtt
    device_id: 80037f3661ddac4
    type: action
    subtype: 4_single
    discovery_id: action_4_single
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.mbr_air_filter
    id: timer_complete
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: timer_complete
        sequence:
          - type: turn_off
            device_id: ef36fa9d247036d3
            entity_id: switch.tasmota_switch_relay_1
            domain: switch
      - conditions:
          - condition: state
            entity_id: timer.mbr_air_filter
            state: idle
        sequence:
          - type: turn_on
            device_id: ef36fa9d247036d3
            entity_id: switch.tasmota_switch_relay_1
            domain: switch
          - service: timer.start
            data:
              duration: "00:30:00"
            target:
              entity_id: timer.mbr_air_filter
      - conditions:
          - condition: state
            entity_id: timer.mbr_air_filter
            state: active
        sequence:
          - type: turn_off
            device_id: ef36fa9d247036d3
            entity_id: switch.tasmota_switch_relay_1
            domain: switch
          - service: timer.cancel
            target:
              entity_id: timer.mbr_air_filter
            data: {}
    default: []
mode: single