Can't Loop Script

Hi Guys,

I am trying to loop a script.
I first followed the example of the flashing lights scripts in the documentation but later found in the forums that a script calling itself is no longer supported.
I found a later example that contained two scripts, one to do the thing and another to call the first. I must be stupid because I cant work out why it doesn’t want to work for me when everyone else has success.

When running the script, I get an error of [homeassistant.components.script] Script script.weatherset already running.

Can you help me in the right direction?

> weatherset:
>     alias: "Set Weather Cube"
>     sequence:
>       - alias: "Set Weather"
>         service: shell_command.cube_clear
>       - delay:
>           seconds: 31
>       - alias: "Loop weather"
>         service: script.turn_on
>         data:
>           entity_id: script.weatherloop
>  
> weatherloop:
>      alias: "Loop Weather Cube"
>      sequence:
>      - service: script.turn_on
>        data:
>           entity_id: script.weatherset

Anybody? I’m so stuck on this one!

Not sure I’ve got your answer, but a couple things to try.

  1. In the weatherloop script, try adding a short delay before the script.turn_on service. Not sure if things run asynchronously.
  2. In weatherloop, try adding a script.turn_off for weatherset before you try the script.turn_on. So basically, stop and restart it. You might insert a bit of delay between off and on, spreading that 31 seconds between the three positions.
1 Like

Brilliant. That seems to work! Thank you so much!

Was it suggestion one or two? (for future visitors to this thread)

I did both, seemed cleaner to stop the script and to give the next one a delay before it tried to start the previous script again.