JavaDoc for Javascript

Hey there.

I understand that Javascript is the preferred rule language for textual rules starting with OH3. Is there any documentation about the openHAB-specific Javascript methods and objects? I mean something like JavaDoc. I have countless questions about the objects (event, events, actions, etc.) and the methods. :slight_smile:

I already know the examples thread from @rlkoshak (OH 3 Examples: Writing and using JavaScript Libraries in MainUI created Rules) and the blog post from @yoshi ([OH3] How to Create Rules in OpenHAB 3 using JavaScript / ECMAScript). Unfortunately, both describe only a small part of what I would like to know.

Kind regards
Sem

I don’t think there is a “preferred” language over all. Each individual will have their own preferences. All the supported languages have their own advantages and disadvantages and are more or less suited to various things.

Everything that is openHAB specific is actually Java. In Rules DSL when you call MyItem.sendCommand(ON), MyItem is a Java Object, sendCommand is a method on a Java Object, and ON is a Java Enum.

This is true for all the languages. All interactions with openHAB itself take place through Java Objects, even though the language being used is JavaScript, Python, or whatever. And therefore, except for some minor differences in overall syntax, the actual interactions with openHAB are mostly the same in the various languages. Rules DSL does a bit more magic behind the scenes and jRuby abandons this consistency in favor of language purity so that last statement isn’t universally true but it’s a good guideline. So if you see a Python example of doing something with openHAB, it should not be too hard to do the same in JavaScript since both are working with the same Java classes.

All of the Java stuff that is part of the Java language is available and available at https://docs.oracle.com/en/java/javase/11/docs/api/index.html. All of the Java classes that make up openHAB itself are available at Overview (openHAB Core 4.2.0-SNAPSHOT API).

Finally, whether or not you plan on using them, the Helper Libraries are a key place to look for how to do stuff with openHAB classes in Python or JavaScript.