Incorrect Group:Switch:AND value lookup

I’m using stable release of Openhab 2.2, within Docker-amd64-debian container.

I have a following config:

Switch test_switch1 (gAnd)
Switch test_switch2 (gAnd)
Switch test_switch3 (gOr)
Switch test_switch4 (gNand)
Switch test_switch5 (gNand)

Group:Switch:OR(ON,OFF) gOr (gAnd)
Group:Switch:NAND(ON,OFF) gNand (gOr)
Group:Switch:AND(ON,OFF) gAnd

When I set ON value to test_switch1, test_switch2, test_switch4, and OFF value to switches test_switch3 and test_switch5 — everything looks fine: all groups have state ON.

If I understand AND-group switches correctly — when test_switch1, or test_switch2, or gOr will have state OFF, then the group gAnd also should have state OFF. But it’s not really what happens for me: when I change test_switch5 to ON, the groups gNand and gOr goes OFF, but group gAnd remains the same — with state ON. And if I’ll change test_switch2 to OFF, then gAnd become OFF

Can anybody please help me with this? Am I doing something wrong, or this is a bug in openhab?

UPD: Recursive lookup itself seems to be working, following 2 configs works just as I expecting:

Switch test_switch1 (gAnd3)
Switch test_switch2 (gAnd3)
Switch test_switch3 (gAnd2)
Switch test_switch4 (gAnd2)
Switch test_switch5 (gAnd4)

Group:Switch:AND(ON,OFF) gAnd
Group:Switch:AND(ON,OFF) gAnd2 (gAnd)
Group:Switch:AND(ON,OFF) gAnd3 (gAnd)
Group:Switch:AND(ON,OFF) gAnd4 (gAnd3)
Switch test_switch1 (gOr3)
Switch test_switch2 (gOr3)
Switch test_switch3 (gOr2)
Switch test_switch4 (gOr2)

Group:Switch:OR(ON,OFF) gOr
Group:Switch:OR(ON,OFF) gOr2 (gOr)
Group:Switch:OR(ON,OFF) gOr3 (gOr)

Looks like there is an issue with using combination of AND and NAND :frowning:

I do not think that the aggregation functions are recursive (i.e. do not aggregate the Items from subgroups) nor do they include the state of subgroups in their calculations.

I’ve done some testing and updated the first post. Looks like AND and OR functions are recursive within themselves… so, probably, something strange begins to happen after mixing them with each other and other functions.

What do you think, should I file an issue on github for this one, or just leave it and forget? :slight_smile:

Certainly, if it is inconsistent an issue should be filed. There is no reason in my mind why a combo of AND and NAND should work differently.

It is good to know that the functions do recurse.