Trigger reboot of host OS

I know this sounds a bit strange. But is there a possibility to trigger a reboot of the host OS through openHAB?
Sometimes my pi reacts a bit slow and needs a reboot to fix it.
Since I don’t have a screen attached to my pi I would need to connect through putty or remote desktop to reboot it.
So I was wondering if I could add a button to my openHAB config that triggers a reboot.

Or if you have other suggestions to make it easier. :slight_smile:

It should work with the exec binding!
Take a look here.

or use the OS itself:

sudo crontab -e
0 4 * * 2 sudo shutdown -r now 

(Reboot every Tuesday at 4AM)

My suggestion (as a root cause analyst) is to find the cause. It is unusual for a proper installed and configured rPi to behave sluggish. :sunglasses:

2 Likes

Note that when using the exec binding to reboot the server you might need to give the user OpenHAB is running as the permission to reboot. Normally this requires a user with root permission and OpenHAB should be running as a user without privileged access rights.

Another idea: if it is just OpenHAB that becomes very slow you could have a look at the memory/heap consumption of the process. Maybe something eats up all the available heap and the JVM is choking while doing aggressive garbage collection all the time to free heap.

Or the configured heap exceeds the RPIs physical memory causing the OS to start swapping.

I accidently found the issue I think. My Pi wouldn’t boot anymore so I flashed it with openhabian yesterday.
When I got everything to work again, it was still acting slow sometimes.
But I think it’s because of the way my openHAB configuration is set up.

To give some background, I have a few input/output modules that can receive/send UDP commands for status changes and status requests.
Every 30 seconds (maybe I should review this) I get the status of all my outputs to show it in my openHAB.
I think that my delays when I try to turn something on/off is because of these rules that run in the background.
The module can only process 1 command at a time so it get’s queued I guess.