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
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 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.