[solved] Problem with item changed in group

My sd card crashed an I installed openhab 2.1.0.
But with the new Installation one rule doesn´t work.

I use contacts from homatic in the group kontakte
Group kontakte

On the Sitemap all contacts have the correct state.

Now I use the old rule, so that when one item of the group changed the state i receive a mail with the item.
But now the rule doesn´t works

rule kontakrgruppestatus
when
Item kontakte received update
then
val dings = kontakte.members.sortBy[lastUpdate].last
sendMail("E-Mail Adresse", "Hausautomation - Kontakt", dings.label + " ist " + dings.state)
end

Anyone an Idea? In the logs I could see no errors

Since 2.1 you must give a Group a type in order for the Group to receive updates. So just change your Group definition to

Group:Contact kontakte

Ok now the rules works, but with
then
val dings = kontakte.members.sortBy[lastUpdate].last
logInfo(“TEST”,dings.label + " ist " + dings.state)
end

I only get the Status of the last item, not the item which changes at last the status

You might need a short Thread::sleep before your first line to give persistence a chance to catch up with the rule. It saves the state to the DB in parallel so your rule might be executing before the new state is saved.

now I had time to test it.
it doesn´t work

Now the rule begins with
rule kontaktgruppestatus
when
Item kontakte received update
then
Thread::sleep(3000)
val dings = kontakte.members.sortBy[lastUpdate].last
logInfo(“TEST”,dings.label + " ist " + dings.state)

but it does no matter which contact changed, I always receive the state of same contact

Please use code fences on any and all code you paste to the forum, even if it is just one line.

I recommend logging out the state and lastUpdate time for all the members of knotakte in your Rule first thing.

The sleep is FAR to long. It shouldn’t be more than 100-300.

When the code isn’t behaving as it should, have a look at what the state of everything is. Perhaps knotakte only has one member and the other Items are missing? Perhaps more than one Item is changing in a cascade so the same Item always ends up at the end. Maybe only one of the Items is being saved in persistence. Maybe one Item had a bad save to persistence and it is dated in the future for some reason.

Right now it is hard to tell what is going on.

I think the problem ist the configuration of rrd4j.
I will create the config and then post it here

I think I could solve the Problem.

I installed mapdb und create the file mapdb.persist

    Strategies {
    default = everyChange
}
Items {
    * : strategy = everyChange, restoreOnStartup
}

The rule Looks like

val dings = kontakte.members.filter[s|s.lastUpdate("mapdb") != null].sortBy[lastUpdate("mapdb")].last as ContactItem