1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Hyperion.ng Toggle with lirc and a remote control

Discussion in 'Hyperion General' started by MikeDC, 3 March 2019.

  1. MikeDC

    MikeDC New Member

    Messages:
    7
    Hardware:
    RPi1/Zero, RPi2, RPi3, +Arduino, +PhilipsHue
    Hi

    As much as anything this is a record for me when I forget how I have done this but maybe it will be useful to others too :)

    Im using OSMC with hyperion.ng on a pi 2b

    Ive setup a sonoff basic to shut down my 5v power supply with Alexa
    but I couldnt find any easy way to shutdown the pi quickly, lazily and most important cleanly first and kept corrupting the SD card.

    I then read about the Lirc integration in Kodi and its already installed in OSMC..

    So I grabbed a TSOP38238 Infrared reciever and connected it up to the pi and enabled lirc in kodi.
    In My OSMC - Settings Pi -Hardware Support i set gpio_out_pin to 17(default), gpio_in_pin to 4 and gpio_in_pull to down.
    I havent used the default gpio_in_pin for lirc as im using that pin for my hyperion LEDS im using gpio4 pin 7 instead :)

    Anyway i used 3 spare buttons on my remote and recorded them for lirc using irrecord and created a remote control file called "my_universal.conf" to use with lirc the buttons on the remote are the green yellow and blue buttons (red is already used for something else)
    I used the correct lirc names for these 3 buttons
    KEY_GREEN
    KEY_YELLOW
    KEY_BLUE

    The command I used was "irrecord -d /dev/lirc0 /etc/lirc/my_universal.conf"

    Then went back to kodi and to My OSMC and selected my_universal as the remote.

    to test that the lirc was receiving the signals fine in a console i ran the irw command and pressed the 3 buttons on the remote.
    18f 0 KEY_GREEN linux-input-layer
    18f 0 KEY_GREEN_UP linux-input-layer
    190 0 KEY_YELLOW linux-input-layer
    190 0 KEY_YELLOW_UP linux-input-layer
    191 0 KEY_BLUE linux-input-layer
    191 0 KEY_BLUE_UP linux-input-layer

    yep its receiving :))


    next i created a file called /etc/lirc/lircrc
    and added the folling to it

    begin
    prog = irexec
    remote = linux-input-layer
    button = KEY_GREEN
    config = /home/osmc/hyperion.ng/build/bin/hyperion-remote --off
    end
    begin
    prog = irexec
    remote = linux-input-layer
    button = KEY_YELLOW
    config = /home/osmc/hyperion.ng/build/bin/hyperion-remote --on
    end
    begin
    prog = irexec
    remote = linux-input-layer
    button = KEY_BLUE
    config = /etc/lirc/shut-down.sh
    end


    I want green and yellow buttons to disable and enable hyperion
    and blue to shutdown the pi cleanly.

    to shutdown i created a simple shell script to run 2 commands not really in the correct place but its /etc/lirc/shut-down.sh
    and contains the following

    /home/osmc/hyperion.ng/build/bin/hyperion-remote --off
    shutdown -h now
    exit 0


    now to test it i started up irexec using the command
    /usr/bin/irexec /etc/lirc/lircrc

    and pressed the buttons on the remote
    green leds went off, yellow leds came on, blue leds went off and the pi shutdown :))

    now i wanted irexec to load on boot so created a service file in /etc/systemd/system called irexec.service
    it contains the below

    [Unit]
    Description=LIRC command handler
    After=hyperion.service
    Wants=hyperion.service
    [Service]
    Type=forking
    ExecStart=/usr/bin/irexec --daemon /etc/lirc/lircrc
    [Install]
    WantedBy=multi-user.target

    i ran the systemctl commands to load and enable the irexec service
    systemctl daemon-reload
    systemctl enable irexec.service

    then rebooted

    now i have my remote working with hyperion :)

    next, ill add a few more buttons to set colours etc.


    hope this helps someone else as much as it will me when i have to do it again :)
     
    • Like Like x 1