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