All,
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 /var/lib/openhab2/etc/keys.properties:
openhab=AAAB3....xyz,_g_:admingroup
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)
su openhab
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:
executeCommandLine("/etc/openhab2/scripts/restartNetatmo.sh", 7000)
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 in Karaf console:
list -s
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)
EDIT (OH3 related):
Just a quick modification if you are using OH3:
you need to use
openhab=
instead of
karaf=
in the
/var/lib/openhab/etc/keys.properties