Need help to find wich item triggered the rule

Hi everybody.

Here is the problem. I have more than 20 zones that have a unique rule for each. These rules get triggered when the contact changes state (closed/open) and a new time / date in postupdated to a zoneX_update.

rule “Update temps Zone1”
Item Zone1 changed from “CLOSED” to “OPEN” or
Item Zone1 changed from “OPEN” to “CLOSED”

var String date = sdf.format( new Date() )
if(Zone1.state == CLOSED) logInfo(“Activite”, “Detection de FEU OUVERT”)
if(Zone1.state == OPEN) logInfo(“Activite”, “Detection de FEU FERMEE”)

I would like to have a unique rule that includes all the zones and finds the one that is being updated. Once it’s found, I would like to have $ZONE_update to be postupdated.
Here is the items:

Group:Contact:OR(OPEN,CLOSED) Alarme “Tous les contacts [(%d)]” (All)
Group Persistence “Items persistence”
Contact Zone1 “Feu [MAP(]” (rdc_corridor,Alarme,Persistence)
String Zone1_update “Feu [%s]” (Persistence)

Here is the persistence file:
Items {
Persistence* : strategy = everyChange, restoreOnStartup

I tried to have this rule woirking with others items, and it gives me an java error. I know that the items are different from above but they have the same base groups and persistence…It was easier for me to test.

Thread::sleep(250) // give persistence time to populate lastUpdate
val mostRecent = Interrupteurs?.members.sortBy[lastUpdate].last as SwitchItem
logInfo(“Activite”, "Most recent is " +

2015-10-27 21:49:00.552 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule ‘Update time sensors’
java.lang.NullPointerException: null
at org.eclipse.xtext.xbase.lib.ListExtensions$ ~[na:na]
at java.util.TimSort.countRunAndMakeAscending( ~[na:1.8.0]
at java.util.TimSort.sort( ~[na:1.8.0]
at java.util.Arrays.sort( ~[na:1.8.0]
at java.util.Collections.sort( ~[na:1.8.0]
at org.eclipse.xtext.xbase.lib.ListExtensions.sortInplaceBy( ~[na:na]
at org.eclipse.xtext.xbase.lib.IterableExtensions.sortBy( ~[na:na]
at sun.reflect.GeneratedMethodAccessor175.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke( ~[na:1.8.0]
at java.lang.reflect.Method.invoke( ~[na:1.8.0]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation( ~[na:na]

Thanks for your help



New update…
I found for the error. One item didn’t had the persistence group, so it was not in the db4o file. For the rest, same, same difficulty :smile:
But I also find that the group item, once it’s triggered from CLOSED to OPEN, all the other items that follow in the group and that are change from CLOSED to OPEN or OPEN to CLOSED, does not trigger the rule. Any patch for that???

Thanks again

That is expected Group behavior. The Group is a rollup of all the Items that are members, not a proxy for those items.

Unfortunately you will either have to list all of the Zones Items as individual triggers, or make your rule flexible enough to trigger on Item Alarme received update, knowing that the rule will trigger multiple times for every change.


Thanks for the response.
In your experience, do i have an alternative besides listing all the zones
in the item section? Can i use regex in that case? My items are Zone* where

  • == 1 to 25?

Thanks again

Afraid not. You have to either use a group or list them all. And since the
group won’t do what you need …


I Will do it as items individually into 1 rule