I don’t think XOR will quite do that for you. Keep in mind that XOR works on only two operands at a time and works from left to right. So if you write the truth table for a three item XOR in sequence like that you get.
‘’’
A B. C. Result
Off off off off
On off off on
Off on off on
Off off on on
On on off off
On off on off
Off on on off
On off on off
On on on on
I’m pretty sure that is not the behavior you are looking for.
To explain one of the word cases.
On on on:
On xor on = off. Off xor on = on
The problem is because it evaluates the first two operands and then uses the result of that operation with the last operand.
From your latest description it sounds like you don’t care what state the switches are in. If any of them change state your want to toggle the light.
That is pretty easy too but using the group update to trigger the rule is s problem because the group receives multiple updates for each event. So the rule becomes:
‘’’
rule “light”
when
Item Switch1 received command or
Item Switch2 received command or
Item Switch3 received command
then
Light.sendCommand(if(Light.state ==ON) OFF else ON)
end
‘’’
there difference in terms of speed?
If there is it is not enough to matter.
Or is this totally wrong idea?
Unfortunately this is one case where you can’t use groups because one change in a group’s Item generates multiple updates. And since you don’t care about the switch’s absolute state, only the fact that one of them changed, there is no clear way to filter out the extra events. Consequently your lights would flicker and may or may not end up where you want them.
However, with two extra lines of code my rule from above will work. Assuming Light3 is your WebSwitch:
‘’‘rule “light”
when
Item Switch1 received command or
Item Switch2 received command or
Item Switch3 received command
then
val newState = if(Light.state == ON) OFF else ON
Light.sendCommand(newState)
Switch3.postUpdate(newState)
end
‘’’
By using postUpdate we can change the state of Switch3 to always match the relay without retriggering the rule. So if you put Switch3 on your sitemap you can use this one Item to know the state of the light and to turn the light off and on. No need for separate status and control lines in the sitemap.
Note, typed all of the above on my phone. Pardon the errors.