I have just found time to do a fresh install from OH 3 coming from OH2.
Now I am investigating the new features.
Currently, I am using in OH2 the rule DSL, now I have seen there exists ECMAScript and Rule DSL.
In the docs I have found that I can write the script with 3 different languages:
javascript
Jython
Groovy
But I don’t find any documentation about this languages for OH.
So what’s the best way now to create scripts in which language?
And can I still create scripts via VSC in javascript/jython or groovy or only inside the UI?
So every 3 languages are OH future-proof?
There is no “OpenHab” preferred language?
I have already found this doc, thanks.
But with this doc I can’t create a complete script at all.
This is a small hello world sample.
And as stated on the site “Example rules for a first impression”.
I search for a documentation on methods and so on.
If I use javascript how do I need to construct the script?
How do I get the item state or how can I set it.
I hope you understand what exactly I mean.
A developer documentation from the OH framework.
The same as other frameworks have.
For example:
var sRule = new SimpleRule() {
execute: function( module, input) {
print("This is a 'hello world!' from a Javascript rule.");
}
};
Great, but what objects are “module” or “input” ?
Or what does exactly “SimpleRule” means? Where is the doc of “SimpleRule” class?
What do you exactly mean?
I don’t want a consulting for free or anything else.
I have only asked if there is an API documentation.
With an API documentation, I can read the docs and can start to write my scripts.
That’s it.
But of course it is possible to search the forum and ask questions in the forum and so on.
This is always needed for advanced things, but for the real basics?
There is no preferred OH language. They all have advantages and disadvantages. There are also more than just those four languages available and two different (and incompatible) versions of JavaScript. It’s all hopelessly fragmented. The documentation is not uniform. There is really no such thing as future proof.
All interaction between OH and the rules for the JSR223 languages (the three you listed) takes place through Java Classes and Objects. So they pretty much all work the same with the main difference being the syntax of the individual languages. Given that…
No matter which of the three languages you are using, you need to create an instance of the Java Class SimpleRule and override the execute method which contains the code that will be executed when the rule is run.
The documentation is there once you realize that it’s all mostly working with Java.
It becomes much easier when using the UI to define rules because most of the effort spent in a text based js or py rule file is spent just defining the rule. In the UI all of that is handled for you and all you have to mess with is that execute method.