0.2 tested on build 1.8.0.148
0.1 tested on build 1.6.2.123
I hate I don’t have a physical power button to turn on and off my rasplex without dealing with physical addons or having to unplug and plug again to restart my rasplex. Things that I thought that could be easily be solved with a push button.
I also added a power button to power a LED so I can know If rasplex is up and running as the default green and red led indicates other things like SD access and if it has power.
For all this Im adding the python GPIO support to rasplex which isn´t available on normal setups
To install
Extract the content inside “/.plexht/addons/packages/” so you get a gpio folder
if you dont know how to uncompress in linux its
tar xf gpio.0.1.tar.gz
Edit or create autostart.sh (default location at “/.config”) with
#!/bin/sh
(PYTHONPATH="${PYTHONPATH}:/storage/.plexht/addons/packages/gpio/lib";
export PYTHONPATH;
sleep 10s;
python ~/.plexht/addons/packages/gpio/bin/shutdown.py;) &
and reboot
Features
- Press the power button to turn Rasplex on
- Press the power button for 3 seconds to securely turn off Rasplex
- Lights a LED connected to PIN 10 to indicate if the unit is running
#Wiring
For this I’m connecting ping 5 to ground ping 6 with a pushbutton
Pin 10 goes to the LED circuit back to ground pin 9
So your setup should look something like this.
I wont explain LEDs and resistors here but you cant connect a LED directly to your Rpi, you need to use a resistor and anything over 15 Ohms should do the trick with LEDs of 20 mA. Just add a bigger resistor if you want it dimmer.
If you notice my script it only takes care of shutting down the system, as Pin 5 its the default Pin for powering on any Raspberry from standby. So its nice to use the same pin for shutting it off.
I also like to use pin 6 and 9 as my ground pins as they are next to the others.
Hope you find it useful for your setups, its specially useful if you are building your own case
Changes on the new 0.2 version
I made some upgrades to the script for better integration.
- Now it has some fault tolerance when dealing with interrupted connections on the 3 second press time that should fix most user problems
- A pop up message is displayed when the button is pressed and the max time is reached so you can have some GUI information of what its happening
- If a LED is also present, it will blink a couple of times to signal the shutdown command



