Second, you do know that with a while loop itās possible the actions will never run, right? I.e., if the state of the alarm is not triggered when the script is called then it will not run the sequence in the loop.
If you always want it to run the sequence at least once, then use until:
- repeat:
sequence:
- ...
until:
- condition: not
conditions:
- condition: state
entity_id: alarm_control_panel.allarme
state: 'triggered'
Thanks a lot for your reply @pnbruckner, 1st for the beautiful implementation and news about scripting and automations
I have the 1 Ms second because I have a series of script and the delay permit at the automation to call other script asynchronous.
I also will wait a patch for the variables, now I receive an error if I use the variables.
Tanks a lot Again
But can i use this also in automation?
I have an automation that call a list of script so if i use script.turn_on in the automation action works like the wiki?
An works also if part of the script fail? for example service: media_player.volume_set
The new script
01notifiche_alexa_allarme_test_novr:
sequence:
- service: media_player.volume_set
data:
entity_id: media_player.ovunque
volume_level: 1
- delay: 00:00:02
- repeat:
sequence:
- data_template:
data:
method: all
type: announce
title: 'Prova'
message: 'Prova'
service: notify.alexa_media_ovunque
# Give it time to complete
- delay: 00:00:05
until:
- condition: not
conditions:
- condition: state
entity_id: alarm_control_panel.allarme
state: 'triggered'
- delay:
milliseconds: 1
- service: media_player.volume_set
data:
entity_id: media_player.ovunque
volume_level: 0.5
First, Iām not sure how turning on a switch can fail or cause an error. But if it did, that would cause the automation to stop running its actions so the following steps that call other scripts would not be executed. Also, since script.03notifica_telegram_cameracucina_immagine was called via script.turn_on, it would not be affected by the error and would continue to run independent of the automation.
Hi. Apologies NB here. Really struggeling. Please see answers to your questions:
For future reference, please post your question in a separate topic and not part of a thread that has been inactive for 2 months. - Will Do.
Please post your code and not a screenshot of your code. - Really struggling to get the indentation correct when I dot hat.
Does the script pass Configuration > Server Controls > Check Configuration? Cant seem to find this in that directory
Are you certain the condition is correct? I think so yes.
What do you mean exactly when you say it doesnāt work? Does it produce an error message in the log or does it not behave the way you expected?Let me try again:
Error I get:
Invalid config for [script]: Entity ID {{besp}} is an invalid entity id for dictionary value @ data[āscriptā][ābesproeing_repeatā][āsequenceā][0][ārepeatā][āuntilā][0][āentity_idā]. Got ā{{besp}}ā. (See /config/configuration.yaml, line 12).
You should know that this automation is not likely to ever perform the repeat for more than one iteration. The moment it turns on the switch, the condition is satisfied and there are no additional repetions.