Calling an external file-based script from an openHAB 3 UI-based rule using callScript()

If you are use Rules DSL as the Script Action language, it should work as it always has per Actions | openHAB.

That’s what a Script is. It’s a bit of code that you call from a rule’s “script”. Honestly, Scripts have always been not terribly useful because you can’t pass any values to it and you can’t get any values back from it. Most people put the code they want to run in the Script Action itself instead of putting the code in a .script.

Note the “execute a given script” is a Script Action. It’s part of the rule. It’s not the same thing as the code snippets you’d put in .script files in the script folder.

If you have a need for a library type capability, you should use ECMAScript which can import a personal library of functions you can call and be able to pass values to them and get values back. See OH 3 Examples: Writing and using JavaScript Libraries in MainUI created Rules

Anyway, yes, you are doing it about the only way that it can be done. If it feels convoluted I think that stems more from a lack of understanding on how rules work and what .script files can do and are for. The only time you’d really use a .script file is if you had a block of code that does the exact same thing every time it’s called, and you need to call that from more than one Rule. About the only use case I’ve seen that makes sense is to set up Scenes where you have two or more rules that can enable a scene (i.e. set of states for a number of lights and other stuff).