I have a script and want it to be executed from another script. HA runs all services but never execute the service with script. (script.tvzone_turn_off). is it intentionally not allowed to avoid recursive calls? or I do something wrong?
If a script uses a delay or wait_template then it has the potential to become busy. While it is waiting for the delay to expire, or the conditions of the wait_template to be met, it is considered to be busy and this script cannot be called at that time.
Scripts that contain delay or wait_template can be turned off. In the Lovelace UI, they are rendered with a toggle button.
Scripts that do not contain a delay or wait_template are rendered with an EXECUTE button.
If your tvzone_off script does not use a delay or wait_template then the issue you are experiencing may be due to something else.
Sorry Teras, I was under the impression that it DID run the already running script but it just skipped all the delays and went straight to the payload.
(i may be wrong, just trying for clarification)
If there are concerns about calling an already running script you âcouldâ either check if the script is running before hand or set a bit at the begining and reset it at the end and use that in auotmations/scripts to prevent doubling up
I may learn something here
Edit : Sorry, cross post (and yes I learnt something !)
Well⌠the child script does use the delay but the script itself is not runningâŚ
but ok, I will insert one more step to turn_off the script before calling it.
tvzone_turn_off:
alias: Tunr off TV zone
sequence:
- service: media_player.turn_off
data:
entity_id: media_player.amazon_tv_stick
- delay:
seconds: 5
- service: switch.turn_off
data:
entity_id: switch.rfkey4
the âsleep_allâ alwys performs successfully the steps #1 (rf3_switch_asus) and #3 (sonoffdual) but ignores the #2 (script.tvzone_turn_off). I cannot imagine the âtvzone_turn_offâ is executed by something else during its callâŚ
I know that automations behave that way and until VERY recently they were handled by the same python code. I know they have now split it, but Iâm not sure of the current divergence.
Dunno, Iâm speculating based on whispers
No there should be no issue doing so. How odd this is not happening. running scripts from within scripts or automations (which is effectively identical) forms the base of HA automation, so that should be debugged if it is not working for you.
You could start by eliminating all data fields here, which are unnecessary. They might not cause trouble but less characters is less code to debug
I found all my scripts in the Lovelace UI Scene editor⌠executable and editable but it does not show the âentity_idâ there. I tried to create a simple scene, saved it and then it reformated my âscripts.yamlâ file: removed all comments, blank lines, etc⌠On another side, the good news is the âsleep_allâ script works now !?!
Ooops. you are right. these two items next to each other. I have mixed them⌠Sorry. But anyway my script_in_script works fine. I have removed âdata:â as you suggested, the code looks much better now, and the Web editor âcleanedâ the âscript.yamlâ as well. All works! Thanks!