Looping scripts

Hey if someone is still wondering, I managed to do some kind of looping with one automation (must not be efficient but it works). Just use events !

example:

- action:
  - data:
      entity_id: media_player.bose
    service: media_player.volume_up
  - delay: 00:00:03
  - event: fade_in
    event_data: {}
  alias: Fade in Bose
  condition:
  - condition: template
    value_template: '{{ states.media_player.bose.attributes.volume_level < 0.5 }}'
  id: '1512675351358'
  trigger:
  - event_data: {}
    event_type: fade_in
    platform: event
1 Like

This is actually a very good idea. because this way you can kill the loop with turning off the automation for like 5 seconds. I had problems with this and resorted to kill both my scripts multiple times to really get it to stop.

~Cheers

This solution is really flaky. If the action you call takes a few seconds, the loop quickly catches up with itself and you get a “Script script.foo already running.”. This warning appears to automatically immediately halt the script. So this mechanism really cannot be relied on.