Hi!
I wanted to share this experience with you all, maybe someone have a good explication, but anyway, seems that in this situation, “Choose” wins.
I have an automation which have multiple “if-then” lines, all are similar, for every device, but when I get an error into one “if-then” the automation won’t continue to the next “if-then”, instead it will break the automation.
The line which breaks the automation is this:
- if:
- condition: state
entity_id: variable.computer2
state: 'on'
then:
- choose:
- conditions:
- condition: trigger
id: mute
sequence:
- service: notify.eventghost2
data:
message: Computer2 Mute
- conditions:
- condition: trigger
id: unmute
sequence:
- service: notify.eventghost2
data:
message: Computer2 UnMute
default: []
It will break the automation because my secondary computer, it is not really on, it is off and the notify.eventghost2 will get an error when the service will trigger (Failed to call service notify.eventghost2. Unknown error). Because of this, the automation will not continue to the next “if-then”.
In the other hand, “Choose” will do exactly what it should, does not matter if there is an error on the first “Choose” it will continue to the next one, no matter what. The automation will not break.
Similar to the “if-then”, but using “Choose”:
- choose:
- conditions:
- condition: state
entity_id: variable.computer2
state: 'on'
sequence:
- choose:
- conditions:
- condition: trigger
id: mute
sequence:
- service: notify.eventghost2
data:
message: Computer2 Mute
- conditions:
- condition: trigger
id: unmute
sequence:
- service: notify.eventghost2
data:
message: Computer2 UnMute
default: []
default: []
The conclusion: If someone does not know why the automation breaks when using “if-then”, think about “Choose”…
I don’t know if this is the real purpose of “if-then”, I didn’t read the exact documenation, but if is not, seem that this is a bug…