openhab / openhab-core

Core framework of openHAB
https://www.openhab.org/
Eclipse Public License 2.0
925 stars 426 forks source link

OH3 callScript - scripts are not executed #1990

Closed holgerfriedrich closed 3 years ago

holgerfriedrich commented 3 years ago

Executing scripts via callScript seems to be broken:

[ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'szenen-1' failed: Script 'sonnenschutz' cannot be found. in szenen

Script is located in the scripts folder, it worked before with OH25 before upgrade.

There seem to be other users affected, see See also https://community.openhab.org/t/scripts-in-oh3/110843/5

Any hint appreciated. Can I tune the log level to obtain more information (I tried, but I have not been able to guess the right logger name).

smaktacular commented 3 years ago

same here:

grafik

edit: was working in 2.5.2 docker image, does not work in 3.0.0

voruti commented 3 years ago

same here: https://community.openhab.org/t/openhab-3-script-file-configuration/111284

olialb commented 3 years ago

I am using openhabian. Just upgraded using the standard upgrade menu and have exactly the same issue. All my .script files are not found. Let us know if we can support to idetify the root cause,

stefan-oh commented 3 years ago

I only had one script, calculating holiday dates. I took the chance to eliminate that with calculations using Ephemeris, so I'm no longer affected, but obviously others depend much more on this functionality. And as it is a documented feature ist should work again.

My thoughts: My rules are all file based. In OH3 these files are read at startup and are being executed from an internal data store. I have files with multiple rules. In the GUI I see every rule being singled out. When the script is called the log output can be read as if the interpreter is looking for the script within the realm of the rule itself instead of an external location. Maybe the lookup mechanism in the scripts folder got lost when file based rules are being read into memory at startup?

kaikreuzer commented 3 years ago

This looks like an unfortunate regression caused by https://github.com/openhab/openhab-core/pull/1433. I have created https://github.com/openhab/openhab-core/pull/2020 as a fix.

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. Could you please try if that works for you?

holgerfriedrich commented 3 years ago

Thank you @kaikreuzer for fixing this.

Though, the workaround does not do the trick. Same error message in the log, also after a restart.

stefan-oh commented 3 years ago

Same result in my setup, I confirm holgerfriedrich's test result

bern77 commented 3 years ago

It does work for me, however you need to use callScript('myfile.script').

holgerfriedrich commented 3 years ago

Thanks, @bern77! This works fine for now.

kaikreuzer commented 3 years ago

Glad to hear that we have found a workaround!

Birchcroft commented 3 years ago

All the above is interestig, but being new to Openhabian 3 I am trying to do as much within the UI as I can as I see this to be the future. So rather than using .script files I've tried developing scripts within the UI and then using them. Unfortunately, callScript still does not work with scripts developed in this manner and the workaround above does not work because, as far a I can determine, there is no .script file to rename.

So does anyone have any suggestions for a workaround when scripts are developed in the UI?

openhab-bot commented 3 years ago

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/help-needed-with-rule-in-openhab3/121780/1

radzik2024 commented 9 months ago

Unfortunatelly - OH version 4.1.1 - the problem is come back :-( Regresion problem :-(

My script is in "scripts" folder but I can not call him :-( callScript("scriptName.script") - "cannot be found"

Windows 11 platform, OH 4.1.1

UPDATE: scary! Something changed my script in the directory. The file is called the same, but inside instead of a script there is some HTML, like a page with a message from YouTube - update your browser! What's the matter, why the content of the script was changed to some html!

rkoshak commented 9 months ago

The file is called the same, but inside instead of a script there is some HTML, like a page with a message from YouTube - update your browser! What's the matter, why the content of the script was changed to some html!

OH does not have any way to write to those files. So I would guess that you have something else going on. If you were running on an SD card I'd say weird stuff like this can happen from not shutting down nicely or the SD card wearing out. Since this is Windows presumably running off of an SDD or HDD it's a mystery. But if correcting that file to make it a proper script works I don't think this is a regression of this issue.