Heads up: JSR223 is broken in recent snapshots (starting 1310)

I only just got my rules working again. I’ve noticed high load than normal, but figured it was due to all the restarts. I’ll keep an eye on it.

I’ve been happy with VS Code, with pylint now and then. LSP would be great.

Right, that’s some good start - I wasn’t yet aware of that sub-page, thanks for pointing me to it!

Can you tell me what to do with the old item_group_triggered functions in my rules?
This is removed in your file.

Thanks a lot.

I had combined the item_triggered and item_group_triggered into one decorator and submitted a PR. I had put the TriggerBuilder change directly into the branch with that change. There is an explanation in the PR. Let me know if you have questions. I planned on updating the documentation once I got a response from the maintainer(s) on whether the PR would be accepted, but that is still pending. If I get some time, I will separate these changes into two PRs, but it would be much easier if the item_triggered PR was just merged first.


Sorry for the late response and thanks for your offer to help.
I am not a skilled programmer and i can not get it to run with your edited triggers.py

Here is one of my rather simple rules:

from openhab.triggers import item_triggered 
from openhab.log import logging 

def Networkdevice_changed_status(event): 
    item_last_change = event.itemName.replace("Sw_","Dt_") 
    item_last_change = item_last_change.replace("Lan","") 
    item_last_change = item_last_change.replace("Wifi","") 
    item_last_change = item_last_change + "LastSeen" 
    events.postUpdate(item_last_change, str(DateTimeType())) 

    import traceback 
    logging.getLogger("Rule Exception").error(traceback.format_exc()) 

When loaded it leads to this error:

2018-08-24 06:18:26.111 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/network.py': TypeError: 'NoneType' object is not callable in <script> at line number 13 

Line #13 is the decorator: @item_group_triggered(“gPCs”)
“gPCs” is a group, but it also fails to load if i put in an item just as a test.

Hope you tell me what i am doing wrong.

Thanks a lot :slight_smile:

Did this work before snapshot 1310, and are you using a recent snapshot? And are you missing the indent in Networkdevice_changed_stats, or is that just from pasting it into the post?

Thanks for your answer.

Yes it worked before 1310 except that i was using the “item_group_triggered” function.
The missing indentation comes from pasting (it lost all formatting and i missed that while correcting).
I am now on snapshot 1339.

Edit: Ahh sorry i made a mistake. My triggers.py was not working because i didn’t delete the triggers$py.class

But now my error is, whichs looks more like it was caused from that trigger change…

[ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/network.py': TypeError: org.python.proxies.openhab.triggers$ItemEventTrigger$8(): expected 0 args; got 3 in <script>; at line number 13

Playing around in my test environment, I get the same error if I use the old triggers.py. Could you please confirm you are using this one… https://github.com/openhab-5iver/openhab2-jython/blob/c1e986fc6cbe9b82f909af5423ee44f82c4d089a/lib/openhab/triggers.py? After updating a module, you also need to restart OH.

Thanks problem solved after several restarts with deleting the triggers$py.class :slight_smile:

1 Like

For Javascript, it seams alternatively https://www.graalvm.org/ can be used then after Java 11:

1 Like