Script for Raspberry Nespi case+??? (SafeShutdown, SafeReset, and LED)

  • 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:

    • LibreELEC repository: rpi-tools (I'm not sure about exact addon name, might have been also RPi.GPIO or something)
    • KODI add-on repository: Kodi Callbacks

    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 :)

    Edited 3 times, last by jleppa (October 4, 2018 at 12:31 PM).

  • 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" ....

  • 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

  • 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.

  • 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.