JSR233 Jython, on Group change [resolved]

Hello, i’m trying use a GenericEventTrigger to trigger my rule when a member of group have a change.

I readed the documentation, but cant configure this. I need a help.

I’m using OH 3 and Jython to make the rule.

This work for change of one item:

sRule = RuleVerificaAlarme()
                "itemName": "Loft_Light"


I tried use this:

sRule2 = RuleVerificaAlarme()

                "eventSource": "GF_Alarme_Sensores",
                "eventTypes": "GroupItemStateChangedEvent"

But not work.

My group is GF_Alarme_Sensores.

In DSL i use

rule "Rule 1.01"
    Member of GF_Alarme_Sensores changed

You’ll have to give us more information that “but not work”. What is the error it gives? Is there information in the logs?

Also this is the hard way to write rules in Jython, have you had a look at the Helper Libraries? They already have working triggers for both of the examples you have given. For OH3 you will need to follow the Manual Installation instructions (skip the part about modifying EXTRA_JAVA_OPTS and install the Python automation add-on instead of the NGRE one) and you will need to use the code in PR #376 which has been updated for OH3.

1 Like

Note that this is not the same as triggering from change to the Group state itself. A member may change and have no effect on parent Group state at all.
You want the equivalent of the Member of trigger in your old DSL rule, not any Group event.

1 Like

Thanks for the reply.

I will try install the Helper Libraries.