Thank you for your answer. I’m nearly there… This is what I’ve done so far:
- Installed the coap-client on my raspberry, following this guide.
- Created a new DTLS Identity for accessing the gateway, following this guide.
Now I’m able to restart the Gateway from the command line:
**16:22:53]** **openhabian@openHABianPi** : **~** $ coap-client -m post -u 'openhab_commandline' -k 'supersafekey' 'coaps://192.164.158.70:5684/15011/9030'
v:1 t:CON c:POST i:219a {} [ ]
decrypt_verify(): found 24 bytes cleartext
decrypt_verify(): found 4 bytes cleartext
But when i use it in a rule
rule "Restart Tradfi gateway"
when
Time cron "0 15 17 1/1 * ? *"
then
var String result = executeCommandLine("coap-client -m post -u 'openhab_commandline' -k 'supersafekey' 'coaps://192.164.158.70:5684/15011/9030'")
logInfo("Test", result)
end
nothing happens, the log says:
2018-11-13 17:15:02.381 [INFO ] [lipse.smarthome.io.net.exec.ExecUtil] - executed commandLine 'coap-client -m post -u 'openhab_commandline' -k 'supersafekey' 'coaps://192.164.158.70:5684/15011/9030''
2018-11-13 17:15:02.387 [INFO ] [.eclipse.smarthome.model.script.Test] - null
I tried allowing openhab to execute it as root by adding following to /etc/sudoers
openhab ALL=(root) NOPASSWD: /usr/local/bin/coap-client
But that doesn’t help. Any ideas?
Edit: fixed it:
rule "Restart Tradfi gateway"
when
Time cron "0 39 17 1/1 * ? *"
then
var String result = executeCommandLine("coap-client -m post -u 'openhab_commandline' -k 'supersafekey' 'coaps://192.164.158.70:5684/15011/9030'", 5000)
logInfo("Test", result)
end
results in a restart of the gateway and this output:
2018-11-13 17:39:02.169 [INFO ] [.eclipse.smarthome.model.script.Test] - v:1 t:CON c:POST i:fbcf {} [ ]
decrypt_verify(): found 24 bytes cleartext
decrypt_verify(): found 4 bytes cleartext