Software restart of Openhab

People seems to think that resetting the power to a RPI is not a desirable way to restart Openhab. So how do people restart Openhab? Getting my girlfriend to log in with putty and type systemtcl restart openhab2 is a no go for her. So how does people restart openhab if it crashes? I have been thinking about connecting a button to GPIO pin and use a python script to read the state of the gpio and then reset openhab. Is there an android app that can restart the Openhab, I think I read somewhere that @ThomDietrich used a mqtt service to restart PC. So maybe something down that road is feasible. I am open for any ideas!

There’s a few ways you could do this here’s a couple:

  1. As you mentioned, have a button on the Pi connected to the GPIO which is monitored. Probably the most tactile way of doing this. Requirements would be a secondary program to monitor the GPIO.

  2. Have an accessible script on a computer in the home that logs in for you. Just double click the .bat or .sh file. Requirements for this would be an active LAN connection. (see

It would be nicer to have it on one of the wall mounted tablets(android) in the flat instead of having to dig up the laptop to restart it. (Which also quite often is not there…)

Well. If the problem is because of any issue with HW, OS or network, most of those problems can kill any approach to graceful restarts as you can’t login or access the GUI, so all you’re left with essentially is to power-cycle.
But any non-graceful shutdown has the potential to make the situation worse for you (power loss while writing can corrupt SD cards etc).

If your server is still fine, you can also use exec binding and put the trigger into GUI or onto some HW switch input.

But why do you want to do this at all? Once you’ve properly debugged your OH install, there should not be any need to restart OH - and if there is one, that need will likely still be around or reappear soon after a boot/OH restart, so restarting won’t help most of the time either or just give temporary relief.

Sometimes that’s all one needs. In Kim’s case, he was not home and his OH server unexpectedly and inexplicably went offline. When you are not physically there and your only help is someone who really isn’t in a position to log in to the RPi to properly restart it. So having a button or element on a sitemap or the like to restart the RPi can sometimes be just enough to keep everything going until he gets home and can properly address the problem.

@skatun, personally I’d do both. Wire a physical button to the RPi that starts the reboot. There are tons of tutorials out there. I’d also run a little script that receives MQTT messages or the like to also kick off a reboot. This gives you two ways to kick off a reboot with minimal extra effort.

Of course, note that depending on what has gone wrong with the machine these scripts might not be able to run themselves. And a reboot does not always guarantee that everything will come back up working. That is why I recommended having a recent clone of the SD card handy. Even my five-year-old knows how to swap out SD cards (heaven help me).

So, IMHO, the button or script could be part of phase 1 in getting the system back up and running for the short term until you can get back. But because it isn’t guaranteed to work you will need a phase 2 to fall back to.

1 Like