XOR not working


1) Give a description of the problem
When I turn on a light then my piston should check if there is one and only one person present and if so then change my house to a specific home mode. For this I am using XOR but is not working as expected.

2) What is the expected behavior?
I have 2 presence sensors and one is present and the other is away. The XOR should return a true when the state of the devices is different one to the other but is actually returning a false

3) What is happening/not happening?
The XOR is returning a false, should return a true

4) Post a Green Snapshot of the piston

5) Attach any logs (From [ST IDE] and by turning logging level to Full)


I vaguely remember this coming up a long time ago, and you’re right - it doesn’t work. I wish I had some steps to offer to correct it, but short of writing in your own XOR function I don’t know of one.

This simple test - you can see both lights were on but it evaluated true:


So any idea on how to request the developer to fix this ??

just to let you know the way I manage to make it work today the way I want is as next:



The guy that developed webCoRE works for SmartThings now so development hasn’t been making much progress. Thankfully what is here usually has a few workarounds for things that don’t work as expected. You could re-write your piston as below to reduce the number of conditions and make it easy to add more presence sensors to the equation… you could also use an array to populate presence and count the number of them present, or any other number of methods.

Despite not having an ‘answer’ I hope this helps!


XOR seems to be unimplemented as a condition, there just isn’t any code for it as far as I can see. You can do this more concisely in an expression using the ^^ logical xor but it becomes more difficult to maintain if you have multiple presence devices for each person:

if [P-Golf Arrival Sensor: presence] ^^ [P_ Lucy Aguirre's Android: presence] is true

A more flexible alternative is to use one condition with the physical device dropdown with “what to compare” set to the presence for the first person and “compare to” the presence for the second person. Then use “is not” as the comparison which behaves the same as XOR since there are only two values to compare.

The presence values are strings “present” and “not present” but they are coerced to booleans so the logical xor works as expected:

(expression) 'present' ^^ 'not present' »»» (boolean) true
(expression) 'present' ^^ 'present' »»» (boolean) false


oh so I guess is good that the guy that developed webCore works for smartthings now as he can formally implement something similar to this but native integrated to the smartthings app as we know WebCore is a third party smartapp.
Thanks for the workaround, actually I like more that one than the one I used so I can reduce code lines.


Not that it comes up often, but would it be easy to remove it from the condition builder drop-down selections next time there is an update rolled out?


so not sure I fully understood how to use the ^^ Is it similar to XOR ??


Yes it’s the logical XOR operator described in the docs. The example [P-Golf Arrival Sensor: presence] ^^ [P_ Lucy Aguirre's Android: presence] will return true only if exactly one side evaluates to true. The expression [P-Golf Arrival Sensor: presence] will return either "present" or "not present" but webCoRE treats those as the boolean values true and false, respectively, as you can see in the earlier example:

(expression) 'present' ^^ 'not present' »»» (boolean) true
(expression) 'present' ^^ 'present' »»» (boolean) false