listen for shutdown

  • Hi,

    I wood like to ad a script which enables the posibility of a power button usage.

    I found manauls to do that, but non of them worked at libreelec.

    this are the script which should run:

    As well the intallation script is not working.

    Hope there is a way to add this simple funktionality to shutdown an restart the Pi with a shorting pin 5 and 6 (GPIO3 and GND)

    Thx in advance


    install:

    listen-for-shutdown.sh

    listen-for-shutdown.py

  • shutdown.sh can't see anything strange..

    Remove all the sudo commands from install.sh script..

    You need to install rpi tools addon from libreelec repo..

    I m not really good with python but try this it should work.. for shutdown.py

  • That doesnt work.

    I install the rpi tools, and it can be found at:

    /storage/.kodi/addons/virtual.rpi-tools/lib

    i get the following:

    Code
    LibreELEC:~/hyperion/bin #  ./listen-for-shutdown.sh start
    Starting listen-for-shutdown.py
    LibreELEC:~/hyperion/bin # Traceback (most recent call last):
      File "/storage/hyperion/bin/listen-for-shutdown.py", line 4, in <module>
        import RPi.GPIO as GPIO
    ImportError: No module named RPi.GPIO
  • satfan The code looks OK, I'm using the same import. Maybe you are using wrong apostrophe signs at the sys.path.append line.

    script seems to hang on line 4

    Code
    import RPi.GPIO as GPIO

    That shouldn t be on line 4 if you copied the script I showed you...looks like you r still loading your first script listen-for-shutdown.py without the rest

  • I made the following things ...

    The script should work ... but I don´t get any reaction if I shorten Pin5 Pin6.

    I get a strange answer if I start the script manually ..

    /storage/hyperion/bin/listen-for-shutdown.py:10: RuntimeWarning:

    A physical pull up resistor is fitted on this channel!

    GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP)

    ###################

    autostart.sh :

    Code
    /usr/bin/sh /storage/hyperion/bin/listen-for-shutdown.sh start

    listen-for-shutdown.sh :

    listen-for-shutdown.py :

  • It works ...! I `m so stupid... I shouldn't be counting pins at 2am at night ... Since I connected a fan to pin 4 and pin 6, I didn't see that I didn't connect pin1 and pin2. So I tried to make the connection between pins 7-8 instead of 5-6

    Thx for your help !

    By the way ... is it possible to reconnect the fan to a other Pin which is shut down if I´m in the shutdown mode ? Maybe I have to add something in that script.

  • It works ...! I `m so stupid... I shouldn't be counting pins at 2am at night ... Since I connected a fan to pin 4 and pin 6, I didn't see that I didn't connect pin1 and pin2. So I tried to make the connection between pins 7-8 instead of 5-6

    Thx for your help !

    By the way ... is it possible to reconnect the fan to a other Pin which is shut down if I´m in the shutdown mode ? Maybe I have to add something in that script.

    Glad you r sorted...fan doesn't have to be full trottle...it should work fine on 3.3 just a little slower...or do what Da Flex recommended...you can also use same circuit for PWM Fan setup..works fine on RPI..