Switch hyperion on/off

  • Hi everyone,

    I could finally set lighberry up with libreelec/hyperion and Rpi3 but I have some concerns.

    - My hdmi source is always on (satellite tv) so even when I switch tv off the leds remain up. I could handle cutting off the power with smart plug or whatever, but I found out that if I cut power (I am powering Rpi through Leds via Gpio), hyperion does not start automatically when I power on again. Leds remain off.

    - Is there any way hyperion can start automatically after power off?

    - And, is there any easy way to shut leds down? I saw some threads where they write some scripts to turn leds on/off via remote tv or keyboard but I’m too noob. Some help would be much appreciated.

    Than you so much!

  • I still don't understand your setup, especially "I am powering Rpi through Leds via Gpio".

    Generally, you can have an on/off button on the RPi, you can autostart scripts when LibreELEC starts, and you can trigger scripts by GPIO events. Does any of those options solve the problem?

  • Thank you for answering.

    I'm powering both leds and Rpi with a single 5V 4A Power Adapter. I plug 5V Power adapter to 5V GPIO pin. See diagram below.

    diagram.png

    These options would solve the problem but I'm so newbie for the scripts, how can I script in LibreElec? Is it possible in win10 or do I need linux?

    If I can only set Hyperion autostarts when LibreElec starts would be great. Do I need to edit autostart.sh file?

    Thanks!

    Edited once, last by xevipc1 (December 28, 2018 at 3:09 PM).

  • I could handle cutting off the power with smart plug or whatever, but I found out that if I cut power (I am powering Rpi through Leds via Gpio), hyperion does not start automatically when I power on again. Leds remain off.

    I wouldn't do that. It's better not to cut the power for the RasPi. Use a RasPi power button instead. That should keep Hyperion in a defined state, and should power it on with the RasPi when the power button is pressed. You can use PuTTY on Win10 to add the necessary scripts to RasPi.

    For the installation of the button, you may have some space between the RasPi Ethernet port and the upper part of the RasPi case. If you have enough space there, you can just lay the button on the Ethernet port without mounting it permanently. Then you just have to drill a hole over the Ethernet port, insert the button and close the case to fix it.

    Here is the button that I use: 10x tact push buttons. With some cables and basic soldering skills everybody can do it.

  • Thank you so much but I think is quite laborious at this moment. Even so good point. I see I can turn leds off in Hyperion mobile app sending color black. So that, I would keep Rpi always on. But anyway I’d like to script hyperion automatically starts after power off in case there is an outage or something. Can you help me with that? Do I need to edit autostart.sh? Or sending via putty? Which command/script?

    Thank you so much!

  • English is not my mother language. "Outage" means an electrical accident, and no power for a short time, right?

    After that outage, the RasPi and LibreELEC will start. You can trigger the fitting GPIO signals by using autostart. In the Python script (see link above), you can learn how to set GPIO levels. I don't know the right pins / signals to start Hyperion. That's not part of LibreELEC. Can you do a research for this?

  • Thanks, I looked around but I don’t see any specific tip. Many concepts and I’m too noob. Python script? GPIO? Do GPIO pins have anything to do when it comes to set hyperion autostart? I thought it might be related to send some command via putty or just edit autostart.sh file. Sorry I’m quite lost here.

    Thanks for your responds

  • The autostart.sh calls a Python script. The Python script will set electrical levels to specific GPIO pins. A device, connected to GPIO (Hyperion), will listen to those level changes at GPIO. That's usually the way to start or reset connected RasPi hardware.

    When I have some time, I will have a look at the Hyperion project.

    I can help you to adapt the scripts, but I need the necessary infos for Hyperion GPIO events.

  • I need to start “hyperion creator” in libreelec and set up it again, luckily is quite fast. Don’t know any other way to “restart”. As you can see it is not practical.

  • Yes I’m using the addon. I burnt lightberry libreelec iso which brings hyperion creator addon pre-installed.

    Also tried hypercon on windows but had some issues, I read it is not very well debugged. Addon is much more simple and i get pretty good results.

  • Excellent, that's it! :)

    If you only have a Win10 PC, you can edit the files by SSH login (use PuTTY).

    If you have a Linux PC, simply remove the MicroSD card, and plug it into the PC.

    Create the directory "/storage/hyperion/scripts" for the scripts.

    On SSH:

    Code
    mkdir /storage/hyperion
    mkdir /storage/hyperion/scripts

    Copy "ledon.py" and "ledoff.py" into that folder.


    Insert this code into autostart.sh, if you want to start Hyperion by default:

    Bash
    #!/bin/sh
    
    (
        python /storage/hyperion/scripts/ledon.py
    ) &

    Copy "remote.xml" into the "/storage/.kodi/userdata/keymaps" folder, if you want to switch it on and off by red and green remote buttons.

    Tell us, if it works!

  • Thanks I’ll try but how do I copy that scripts in that folder? Or how I create ledon.py file to copy the script? Noob question

    And seems ledon.py script only makes the rainbow swirl, after that it will run hyperion normally?

    EDIT: Hmm seems does not work..

    1. mkdir /storage/hyperion
    2. mkdir /storage/hyperion/scripts

    Good, I created the file

    cd /storage/hyperion/scripts

    nano ledon.py

    Copied the code, and saved,

    In autostart.sh I copied your code and reboot the Pi.. Leds are not on.. :_((

    Do I need to install some Python interface or something to get Rpi enable to run it?

    Hm I tried to run the script from putty, this is what I get.. seems no connection..?..

    LibreELEC:~ # cd /storage/hyperion/scripts

    LibreELEC:~/hyperion/scripts # python ledon.py

    * Trying 127.0.0.1...

    * TCP_NODELAY set

    * connect to 127.0.0.1 port 80 failed: Connection refused

    * Failed to connect to 127.0.0.1 port 80: Connection refused

    * Closing connection 0

    curl: (7) Failed to connect to 127.0.0.1 port 80: Connection refused

    hyperion-remote:

    version : V1.03.4 (brindosch-c750c41/dc6a602-1522918225

    build time: Apr 5 2018 01:57:05

    Connected to localhost:19444

    Start effect Rainbow Swirl


    Tried editing script and changing port 22 instead of 80..

    LibreELEC:~/hyperion/scripts # python ledon.py

    * Trying 127.0.0.1...

    * TCP_NODELAY set

    * Connected to 127.0.0.1 (127.0.0.1) port 22 (#0)

    * Server auth using Basic with user 'kodi'

    > POST /jsonrpc HTTP/1.1

    > Host: 127.0.0.1:22

    > Authorization: Basic a29kaTprb2Rp

    > User-Agent: curl/7.58.0

    > Accept: application/json

    > Content-type: application/json

    > Content-Length: 148

    >

    * upload completely sent off: 148 out of 148 bytes

    SSH-2.0-OpenSSH_7.3

    Protocol mismatch.

    * Recv failure: Connection reset by peer

    * Closing connection 0

    curl: (56) Recv failure: Connection reset by peer

    hyperion-remote:

    version : V1.03.4 (brindosch-c750c41/dc6a602-1522918225

    build time: Apr 5 2018 01:57:05

    Connected to localhost:19444

    Start effect Rainbow Swirl

    LibreELEC:~/hyperion/scripts #


    Thanks!

    Edited 5 times, last by xevipc1 (December 30, 2018 at 7:50 PM).