Automations if/elif and delay

Hi, I can’t get delay to work using the if/elif code, how do I make it do the program?
I have the data

input_boolean:
  delay_led_ver1
  delay_led_ver2
  delay_led_ver3

input_datetime:          # 00:03
  delay_led_ver1_off:    
    has_date: false
    has_time: true

delay_led_ver2_off:    # 00:05
    has_date: false
    has_time: true

delay_led_ver3_off:   #    03:00
    has_date: false
    has_time: true

and automations
...
action:
    - delay: 
        value_template: >
          {% if is_state('input_boolean.delay_led_ver1', 'on') %} delay_led_ver1_off
          {% elif is_state('input_boolean.delay_led_ver2', 'on') %} delay_led_ver2_off
          {% elif is_state('input_boolean.delay_led_ver1', 'on') %} delay_led_ver3_off
          {% else %}
          {% endif %}
    - service: switch.turn_off
      data:
        entity_id: switch.relay_led_faza1
    - service: switch.turn_off
      data:
        entity_id: switch.relay_led_faza2

If those are the actual configurations for your helpers, they are mostly incorrect.

  • If your Input boolean helper entities do not show up in the Entities menu, you should start by sorting them out.
  • Input datetimes are not durations. The delay action accepts seconds as an input, so a better helper to use with a delay action would be an Input number.
  • delay does not use any additional keys like value_template, just place the template directly as the value for delay
  • Your if/then in the template has two clauses with the same if argument, and your else doesn’t have a value…

Community Guidelines: Help us Help You

It is much easier to help if you post a complete automation and your actual configuration, then describe what your goal is instead of posting bits and pieces…