There is some overlap in terminology here that needs to be cleared up first.
In OH 2 and earlier, there was a concept of a Script which is a block of Rules DSL code that can be called using callScript(name_of_file.script)
Actions | openHAB.
In OH 3, MainUI presents a subsection labeled “Scripts”. These are not the same thing. These are actually fully fledged Rules, though they are Rules that only have a single Script Action and are tagged with “Script”. Because these are fully fledged rules, they are called by executing another rule. Greg posted an example for how to do that in JavaScript. As far as I know this is not possible in Rules DSL, but it is possible through the UI outside of a Script Action.
callScript
is in the same class as createTimer
and transform
(ScriptExecution) so it should be accessible by default in Rules DSL. In the other languages ScriptExecution will have to be imported, just like is required for createTimer
.
But note the difference. callScript
can still only call a Rules DSL script placed into a file in the $OH_CONF/scripts
folder. It cannot execute another Rule and since the things listed under Scripts in MainUI are rules, they cannot be called using callScript
.
So, a tl;dr is yes, callScript
still works and it works exactly like it did in OH 2.5. That means no UI support is provided to create the Scripts in the first place.
Alternatives to this, and perhaps better alternatives might be to call a rule as Greg demonstrates. It’s even possible to pass stuff to the called rule which is not possible with Scripts. Or, if you are using one of the other languages, put your reusable code into a library and import it. See an example of that in OH 3 Examples: Writing and using JavaScript Libraries in MainUI created Rules.