My rule fails when I execute a script, but when I try it manually it works fine.
owm.rules
When
Item OWM_Local_Current_Icon changed
then
if(OWM_Local_Current_Icon.state != NULL) {
val cmd = "/etc/openhab/scripts/base642png.sh currentweather \"" + OWM_Local_Current_Icon.state.toFullString.replace("data:image/png;base64,","") + "\""
logInfo("owm.rules",cmd)
executeCommandLine(cmd,2000)
}
end
I will get this error:
2021-01-15 21:06:39.437 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'openweathermap-1' failed: An error occurred during the script execution: array element type mismatch in openweathermap
When I run the logged cmd in cli with sudo -u openhab /etc/openhab/scripts/base642png.sh currentweather "iVBORw0KGgoAAAANS.......... Hgf"
It’s working as expected.
Can someone help my? I can’t find the Problem.
Increasing the log Level to DEBUG for internal.handler.ScriptActionHandler doesn’t Show more Details.
Do you use OH2 or OH3 ?
The rule seems to follow the syntax of OH2 for executeCommandLine.
The error message seems to show that you use OH3 as well as the tag that is related to your post.
For OH3 the syntax of executeCommandLine has changed.
See Actions | openHAB
e.g.
var ScriptResponse = executeCommandLine(Duration.ofSeconds(60), "path/to/my/script.sh", itemState1, itemState2);
In case it sometimes works but not always could the problem be related to base64 argument ?
You can add a line in your script that writes something to /tmp/ to check if the script itself is being executed.