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…
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…
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
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:
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…
I’ve decided to let it sit for a moment and do some gardening 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…
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
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…
Should the strange behavior return, I will post it here!