Hi,
I am using OpenHAB 2.5 Milestone 3 in a docker container on a x86_64 NAS. I have sometimes issues that the docker containers starts too quick before the Zwave stick gets initialized. Hence I want to restart the zwave binding when it detects that the zwave things are “offline” at system start.
Based on previous topics I created the follwing rule:
Remind that in the docker container the path to karaf console is /openhab/runtime/bin/client
rule "Do what I want"
when
Item restart_zwave changed to 2
then
// val String results = executeCommandLine("/openhab/conf/restartzw.sh", 5000)
val String results = executeCommandLine("/openhab/runtime/bin/client 'bundle:restart org.openhab.binding.zwave' ", 8000)
logInfo("FILE", "***** RESTARTING: >" + results + "< *****")
end
When running the command from the docker command line it works:
# /openhab/runtime/bin/client 'bundle:restart org.openhab.binding.zwave'
When running the rule I receive the following log entry and the binding is not restarted:
17:28:15.963 [DEBUG] [clipse.smarthome.io.net.exec.ExecUtil] - executed commandLine '/openhab/runtime/bin/client 'bundle:restart org.openhab.binding.zwave' '
17:28:17.818 [DEBUG] [clipse.smarthome.io.net.exec.ExecUtil] - exit code '1', result 'Closed'
17:28:17.819 [INFO ] [g.eclipse.smarthome.model.script.FILE] - ***** RECYCLING: >Closed< *****
Alternatively I have created a small script /openhab/conf/restartzw.sh
that runs the above command string from command line. When running the script from the command line it works but running it from the rule creates the error:
#!/bin/sh
/openhab/runtime/bin/client 'bundle:restart org.openhab.binding.zwave'
This creates the following error log entry when calling this script from the rule (see above):
17:29:37.446 [DEBUG] [clipse.smarthome.io.net.exec.ExecUtil] - executed commandLine '/openhab/conf/scripts/restartzw.sh'
17:29:39.302 [DEBUG] [clipse.smarthome.io.net.exec.ExecUtil] - exit code '1', result 'Closed'
17:29:39.303 [INFO ] [g.eclipse.smarthome.model.script.FILE] - ***** RECYCLING: >Closed< *****
I think the problem is the exit code: 1
respectively the command result Closed
which are most likely the reason/explanation for the problem. But I do not understand what this means …
I would kindly appreciate any hint to get this solved.
There can be no big problem as the command works fine when I run it from command line.
Thank you
Justus