JSR223/Jython: Groupitem update not triggering?

While converting my DSL rules I came to a stop in a simple rule that triggers on a group update.

The group/item :

Group:Number:SUM	gTotalHeatingWatt   "Total oppvarmings effekt"	<heating>  (All) 	[ "iss:type:DevElectricity","iss:unit:Watt" ]

Here’s a DSL example that works:

rule "mytest1"
when
    Item gTotalHeatingWatt received update
then
    logInfo('MYDEBUG', 'testing 123')
end

The jython version which doesn’t trigger at all:

@rule("mytest")
@when("Item gTotalHeatingWatt received update")
def tester(event):
    la.logInfo("MYDEBUG2", "mytest123")

Am I doing something wrong or is this a bug? :thinking:

Also, are there any known issues with group items that have been added or has its name changed while OH is running? I can’t seem to loop members of a groupitem that I just defined and added members to…:thinking:
I get no error message, it just doesn’t loop the groupitem.

Edit: I have no idea how, but after trying different approaches and finally returning to the same way of looping the members (ir.getItem(“blabla”)) it just started working. So in conclusion, probably a PEBKAC :see_no_evil: But the first post is still an issue…

1 Like

When you use the @rule decorator, it creates a logger for the rule so you would typically use:

tester.log.info("mytest123")

The name of the logger will be the rule name (i.e. “mytest”).

You are not showing your global variables so it’s hard to see where la is coming from, but assuming it’s a properly defined logger, the call would be

la.info("mytest123")

and you would have defined the “MYDEBUG2” when you created the logger.

yeah the logger is not the problem, it’s working elsewhere…I just didn’t add the import statement in the post (its in the actual test script)

from core.actions import LogAction as la

:slightly_smiling_face:

When an Item in a group with an aggregated group function receives an update, the group does not receive an update event. So, this rule would not trigger unless you were sending the group an update. You could use a ‘changed’ or ‘Member of’ triggers.

Ok, but shouldn’t that be the case for DSL rules as well? :thinking: The update (group item) triggers fine in DSL (from a groupmember), just not in jsr223/jython.

Unfortunately, no, since it is a different rule engine. I haven’t run into issues using either ‘changed’ or ‘Member of’, so I moved this to the bottom of my list. Are you having trouble making one of those work for you?

1 Like

Oh ok, no it’s not a big problem for me, I can work around it. Thanks for replying/confirming :slight_smile: