I was looking thru my code to clean up some of the and / or conditions with the new shortcut from Thomas, and I found this one I was using.
Don’t know how or where I came up with it, but it appears to be working. I look at the samples in the Docs and every list item appears to start with ‘condition:’. Is that word not needed if the condition is a template?
Like I said, this appears to work, but is that intended. Looking for a Masters Opinion.
First, I am the LAST person on the forums that should be advising on YAML code. I am 99% wrong most of the time.
That said, try changing ‘off’ to ‘on’ and see if the action follows the new test.
I don’t think the second syntax is correct.
condition: evaluates everything that follows as true or false. condition: or evaluates true if anything that follows is true condition: and evaluates true if everything that follows is true.
The indenting rules of YAML determines what ‘follows’ includes. I am confused with the indenting in your former code segment. This is what I think it should be:
condition:
condition: or
conditions:
- first condition
- second condition
… means that the condition: evaluates as true if the -first or the -second conditions are true
You can mix other conditions, like and:
condition:
condition: or
conditions:
- first condition
- second condition
condition: and
conditions:
- third condition
- fourth condition
… means that the condition: evaluates as true if the -first or the -second conditions are true, AND both the -third and -fourth conditions are true.
If I am wrong, we will certainly be corrected very soon.
(If you want the right answer online, provide a wrong one).
I missed that top ‘condition:’. I see it in the docs now.
What I wasn’t sure about is if the ‘if’ in any form (long or short) will iterate correctly with just a list, and you are confirming that it will.
I suppose because they are templates nothing else is needed, they are in the end true or false (pos or 0/neg)