Closed dilyanpalauzov closed 2 years ago
Hello @dilyanpalauzov,
the difference is that JSR223 JavaScript is based on an older JavaScript engine called NashornJS
that only supports ECMAScript 5.1. Furthermore, you have to use the raw Java APIs with JSR223 which is quite complicated.
JS Scripting instead supports the latest ECMAScript 6 and provides this library (openHAB-js) that „translates“ between JavaScript and the raw Java APIs. This makes the usage of JS Scripting much easier and allows you to use pure JS without worrying about the Java part. Therefore it is recommended to use JS Scripting.
This recommendation is nowhere written and the differences between the two systems are not outlined.
I am now aware of this thanks to to your issue.
I'll move this issue to the docs repository and provide a PR that updates the docs to fix this.
https://www.openhab.org/docs/configuration/jsr223.html says, that one possible way for scripting is to use JavaScript, by putting
.js
files underopehnab/automation/jsr223/
.https://www.openhab.org/addons/automation/jsscripting/ presents another way to JavaScript-scripting, by installing
.js
files underopehab/automation/js/
.I cannot find anywhere information, what are the differences between both approaches and when to use which one. Both approaches obviously use JavaScript.
Please extend the documentation to state, how JavaScript scripting differs from JSR223-JavaScript scripting.