I totally agree and also don’t like giving super powers to low-level users. However, when you implement the system for non-technical users, you cannot tell them “log in to the server via SSH and restart it”. You need to provide a user-friendly option, otherwise they will simply go and pull the plug.
OpenHAB should provide such a friendly (and secure) option by default instead of making us look for workarounds.
I personally believe that systems (even highly available ones) should be rebooted periodically for performance reasons, but that’s not part of this discussion and you’re right about pointing out that (doing it this way) is potentially harmful.
login to the GNU/Linux platform where openHAB is active.
if not already installed, install sudo
grant access for the openhab user by editing the sudoers file. Use visudo for this purpose.
setup a line like this: openhab ALL (ALL) NOPASSWD /sbin/reboot
at the correct context (search for root in the file)
install exec and create the correct thing to use the script
edit the whitelist to allow openHAB exec to execute sudo /sbin/reboot
link an item to the thing and setup a Switch Widget to use the exec channel ‘run’
No need for root. Stay save, but give the user control.
But please be aware that maybe the UI is not reachable anymore, so there might be a better way to restart openHAB by building a script which can be executed remotely (just by a double click on the Desktop Icon maybe with a simple “Are you sure?” )
Definitely no.
Reboots are not needed and do more harm than good. A simple accessible reboot switch just makes the lazy part in everybody surface and quickly get in control instead of taking the painful route to really debug your problem. This is even more true for beginners. That’s not the OH way of doing things.
And that is why most of us (openHABian developers, experienced supporters) with discernment will not support users in getting there.
I also disagree with this. If performance degrades over time, that’s just sign of another uncaught bug (mem leak or some such) or bad software design and your time is better invested into looking after that.
@z9th3, did you ever solve this? I’m doing a fresh install on an RPi4 and have run into the same issues with the openhab user requesting a password. @Udo_Hartmann’s suggestion unfortunately isn’t working for me.
I’m suspecting that this guide might need to be rewritten to use the Exec binding, but I’m not sure if that will work either.
@rpwong sorry for the late reply, I have not worked on this issue anymore so I don’t have any good news to report. My need for automatic reboots has decreased because it seems my current system is more stable.
Thanks @sihui! I’ll try it out this weekend. I rarely need to reboot these days, but the shutdown command is nice to have on occasion. Mostly, I’d like to update the guide so that it works for others.
Hello, your example works great for a long time on OH2.5 … But on OH3 I’m having an error:
2021-01-27 13: 36: 19.614 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘system-1’ failed: An error occurred during the script execution: array element type mismatch in system
I would know how to help me solve it, I miss “restart” in the UI.
Thanks!
executeCommandLine is the only thing that doesn’t hold up if someone transfers their existing config files to OH3. Rather than updating this tutorial, I’ll probably write an OH3-specific version and reference this one.
EDIT: I changed my mind and just updated the rules with OH3-specific versions of executeCommandLine.
Hello,
i have started the migration from my OH2.5 to OH3 and have also implemented the reboot/shutdown switch and it’s working fine.Now i also want to replace the sitemap by a page but have not found a way how to setup a page especilly for
I found a solution when searching for somthing else.
In the item defintion you need to add Metadata | State Description and here in the field Options put
In a PAGE you can add a LIST CARD and in the LIST CARD you should use LABEL LIST ITEM for each log swich item.
When you display the page, klick on the Item Label displayed in the page and you get the list from the Option field for your selection