I currently struggle with my Netatmo binding. After a few hours it stops getting updates from the Netatmo station.
So I implemented a solution to restart the binding from within a rule.
I hope this helps someone for solving similar issues with specific bindings:
First generate the key (as an alternative to sshpass) to enable you to start karaf without beeing asked for your password
sudo -u openhab ssh-keygen -t rsa -f openhab.id_rsa (no passphrase)
Next, put the result (key only of course) from openhab.id_rsa.pub into /srv/openhab2-userdata/etc/keys.properties:
And connect to karaf by.
sudo -u openhab ssh -p 8101 -i /home/openhab/karaf_keys/openhab.id_rsa openhab@localhost
This should work to connect to karaf without a password.
You just need to confirm to connect to the host for the first time:
“Warning: Permanently added ‘[localhost]:8101’ (RSA) to the list of known hosts.”
Obviously there is a difference if I switch “really” to openhab user and run from there:
sudo su (to switch to root)
This time run of course:
ssh -p 8101 -i /home/openhab/karaf_keys/openhab.id_rsa openhab@localhost
and again confirm:
Warning: Permanently added ‘[localhost]:8101’ (RSA) to the list of known hosts.
After that you should be able to run from any binding restart:
Whereas the script contains:
#!/bin/bash /usr/bin/ssh -p 8101 -i /home/openhab/karaf_keys/openhab.id_rsa openhab@localhost 'bundle:restart org.openhab.binding.netatmo'
If you need the names for the different bundles you would like to restart, please check either
In case you would like to restart the binding from within the rule (and without a script), just use this syntax:
executeCommandLine("sudo /usr/bin/ssh -p 8101 -i /home/openhab/karaf_keys/openhab.id_rsa openhab@localhost bundle:restart org.openhab.binding.netatmo", 6000)