Looping an ESPHome script

Hello,
can somebody help me to loop this ESPHome script? I cant execute the same script inside the same script. That is what I tried:

script:
  - id: "jar_oc"
    then:
      - logger.log: "Jar automation is running"
      - servo.write:
          id: jaw
          level: -0.0%
      - delay: 0.6s
      - servo.write:
          id: jaw
          level: 100.0%
      - delay: 0.6s
      - script.execute: jar_oc

Thanks!

Hello friend,
To day i search for this solution … no result… but i have any idea and its work: implement to script while loop. example :

script:
  
  id: casovani_podavace
  mode: single
  then:
  - while:
      condition:
        switch.is_on: ventilator
      then:
      - logger.log: "Still executing"
      - delay: 1miin
      - switch.turn_on: podavac
      - delay: 1 min  # timer length
      - switch.turn_off: podavac

really thats work fine… Regards Dan

2 Likes