Hi,
I have been searching severals forums for a -probably small - problem: I would like to generate a rule with which I can manually reboot my Raspberry.
I have tried the following rule (which does not work):
rule “Manueller_reboot”
when
Item reboot changed from OFF to ON
then
say(“starte System neu”)
executeCommandLine(“sudo /sbin/shutdown -r now”)
// notifyMyAndroid(“9a9547982d29dc6af942bc2a2b03ddefafb70c499e702319”, “reboot”, “text regel.”)
end
Some remarks:
- I have added the “say” command as a kind of acustic feedback - in order to be sure that the rule has been triggered
- after the “say” I could like to have a command that reboots the Raspberry (so the whole systeme - not just a restart of OH)
I have tried several different commands (like “sudo reboot”, “sudo /sbin/shutdown -r now”, “executeCommandLine(“reboot”)” …" … none worked.
I seems to be a banal problems (and I didn’t expect that it runs out to be so difficult to implement this rule) … but it would be a nice feature to restart my RPi manually from my cellular phone without the need to start my computer.
Every help or advice is highly appreciated
best regards
schroedinger
First: Please set the complete path to sudo (/usr/bin/sudo)
Second: Did you ever sudo from openhab user? (sudo will remind the user to respect privacy…)
Third: Did you setup the user openhab not to need any password for sudo?)
Hi,
thank you for the fast answer.
I am quite a newbie concerning Linux (although I have learned a lot about that since I use OH) - so please excuse that I need to ask a few more questions …
First: Please set the complete path to sudo (/usr/bin/sudo)
How do I do that?
Second: Did you ever sudo from openhab user? (sudo will remind the user to respect privacy…)
I am not sure. So far, whenever I wanted to start OH manually I have entered via SSH “sudo reboot” (or: “sudo shutdown”)
Third: Did you setup the user openhab not to need any password for sudo?)
No, I haven’t, Sofar I always need to enter the password whenever I use “sudo”
Best regards
schroedinger
Hi,
Udo’s remarks helped me to solve the problem.
I did the following:
sudo visudo -f /etc/sudoers.d/010_pi-nopasswd
Adding following lines
openhab ALL=(ALL) NOPASSWD: ALL
After I had done that the following rule worked:
rule “Manueller_reboot”
when
Item reboot changed from OFF to ON
then
say(“starte System neu”)
executeCommandLine(’“sudo” “reboot”’, 100)
// notifyMyAndroid(“9a9547982d29dc6af942bc2a2b03ddefafb70c499e702319”, “reboot”, “text regel.”)
end
@Udo_Hartmann: thank you for your support
cu
schroedinger
4 Likes