I have not found anything, the official script does not work since libreelec does not allow apt get install.
GitHub - RetroFlag/retroflag-picase: RetroFlag Pi-Case Safe Shutdown
Does anyone know how to do it in libreelec?
I have not found anything, the official script does not work since libreelec does not allow apt get install.
GitHub - RetroFlag/retroflag-picase: RetroFlag Pi-Case Safe Shutdown
Does anyone know how to do it in libreelec?
Insufficient information : What are you asking? What are you trying to do.Please provide more information. Hardware, version of LE etc
Purpose of this script is to make shutdown & reboot (+LED) buttons on RetroFlag NesPi Plus case to work on Raspberry Pi LibreELEC.
Here's script for RetroFlag NesPi+ case which I modified for my needs from recalbox_SafeShutdown.py. No need to download or install anything from linked github page. Save the code I shared for example as "nespi_shutdown.py" and copy it to your LibreELEC sd card.
On LibreELEC install following add-ons:
From "Kodi Callbacks" settings set "nespi_shutdown.py" to run on KODI start. There's also other ways to run scripts on Kodi start but I have used this add-on because of my limited skills
Also "Safe ShutDown" switch inside NesPi+ case needs to be turned ON.
I don't have knowledge to say if my modified script is 100% correct but power button, reset button & LED seem to work correct. Although LED doesn't blink correctly for a short time after reboot button is pushed (maybe because LibreELEC reboots much faster than Recalbox). If there's any improvements to be done please share
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib')
import RPi.GPIO as GPIO
import os
import time
from multiprocessing import Process
#initialize pins
powerPin = 3 #pin 5
ledPin = 14 #TXD
resetPin = 2 #pin 13
powerenPin = 4 #pin 5
#initialize GPIO settings
def init():
GPIO.setmode(GPIO.BCM)
GPIO.setup(powerPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(resetPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(ledPin, GPIO.OUT)
GPIO.setup(powerenPin, GPIO.OUT)
GPIO.output(powerenPin, GPIO.HIGH)
GPIO.setwarnings(False)
#waits for user to hold button up to 1 second before issuing poweroff command
def poweroff():
while True:
GPIO.wait_for_edge(powerPin, GPIO.FALLING)
os.system("shutdown -h now")
#blinks the LED to signal button being pushed
def ledBlink():
while True:
GPIO.output(ledPin, GPIO.HIGH)
GPIO.wait_for_edge(powerPin, GPIO.FALLING)
start = time.time()
while GPIO.input(powerPin) == GPIO.LOW:
GPIO.output(ledPin, GPIO.LOW)
time.sleep(0.2)
GPIO.output(ledPin, GPIO.HIGH)
time.sleep(0.2)
#resets the pi
def reset():
while True:
GPIO.wait_for_edge(resetPin, GPIO.FALLING)
os.system("shutdown -r now")
if __name__ == "__main__":
#initialize GPIO settings
init()
#create a multiprocessing.Process instance for each function to enable parallelism
powerProcess = Process(target = poweroff)
powerProcess.start()
ledProcess = Process(target = ledBlink)
ledProcess.start()
resetProcess = Process(target = reset)
resetProcess.start()
powerProcess.join()
ledProcess.join()
resetProcess.join()
GPIO.cleanup()
Display More
Looks really clear to me : Nespicase+ comes with secure power+reset button and need script
Your solution is working for me but not the led
kinda painful to configure callbacks, here's a working tip using SSH and not kodi (so the raspberry should respond too when kodi crash)
Just connect via SSH and launch this Lakka script : GitHub - marcelonovaes/lakka_nespi_power: Lakka 2.1 + NESPi CASE + Shutdown buttons
The only thing different is the root password according to this page, default is libreelec : Accessing LibreELEC [LibreELEC.wiki]
Also, you have to activate SSH on libreelec settings, that's not said, you just switch the button without reboot
Tip was found on this post : Shutdown script for the snespi case
it's very unfortunate that this small script isn't offered directly in libreelec, you know a simple addon called "Nespicase+ soft shutdown buttons" ....
will this work with the the perseids NESPI CASE as well?
If someone could point me in the right direction of creating a add-on I'm more than happy to spend some time on this.
Previously I used other scripts but I had problems with both in the end, one being after a period of time it wouldn't reset or Shutdown and I would have to pull the plug and the other script I found the red led would always flash instead of staying on.
So in the end I sat down did my research and created my own script.
I wrote a script to work with gpio zero, installing raspberry pi tools from the LibreELEC repo will enable gpio zero.
After that I copied of my scripts and created a autostart.sh file in the .config folder and everything works perfect.
My script also sends the correct commands to shut down libreelec correctly "kodi-send --action"shutdown"
This shuts down the exact same way it would if you select power off from the power menu of Kodi.
I don't feel "shutdown -h now was doing the job properly as it shutdown almost instantly making me feel metadata etc wasn't being saved.
So if I could create a add-on that had the raspberry pi tools as a dependency and then installed my scripts that would be perfect.
The problem is I wouldn't know where to start with this lol
Nice job on writing your own script, care to share it? Or did you manage to add it as an add-on?
I tried the lakka ninjapower script but it's not working.
Thanks in advance
I'll share it as soon as I get to my computer as its backed up on there.
Are you familiar with ssh?
Because after scripts are copied over you'll type 4 commands to enter after the scripts have been copied over.
I never managed to get going with a addon as I wouldn't know where to start.
It must be easy though as it only requires 1 dependancy which is raspberry pi tools from the libreelec repo as this has gpi-zero which the script uses.
I've been running it for ages now and still works perfect
Great to here it's still working! Yes I'm familiar with SSH so that shouldn't be a problem.
I just installed Libreelec on my pi, before I was using OpenElec on a small HTPC. Rightnow I can't seem to get WakeOnLan to work, so my hopes are set on your script
Personally I wouldn't bother with wake on lan using a pi, the pi uses next to no electricity, I just make sure I buy hard drives then spin down.
Wake on lan would only be beneficial if you was using a computer for your main media center and then pi's for other rooms.
For example, my latest setup is a computer in the front room connected to my main TV, this runs libreelec and hosts all the files via samba to my pi's in my bedroom the kids bedroom and the conservatory which is where my snes pi is.
Wake on lan is also my next project for my main computer
That's basically my setup as well. I share my files on my PC using samba and play them on my TV on libreelec on a pi. My PC is in a room on the second floor and is on most of the time. I can send a "magic packet" to my PC to wake it through LAN however.
I use Yatse as the control app on my android, been using it for a few years and really glad with it. But rightnow I can't wake my Pi through the app...
But if I can use the on/off and reset button on the nespi case that's a nice solution too
(I don't use the retropi that often, but if I do I just need to swap SD cards and I can start gaming).
That's basically my setup as well. I share my files on my PC using samba and play them on my TV on libreelec on a pi. My PC is in a room on the second floor and is on most of the time. I can send a "magic packet" to my PC to wake it through LAN however.
I use Yatse as the control app on my android, been using it for a few years and really glad with it. But rightnow I can't wake my Pi through the app...
But if I can use the on/off and reset button on the nespi case that's a nice solution too
(I don't use the retropi that often, but if I do I just need to swap SD cards and I can start gaming).
Hi,
Here is the shutdown script for you
Ive put instructions in there for you to follow.
If you follow them it will work perfect.
I just installed the scripts and they're working perfectly, thank you so much.
I just installed the scripts and they're working perfectly, thank you so much.
No worries. Enjoy
Hi,
I've found this thread via Google. I'm using a raspberry pi 4 with the newest Libreelec Version and a NesPi Case 4.
Is the script also for this one and if yes, how can I install it? I've already problems with this line: Copy folder "shutdown_scripts" to /storage
How can I do this?
Thanks for all help.
I've already problems with this line: Copy folder "shutdown_scripts" to /storage
How can I do this?
Attach the microSD to your PC and copy that folder into the /STORAGE partition. Then do the rest of the instructions on RPi by SSH.
I don't have that case, but I think your chances are pretty good.