Evaluating Group Item fails

Hi community,

I have a couple of keyfobs which send scene numbers when a button is pressed. I’d like to evaluate the name of the keyfob item which was used and the value it transmitted.

I’m currently using OH2.1 stable on openhabianpi.

I have the following item definition:

Number FB1_Szene "FB1 Szene [%.1f]" <keyring> (gSensoren, gFB_Szene) {channel="zwave:..."}
Number FB2_Szene "FB2 Szene [%.1f]" <keyring> (gSensoren, gFB_Szene) {channel="zwave:..."}
Group:Number:MAX gFB_Szene 

and this rule:

rule "FB Taste gedrückt"
    when Item gFB_Szene changed
            val FB = gFB_Szene.members.sortBy[lastUpdate].last
            val nameOfFB = FB.name
            val valueOfFB = FB.state
            logInfo("alarm", "Fernbedienung " + nameOfFB + " betätigt und den Wert " + valueOfFB + " übermittelt")

The items are listed in rrd4j.persist

Items {
FB1_Szene : strategy = everyChange
FB2_Szene : strategy = everyChange

Now when I press a button the rule is triggered but comes up with an error:

[ERROR] [.script.engine.ScriptExecutionThread] - Rule 'FB Taste gedrückt': null

Any idea what I’m doing wrong?

Kind regards

One or more of the members of gFB_Szene is NULL and/or not in persistence yet (you are saving these Items in persistence right?). You can filter them out.

val FB = gFB_Szene.members.filter[fb | fb.lastUpdate != null].sortBy[lastUpdate].last

Hi Rich,

that was exactly the problem. One item wasn’t initialized and therefore the item state was NULL.

Thank you very much for your assistance.

Kind regards