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

  • NisteR

    Changed the title of the thread from “Script for Nespi case+ (SafeShutdown, SafeReset, and LED)” to “Script for Raspberry Nespi case+??? (SafeShutdown, SafeReset, and LED)”.
  • 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:

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

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

  • 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

  • @robmcc83

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

  • razmafaz :

    We got a showcase about the power button, I'm using an additional status LED, reset is easy, too.

    You just have to know where the button / LED contacts of your case are, and connect them right.

    If you post those connections to the GPIO, then I can post the script.

    Flexin' vinyl, jammin' break beats. 8)

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