Need help to set dynamic value in delay based on repeat.index

alias: Garage Alert
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.ratgdov25i_18f389_motion
    to: "off"
    from: "on"
    for:
      hours: 0
      minutes: 0
      seconds: 5
condition:
  - condition: state
    entity_id: cover.ratgdov25i_18f389_door
    state: open
    for:
      hours: 0
      minutes: 0
      seconds: 5
action:
  - repeat:
      while:
        - condition: state
          entity_id: cover.ratgdov25i_18f389_door
          state: open
        - condition: state
          entity_id: binary_sensor.ratgdov25i_18f389_motion
          state: "off"
      sequence:
        - service: notify.mobile_app_iphone_14_pro
          metadata: {}
          data:
            message: >-
              Garage door is open for {{
              relative_time(states.cover.ratgdov25i_18f389_door.last_changed)}}
              from
              {{as_timestamp(states.cover.ratgdov25i_18f389_door.last_changed)|timestamp_custom('%A
              %I:%M%p') }}
        - delay:
            seconds: {% if repeat.index in range(1,4) %} 5 {% else %} 30 {% endif %}
mode: single

I’m trying to set 5 seconds for the first 3 occurrences, then 30 seconds for the rest. However, it throws me this error. It sounds like the value is empty

Message malformed: expected float for dictionary value @ data[‘action’][0][‘repeat’][‘sequence’][1][‘delay’][‘seconds’]

quote the seconds template? otherwise it thinks it’s a literal string perhaps?

1 Like

You are right. That’s stupid of me. I don’t know why it didn’t work when I tried that ealier