The are no major changes in the helper libraries. I had future proofed them a long while ago for the upcoming package name changes in OH 3.0. There are a few more things due to some deprecations, but OH 3.0 should be a smooth transition for the helper libraries, especially when using the Jython and helper library add-ons. I have some new features coming out though.
Jython is very easy to install and use. Itās what Iām currently using, though Iām starting to also move into more heavy JavaScript stuff as Iām writing libraries of reusable rules and want to reach as wide an audience as possible. See [beta testers wanted!] Jython addon w/ helper libraries (requires OH 2.5.x).
Yup, Iāve seen this one. Would love to try it later as I am learning python.
Currently, Javascript is more than enough as I have good experience with nodejs.
Itās not really a default languageā¦ JavaScript (Nashorn) just happens to be currently included in the JDK. Heads up though, since it has been removed in JDK15, which is due for release in September. When OH is configured for other scripting languages, they will also be available in the āexecute a given scriptā options of Actions and Conditions in the UI rule editor.
Currently I try to get the function rules.runNow("<rule UID>"); to work. but for me it seams that this is not working You mentioned this was also not working for you. Is this still the case on your side? Then there is definetiv a bug.
Hi @rlkoshak, great stuff, however thereās a part where you suggest this:
You will also notice there are a lot of variables that only exist when the Rule is triggered by certain types of triggers. You can test in a script to see if a variable exists using:
// Both with and without library
if(command == undefined) // we know the Rule wasn't triggered by a command if true
It throws me this when running from designer with Ctrl+R:
ReferenceError: "command" is not defined in <eval>
A lot has gone on and changed in the nearly two years since Iāve written the above. Iām not sure those variables are populated the same way in OH 3 any more, or even if they were in the later versions of OH 2.x.
Maybe you need to describe what you mean by āDesignerā. If you mean the old old old IDE for openHAB called openHAB Designer, that hasnāt worked nor has it been maintained in years. It never was updated to fully support Rules DSL in OH 2.0, let alone the JSR223 languages.
Also, it never let you run the rules independently.
If you are talking about MainUI, event only exists if you trigger the rule from an Item event. If you are running it by hand I donāt know if there is a good way to tell. Maybe you can test to see if this.event === undefined.
Thanks, Iām on OH3 latest milestone, and weāre talking about the main UI / rules / edit script.
Finally the this.event did the trick, thanks again for the help.