rule "Reboot Display EG"
when
Item resetdisplay changed to ON
then {
val String results1 = executeCommandLine("ssh root@10.10.10.13 shutdown -r 2>/dev/null", 5000)
logInfo("Reboot display", results1)
resetdisplay.sendCommand(OFF)
}
end
results in
==> /var/log/openhab/openhab.log <==
2020-10-19 11:07:13.892 [ERROR] [internal.handler.ScriptActionHandler] - Script execution failed: An error occurred during the script execution: array element type mismatch in haus
Your issue likely is not specific to the OH3 code (more likely to your setup), and for sure not of general nature as I requested everybody a couple of posts up.
the file is called haus.rules
removed the {} but still the same, i guess the issue is with the executeCommandLine script in OH3
the rule was working perfect in 2.5.9
thanks
Thomas
Hmm, a redirect. What will be a bit different from “native” OH2 rule to OH3 rule running under a DSL interpreter of the new rule engine … is the context.
Pipes and so on are often problematic with executeCommandLine, because it does not run in a shell context.
I believe the exec code does some uhh kludges to try and work with simulating pipes by itself, maybe this is where the “array” comes in.
This is not the same, but feels similar. I have no knowledge to look deeper or experiment, but would at least try without the redirect.
Thanks rossko57
this solves the error in the log, but the remote pi is not booting
rule "Reboot Display EG"
when
Item resetdisplay changed to ON
then {
val String results1 = executeCommandLine(Duration.ofSeconds(15),"/usr/bin/sh","/usr/bin/ssh root@10.10.10.13 shutdown -r")
logInfo("Reboot display", results1)
resetdisplay.sendCommand(OFF)
}
end
this solves only the error but the remote pi is not booting
yes, only solution to get it work is creation of reboot sh file
[13:24:15] root@t2:/etc/openhab/scripts# more reboot_display.sh
ssh root@10.10.10.13 shutdown -r 2>/dev/null
chmod + chown +adding it to whitelist
and the below rule
rule "Reboot Display EG"
when
Item resetdisplay changed to ON
then {
var result=executeCommandLine(Duration.ofSeconds(15),"/usr/bin/sh","/etc/openhab/scripts/reboot_display.sh")
logInfo("Reboot display", result)
resetdisplay.sendCommand(OFF)
}
end
The parameters of executeCommandLine have changed.
The timeout is now the first parameter and has changed from integer in milliseconds to Duration type.
Then are following the command string(s).
Before it was one string, now it has to be splitted at every space delimiter or at the @@ delimiter.
Your old command:
val String results1 = executeCommandLine("ssh root@10.10.10.13 shutdown -r 2>/dev/null", 5000)
New command:
val String results1 = executeCommandLine(Duration.ofSeconds(5), “ssh”, “root@10.10.10.13”, “shutdown”, “-r”, “2>/dev/null”)