Calling scripts within scripts

Hi,

Im having some issues with scripts calling other scripts that have delays or while loops within them. At first I was just calling the scripts directly but then read about using the script.turn_on service which I now use.

However, I have an automation that calls a script when my plex client changes state. Within that script is call to another script to turn on my electric fire (called using script.turn_on) which has a while loop within it (whilst tv and av reciever on, it monitors the temp etc).

The first time the calling script runs its fine, but after that it wont respond to state changes of plex unless I disable the call action of the script that contains the while loop. I have also noticed this with other scripts that have while loops when being called from other scripts.

Anything I can do to make the calling script carry on working whilst the other scripts are still running?

Make sure to set the script’s mode appropriately for how you want it to behave.

Also, avoid continuous looping. Set up an automation that triggers on the temp crossing a threshold and have the tv and monitor states as conditions.