A few comments.
Proxy items are the “way to go” IF you need to intercept commands and conditionally execute them.
see Automation/Orchestration et seq
I’ve run my code system thru multiple re-architecture steps over the past few months for scalability, performance, and reliability reasons. One of the biggest headaches is figuring out which change in an item triggered a group change. I had huge amounts of “book-keeping code” in Xtend to keep this straight—worked correctly after multiple iterations BUT performance (even with suppressed logging) did not scale very well.
I decided to explore the JSR223 Jython variant. I was loathe to re-do all my rules into jython, even though I know Python pretty well. The critical overhead question was “which item in a group” triggered a change to the group. The jython-openhab interface solves this pretty well using the @item_group_triggered decorator.
The hardest part is getting the jython setup correct. I had no success with a global jython installation, but a standalone jar installation works.
The key meta-construct in an appropriately-pathed jython .py script is this:
@item_group_triggered("gSwitch_u_01")
def example(event):
events.postUpdate("nlastSwitchname",event.itemName)
You have to define “nlastSwitchname” as a virtual item in an items file, viz…
x
String nlastSwitchname
AFAIK you cannot define a structure like a SwitchItem in jython and pass that structure as-a-whole to classic rules/Xtend.
So my workaround is any Xtend/classic rules which needs the result of the event-trigger has to pass the itemName through an intermediate String item like “nlastSwitchname” and use that to parse-out other info in classic rules/Xtend from the group info. An important part of any classic/Xtend rule structure in this case is to pull the value of the global item (e.g. nlastSwitchname) into a local rule-instance execution variable (say “plastSwitchname” at rule-firing time and use that value to de-referencieng other needed elements like state, etc. This helps control multiple group-rule-instance-firing SNAFUs.