Well, the error is it can’t find the script so either:
you didn’t move your scripts over
they are in the wrong folder
the “right” folder may have moved
there is a bug and openHAB is looking in the wrong location.
Someone experiencing this problem needs to file an issue.
As a work around, depending on what your scripts do, you can achieve the same thing in Jython/JavaScript/Groovy by creating a library. Or you can implement them in a rule and use OH 3 Examples: Writing and using JavaScript Libraries in MainUI created Rules. Or you can write rules that call other rules. This is particularly easy to do in UI rules as there is an “execute another rule” Action you can choose. But you can do it in code as well.
In JavaScript it would look something like:
// Run another rule
var FrameworkUtil = Java.type("org.osgi.framework.FrameworkUtil");
var _bundle = FrameworkUtil.getBundle(scriptExtension.class);
var bundle_context = _bundle.getBundleContext()
var classname = "org.openhab.core.automation.RuleManager"
var RuleManager_Ref = bundle_context.getServiceReference(classname);
var RuleManager = bundle_context.getService(RuleManager_Ref);
RuleManager.runNow("tocall");
var map = new java.util.HashMap();
map.put("test_data", "Passed data to called function!")
RuleManager.runNow("tocall", true, map); // second argument is whether to consider the conditions, third is a Map<String, Object>
Notice how you can pass data to the other rule. Much of the stuff in the above code is done for you in the Helper Libraries.
Unfortunately you can’t do this from Rules DSL as far as I know.
I’m willing to file the issue if someone could give me a hint where to do that (well. Github is clear, but…). I have no idea atm in which part of OH this could or should be fixed. Thanks!
Hi Rich, thanks for the link. The “how-to” was basically clear to me, I might not have been too clear as what I’m unsure about. Sorry for that.
Is it openhab-core, openhab.distro, … that I need to open the issue? I’m not really sure which part of the different parts of OH I need to open the issue with.
Thanks
I ended up copying the scripts’ contents into new rules, triggered by dedicated items which I simply send an ON command where I would otherwise call the script. It works quite well as a workaround.
According to my tests, there should be a simple workaround:
Simply rename your script files from myfile.script to myfile.script.script and they should be found.
2020-12-28 17:58:00.492 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘Time-1’ failed: Script ‘holiday’ cannot be found. in Time
2020-12-28 17:58:20.488 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘Time-1’ failed: Script ‘holiday’ cannot be found. in Time
2020-12-28 17:58:40.499 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘Time-1’ failed: Script ‘holiday’ cannot be found. in Time
2020-12-28 17:59:00.489 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘Time-1’ failed: Script ‘holiday’ cannot be found. in Time
2020-12-28 17:59:20.498 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘Time-1’ failed: Script ‘holiday’ cannot be found. in Time
2020-12-28 17:59:40.490 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘Time-1’ failed: Script ‘holiday’ cannot be found. in Time
Adding “.script” to the name did not work, neither did the removal of the entire extension work. In both cases the same error message is logged:
2020-12-28 18:10:34.172 [INFO ] [rg.openhab.core.model.script.default] - ##### Prüfe, ob heute arbeitsfrei ist
2020-12-28 18:10:34.176 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'zentral-1' failed: Script 'arbeitsfrei' cannot be found. in zentral
“zentral.rules” is the calling script and “arbeitsfrei.script” or “arbeitsfrei.script.script” or “arbeitsfrei” is the script called from within “zentral.rules”
Tinkering with it, I agree, the workaround does work. I was not clear to me that the additional “.script” needs to be applied not only to the script file itself but also to the call in the rule.
To make it clear to everyone:
The filename needs to be changed from myfile.script
to myfile.script.script
AND
in the calling rule callScript('myfile')
needs to be changed to callScript('myfile.script')