Per the wiki:
AND(value1, value2) This does a logical ‘and’ operation. Only if all items are of ‘value1’ this is returned, otherwise the ‘value2’ is returned.
…
OR(value1, value2) Does a logical ‘or’ operation. If at least one item is of ‘value1’ this is returned, otherwise the ‘value2’ is returned.
So a Switch is treated as a Boolean and so:
AND(OFF,ON) - if all Switches are OFF, the Group’s state will be OFF. Otherwise (i.e. at least one Switch is ON) the Group’s state will be ON
OR(ON, OFF) - if at least one Switch is ON, the Group’s state will be ON. Otherwise (i.e. all Switches are OFF) the Group’s state will be OFF
It is two ways to test for the same thing, one with an AND and one with an OR. The big trick is to realize that the first value in the parens is the state that is being ANDed or ORed and therefore it isn’t treating ON and true and OFF as false by default; you specify what it considers to be true. I don’t know if that makes sense.
Another way to think of it is it counts the number of Items that are the first value.
When doing an AND and that count equals the number of Items the Group’s state is set to the first value, otherwise it is set to the second value.
When doing an OR and that count is equal to one or more then the Group’s state is set to the second value, otherwise it is set to the second value.
So whether you use the AND or the OR example from above, the state of the Group will be set to ON if one or more of the member switches are ON. And since you can do anything with a Group that you can do with an Item (i.e. trigger a rule, check its state, send it a command) you can:
- put it on your sitemap as a Switch and control all of the lights with one switch
- trigger a rule**
- check its state in a Rule (e.g.
if(Home.state == ON){
)
** A note about triggering a rule with a Group. The state of a Group is calculated in steps so if you trigger a rule when the Group gets updated the rule will be triggered multiple times. However, if you trigger the rule only when the Group’s state changes be aware that the Group will only change state based on the AND and OR rules above. For example, when all the Switches are OFF and one turns ON the Group will change state to ON and the rule will trigger. However, when the second Item turns ON the Group is already ON so it doesn’t change state and the rule doesn’t fire.