These are not language specific. I’ve gone through the code for all of the existing triggers (each trigger provides different event attributes) and documented them…
It’s not the only way nor even the best way. A lot has changed since I started writing these and the UI is being completely rewritten which is largely why I stopped writing this series. It will be picked back up again soon and it will make it into the docs. There is already a really good start to a beginner;s tutorial you can find here.
But if you are using anything but Rules DSL in OH 2.X you are using the NGRE. In OH 3, it’ll be just called the Rule Engine and it will also run Rules DSL.
For the specific task of using scripts within NGRE in papaerUI, I’d say it is the best tutorial .
I am not using he helper lib as it seems to be changing and I don’t want to rely on it yet.
Although I have a good experience with OH, but it was not easy to find out what APIs are available and what are not (I am still trying to find out how to load the logger )
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.