Openhab on RaspberryPi safe power shut down?

Does one need to run some sort of command to safely shut down OpenHab that is installed on RaspberryPi or can the power cord just be unplugged if needed?

Don’t unplug the power cord if you value your SD card integrity! Use the following command to first shut the Pi down:

sudo shutdown -h now
4 Likes

That is really a Linux question.

You can connect a momentary switch to pins on the RPi that when pressed will shut it down safely. I did this for a project.

I posted the project as there is an openhab element to it. The post does not list which pins to use but you can see the nice LED illuminated switch I used:

Thanks for your practical suggestion to run “sudo shutdown -h now”

Could you explain where to type it in?

Sorry, you are dealing with a thread tagged “Beginners” here so a step by step owuld be much appreciated.

Could you share the code for operating such push switch as a shut down? Although I am not sure there is a need for a hardware shortcut as I rarely see the need to power off the OepnHab running Pi board and happy to do it in an online interface.

Ah, OK, you’ve got some learning ahead of you!

Is your Pi connected to a screen? Ultimately, you need to type that command into a terminal window on the Pi (nothing to do with openHAB), but how you get into that terminal depends on how you access the Pi.

Just to reiterate: shutting down the Pi has nothing to do with openHAB, at all! There are thousands of tutorials online about Pi basics which I’d recommend you search for!

You bet! Just fired up my first Pi board last night and then decided to move it. I can hook it up to a monitor temporarily but I don’t think I have a keyboard anywhere in the house. (Oh, and I see it complains about under-voltage from a 1.2A PSU) I was planning to run it as a headless system afterall. So nothing in OpenHab to shut down the OpenHab?

No. openHAB is software which is running on your Pi hardware. You must shut down the hardware if you need to remove the power cable.

1 Like

There is no code. Its a feature of the pi. Short the correct two pins and the pi shuts down and then you can safely remove the power. I will have to look up which two pins or you can google it

Checked my notes on it: It seems you can select which pin to use and this is defined it the Pi’s config.txt. I chose GPIO5 pin29 and ground it with a momentary switch on the case to start a safe shutdown.As shown in the example below:

image

I forgot mention. One neat feature of using an illuminated hardware button is that you can power the button LED so that the light goes out when the pi is shutdown and is safe to remove the power supply

2 Likes