I’m on OH 5.0.2 and I am realizing that my few rules and scripts in JS are in fact written in Nashorn way and executed the Nashorn way while they are identified as “new JS” when I create them, but then, the internal engine behaves as old one…
This means you do not have Nashorn JS installed at all. So all your rules are running on GrallVM JS. There are differences for sure but for the most part, a Nashorn JS rule will work in GrallVM JS. It’s going to be much longer and more complicated than necessary, but it will work. You’ll eventually probably want to rewrite them to take advantage of the JS Scripting helper library for long term maintainability.
Nashorn provides “ECMAScript 5.1” while GrallVM JS provides “ECMAScript 11” which is what your screenshot shows.
The Blockly code “compiles” to GrallVM JS. So your Blockly codes are running in JS too.
It appears you already have. But in general you just need to uninstall the Nashorn add-on. If you have any rules still using Nashorn JS OH will complain. But, like I said, you appear to have already done this.
ok, thank you Rich, all clear.
I got confused with Gemini who was insisting that I had “obviously” the wrong engine running on my setup because some of its proposed code was not running ok… I need to be more careful.
It was building a full story on why some hiden engine was running and what I should do to disable it… I got worried with what it was suggesting I should do (stopping things via karaf etc…).
Sorry for that.
None of the chatbots are able to build OH rules unless you have custom trained one specifically to do OH rules (if anyone has done this with a LLM it would be awesome if they posted it somewhere). The code they produce pretty much always looks reasonable but when you look more closely at it, you realize it’s actually nonsense. It’s almost always a mix of Nashorn and GraalVM JS, includes a bunch on unnecessary steps, and often uses APIs to communicate with the rest of OH that do not even exist.