Hello,
I have an automation which calls multiple scripts in sequence:
service: script.mon_script
data:
param1: ma_valeur_1
data_template:
param2: ma_valeur_2
service: script.mon_script
data:
param1: ma_valeur_3
data_template:
param2: ma_valeur_4
Problem is that I would need those scripts to be executed in parallel. Therefore, I am trying to follow this documentation: Scripts - Home Assistant
However, I do not find the correct syntax to replace my current implementation with script.turn_on, and still being able to pass parameters (data and data_template)
Have someone already managed to do this ?
Thanks for the help !
tom_l
October 19, 2021, 9:21am
2
- service: script.turn_on
target:
entity_id: script.mon_script
data:
variables:
param1: ma_valeur_1
param2: ma_valeur_2
- service: script.turn_on
target:
entity_id: script.mon_script
data:
variables:
param1: ma_valeur_3
param2: ma_valeur_4
See here: https://www.home-assistant.io/integrations/script/#passing-variables-to-scripts
3 Likes
toukite
October 19, 2021, 10:37am
3
Thank you !
But what about the type “data” vs “data_template” that I had ?
Both should be listed as “variables” now ?
koying
(Chris B)
October 19, 2021, 11:19am
4
data
and data_template
are just synonyms, nowadays. Use one or the other.
dariowho
(Dario)
November 14, 2021, 2:44pm
5
Hi all, I just wanted to add a bit of information that took me a while to figure out. When running a similar automation I got a warning like:
[homeassistant.components.script.mon_script] mon_script: Already running
This caused the second instance of the script to be aborted. Following another thread (What exactly happens on WARNING [homeassistant.components.script] Script script.xxx already running? - #2 by nickrout ), I solved by adding a script.turn_off
step in between the two calls:
- service: script.turn_on
target:
entity_id: script.mon_script
data:
variables:
param1: ma_valeur_1
param2: ma_valeur_2
- service: script.turn_off
target:
entity_id: script.mon_script
- service: script.turn_on
target:
entity_id: script.mon_script
data:
variables:
param1: ma_valeur_3
param2: ma_valeur_4
lmamakos
(Louis Mamakos)
November 14, 2021, 2:52pm
6
I don’t think that does what you think. Instead, in the definition of the script you out to specify mode: parallel
rather then having the default of single
for the script. I think that default script mode is what is causing the warning you see.