Indicating that a variable of script will be passed

I think openHAB 5.2 introduced some more “visual” coding support, to e.g. highlight problems in the code. Nice feature!

But I’ve got a few scripts, which I call in other scripts or in rules, and to which I pass a few arguments. And if I use one of these parameters, the code editor complains that they’re not declared yet. Understandable, but a bit annoying:

Is there a way to “tell” the editor that these parameters will be passed through as arguments? Or should I open an issue for this on GitHub?

Try using ctx.javaobject instead of just javaobject. Apparently that’s how we were supposed to do it all along.

And there are some changes coming down the line that may make using just the variable name by itself problematic.

I think that will sort it. If not, there may be nothing we can do short of turning that off in the editor entirely.

As always, @rlkoshak has the answer, and faster than his shadow. :slight_smile:

I’ve seen that there’s work being done with other JavaScript problems, although it’s been a while since I’ve read anything about it. Is the solution expected for 5.2.1?

Nice, I did not know that. Apparently I’ve got to update a few dozen rules now.

If you are referring to the problem where a multi threaded exception gets thrown when you pass just about anything more complicated as l than a JS float to another rule, yes. The fix is in place and is flagged to be back ported.

The fix involved adding a javaify and jsify method so that only Java Objects get passed to another rule, never JS Objects. The jsify can covert the Java break to JS on the other side.