OR-Group doesn't change

Hi, for some reason, the below group does not reflect the state of the two group members. Anyone has any ideas what I am doing wrong…?

OT_AtHome     (Type=SwitchItem, State=ON, Label=null, Category=null, Groups=[owntracks, gPresence])
PhonePresence (Type=SwitchItem, State=ON, Label=null, Category=null, Groups=[gPresence, gFamilyPhones])
gPresence     (Type=GroupItem, BaseType=SwitchItem, Members=2, State=OFF, Label=null, Category=null, Groups=[gPersonPresenceSwitches])

The items and group definitions are

Group:Switch:OR(ON, OFF) gPresence
Switch OT_AtHome             (owntracks,gPresence) 
Switch PhonePresence         (gPresence,gFamilyPhones) {channel="network:pingdevice:iphone:online" }

Thanks for any ideas, I’m hitting a wall here…

Group:Switch:OR(ON,OFF) gPresence

No space

thanks for the swift reply - sadly, that didn’t do it.

Weird, I have almost exactly the same setup…
Let’s try something else,

Re-order the groups in OT_AtHome

Switch OT_AtHome             (gPresence,owntracks)

Save

Comment out the Group

// Group:Switch:OR(ON, OFF) gPresence

Save
Remove comments
Save
Monitor the log while you are doing this

Save

HI @vzorglub, thanks for your thoughts, but that didn’t reveal or change anything. The logs just reported the expected refreshed items definition. What really puzzles meis that looking at the items in KARAF, the connection and group assignment all seem to be o.k. Also,I have added a test-switch that is member of the same group and any time I manually switch it, the group’s state changes correctly. I am now thinking that I have maybe messed up setting the group items with sendCommand/postUpdate in an inconsistent way, although my understanding is that a groups state is only depending on the member item’s state regardless of how those states were set. Anyways,I will search through the code to try and clear that up and will report back if that does anything good…

That’s a possibility,
Can you post any rules that contains the group itself, please? I’ll have a look too. 4 eyes always better than 2.

I’m not updating the group directly, but only the member items and that’s unfortunately happening in various rules, so I need to crawl through all of them… :frowning:

The only place that I am handling the group itself is in the rule that checks presence of all family members:

rule "group Presence updated, at least one sensor changed state"
when
    Item gPresence changed
then
    Thread::sleep(500)
    val sensors = gPresence.members.filter[sensor | sensor.lastUpdate("mapdb") !== null]
    if(sensors === null) logWarn("presenceDetection", "Something is wrong, no Item has a valid lastUpdate!")
    var tc = 0
    sensors.forEach(s | if (s.state == ON) {tc = tc + 1})

    // someone came home
    if(gPresence.state == ON && PresenceDetected.state != ON) {
        PresenceTimer.postUpdate(OFF) // cancel the timer if necessary
        PresenceDetected.sendCommand(ON)
        logInfo("presenceDetction", "someone came home")
//        sendCommand(Alarm_ArmActivity,OFF)
    }

    // no one is home
    else if(gPresence.state == OFF && PresenceDetected.state != OFF){
        PresenceTimer.sendCommand(ON) // start the timer
        logInfo("presenceDetction", "last person left home, 5 min timer started")
    }

    // no change in presence status
    else {
        logDebug("PresenceDetection", "no change in presence status at home")   
    }
end

Now,I just noticed something interesting: after adding some more logging and checking the presence detection of a phone in the WiFi, the logs report a phone state changing to ON and with all other group items being in OFF state, the group still shows OFF:

2018-04-28 09:16:35.250 [INFO ] [se.smarthome.model.script.loggerName] - PhonePresence_Kid updated to ON
2018-04-28 09:16:35.254 [INFO ] [se.smarthome.model.script.loggerName] - gPresence_Kid GROUP now is OFF

the phone item is defined via the network binding

Switch PhonePresence_Kid        (gPresence_Kid,gFamilyPhones) { channel="network:pingdevice:iphone_kid:online" }

So it looks like the item update via network binding doesn’t cause the group to be updated…?!

and gPresence_Kids definition?

Group:Switch:OR(ON,OFF) gPresence_Kid   (gPresence) 

So, every family member has an individual presence group gPresence_XX that contains the individual OT_AtHome_XX and PhonePresence_XX items. The overall gPresence group contains the individual gPresence_XX groups as members. However, the issue arises on the individual level already:

Group:Switch:OR(ON,OFF) gPresence_Kid   (gPresence) 
Switch    OT_AtHome_Kid         (gPresence_Kid,owntracks)
Switch    PhonePresence_Kid     (gPresence_Kid,gFamilyPhones) { channel="network:pingdevice:iphone_kid:online" }

The group gPresence_Kid is not handled directly in any rule, but the member items are. When both member items are off and PhonePresence_Kid changes to ON (via network binding), the group doesn’t change state to ON

I am sure there is something really silly I’m missing, but for now I’m stuck…

Try in the group the other way around:

Group:Switch:AND(OFF,ON) gPresence_Kid (gPresence)

How are you getting on?

same result…

I’ve decided to let it sit for a moment and do some gardening :grimacing: sometimes it helps to give it a break and come back fresh after a few hours. I still think it must be something silly somewhere that I just don’t see because I’ve been focussing on it for too long…

In your items file, are your groups defined before the items?

actually, they are defined in separate files, so I can’t say that for sure. However, the items list in KARAF shows the groups and items properly defined

gPresence_Kid (Type=GroupItem, BaseType=SwitchItem, Members=2, State=OFF, Label=null, Category=null, Groups=[gPresence])
OT_AtHome_Kid (Type=SwitchItem, State=OFF, Label=null, Category=null, Groups=[gPresence_Kid, owntracks])
PhonePresence_Kid (Type=SwitchItem, State=ON, Label=null, Category=null, Groups=[gPresence_Kid, gFamilyPhones])

Just to try can you put your group definition just above the items belonging to that group in the same file to see what happens?

hi @vzorglub, thanks for staying involved in this!

I don’t think this is an issue of order of file load/item definition as otherwise the KARAF info wouldn’t show the correct assignments…

I have now completely rebooted the OH server and as of now, the behavior is as expected when I manually change the member items. My best guess at this point is that after several re-saves of item and rules files, something must have gone awry in the OH instance. I guess I should have tried the reboot earlier… :blush:

Should the strange behavior return, I will post it here!