I tried to use exec bindings to shutdown by NAS Synology but the command is not executed. If I display the openhab logs (tail -f /var/log/openhab/openhab.log) I can see this message : .2016-04-01 00:35:50.842 [INFO ] [.o.b.exec.internal.ExecBinding] - executed commandLine ‘ssh root@192.168.1.180 sudo shutdown -h now’
Below I will write what I already done:
I copied the exec binding file in addon directory
manually, from my RP2 (where is Openhab 1.8 installed) the command is executing without enter any password (I’m using SSH keys) .
Also I tried “local” to restart the RP2 and It sames that is working
I used:
Switch synology “Synology” (gDevices) {nh=“192.168.1.190”, exec=">[OFF: sudo shutdown -h now]"}
MY advice when debugging the exec binding is to don’t use the exec binding and instead use the executeCommandLine in a rule and log what the command returns. It is the only way to discover what errors are being generated.
In my experience getting ssh to work from openHAB is challenging and the more common problems I’ve seen:
the user OH is running under has not accepted the ssh key for the remote host yet
the user OH is running under is not configured with the right keys to ssh to the remote host without a password
the permissions on the files in .ssh are too open and the remote host refused the connection
In all of these cases you can only see these errors by running it from a rule and logging the resuts.
Thank you for all your answers. Hopefully I found the problem… I didn’t know that exec is also a persistence not only a binding. Maybe that’s why | didn’t see that I have only exec persistence file copied. After I add the exec binding everything works fine