alcorn
(Tom Alcorn)
May 6, 2020, 4:16am
1
Is it possible to define your own classes for use in rules and scripts? The IDE doesn’t seem to like the syntax:
class Foo {
}
Relatedly, how do I figure out which features of Xtend are and aren’t allowed in rules?
5iver
(Scott Rushworth)
May 6, 2020, 4:18am
2
Yes, but you will need to use the new rule engine with scripted automation and Jython, Groovy, jRuby, Kotlin, etc.
alcorn
(Tom Alcorn)
May 6, 2020, 4:35am
3
How do I enable/use scripted automation with the new rule engine? Is there a guide to using Kotlin with the new rule engine?
For anyone else wondering about class support in the Rules DSL, I found these comments by @rlkoshak explaining that the Rules DSL does not allow defining classes and has restrictions on what can be imported.
I like the idea though worry about long term support to the plugin. Most of the ESH devs and maintainers do not seem to have much interest in supporting/improving support for languages outside of the up and coming Experimental Rules Engine. Even the current Rules DSL is mostly coasting (though the recent additions of triggeringItem and Member of Rule triggers are noted massive improvements).
That has been one of the big problems with the JSR223 add-on which lets us write Rules in Jython, JavaSc…
So does Xtend, but the Rules DSL (remember Rules DSL != Xtend) only gives us access to core Java libraries, Joda, and ESH/OH core libraries. I wouldn’t want that same limitation with Kotiln Rules. That was my main point.
With JSR223 languages managing libraries like that isn’t so hard, just download them and put the files in the right spot. For something like Kotlin though, especially if we are talking about only importing Java libraries in jar files we now need to mess with classpaths and the…
5iver
(Scott Rushworth)
May 6, 2020, 4:43am
4
Just install the new rule engine… scripted automation is included.
Not yet, but I plan to get one together. Best to stick to Jython and use the helper libraries…
I just submitted a PR that adds a core feature for a JythonScriptEngineFactory and it would be great to have some testers! Basically, this will allow for the installation of Jython including the core and community helper libraries through Paper UI, once the PR is merged. If you’d like to test it, you’ll need to…
Have OH 2.5.x (S1778) or newer
Shutdown OH
Backup OH
Download the addon and copy to $OPENHAB_HOME/addons/ (see here for more details). The jar contains the core and community helper l…