Group:Switch:OR(ON,OFF) myGroup - Why will this count?

It’s frustrating me. Why is this counting all ON member items?

Group:Switch:OR(ON,OFF) gPresence

I just want ON or 1 as result if one or more items are ON. What I’m doing wrong here?
The doc says:

OR(value1, value2) Does a logical ‘OR’ operation. If at least one item is of ‘value1’ this is returned, otherwise the ‘value2’ is returned.

How can value1 > 1 ???

Not sure I completely understand the problem but the item

Group:Switch:OR(ON,OFF) gPresence

will switch to ON if either one of its members switch to ON.
As in, as long as any member of that group is ON the gPresence group item will switch to ON.

Sure, but the underlying value is 2 for me, if two items are ON. Why? I used OR and not SUM.
OH2 switch is interpreting any value > 0 as ON. But I just want an ON=1, not 2 or 3 or…

EDIT: I have the same problem with Contacts. Problem with this is, how should I add a mapping to a not constant value?

2=more on
3=even more on

For me the OR is buggy. What happens should happen if I used SUM. But I don’t,

A switch handles ON or OFF states not numbers…should you be using a rule instead?

Yes. But how can (ON or ON) == 2. It has to be 1. This is what happens for me in OH2 stable release.

Please try this:


Group:Switch:OR(ON,OFF) myGroup
Switch sw1 (myGroup) 
Switch sw2 (myGroup)


Switch item=sw1
Switch item=sw2
Text item=myGroup label="myGroup [%d]"

What is the output of Text myGroup for you?

It should be

Text item=myGroup label="myGroup [%s]"

now I can map to ON and OFF in the transform.

Solved. But not 100% logical, because even if %d is output a double, it should be 1 and not a sum of all items.

I know some people would like this feature, but I do not think it is intended behaviour. I do not use OH2 yet, but can others confirm this counting? Should an issue be raised?

I think you will find that the %d parameter returns the number of items in the group, which is 2 in your case. The %s returns the string representing the state. Or something like that.