How to: turn Hyperion on/off using your TV remote.


Posted in Raspberry Pi
11 comments on “How to: turn Hyperion on/off using your TV remote.
  1. Sarybe says:

    On my raspberry pi 2, your script didnt work with osmc.
    I change for that :

    #!/bin/bash

    PROCESS_NUM=`pgrep hyperiond | wc -l`

    if [ $PROCESS_NUM -eq 1 ]

    then
    curl -v -H “Accept: application/json” -H “Content-type: application/json” -X POST -d ‘{“id”:1,”jsonrpc”:”2.0″,”method”:”GUI.ShowNotification”,”params”:{“title”:”Hyperion”,”message”:”Disabled”,”image”:”/home/osmc/hyperion.png”}}’ http://127.0.0.1:8080/jsonrpc
    sudo service hyperion stop

    else
    curl -v -H “Accept: application/json” -H “Content-type: application/json” -X POST -d ‘{“id”:1,”jsonrpc”:”2.0″,”method”:”GUI.ShowNotification”,”params”:{“title”:”Hyperion”,”message”:”Enabled”,”image”:”/home/osmc/hyperion.png”}}’ http://127.0.0.1:8080/jsonrpc
    sudo service hyperion start
    fi

    • Davy Uittenbogerd says:

      This one works for me… Almost.
      I only could get it to go ‘enabled’ But it won’t disable… Any thoughts about this?

      I have two instances running. Here’s my Hyperion status log:

      osmc@osmc:~$ sudo service hyperion status
      ● hyperion.service – Hyperion Systemd service
      Loaded: loaded (/etc/systemd/system/hyperion.service; enabled)
      Active: active (running) since wo 2017-01-25 11:06:50 CET; 10min ago
      Main PID: 760 (hyperiond)
      CGroup: /system.slice/hyperion.service
      ├─760 /usr/bin/hyperiond /etc/hyperion/hyperion.config.json /etc/hyperion/hyperion.config2.json
      └─762 /usr/bin/hyperiond –parent 760 /etc/hyperion/hyperion.config2.json

      jan 25 11:06:53 osmc hyperiond[760]: EFFECTENGINE INFO: 27 effects loaded from directory /usr/share/hyperion/effects
      jan 25 11:06:53 osmc hyperiond[760]: EFFECTENGINE INFO: Initializing Python interpreter
      jan 25 11:06:53 osmc hyperiond[760]: INFO: Hyperion started and initialised
      jan 25 11:06:53 osmc hyperiond[760]: INFO: Json server created and started on port 19446
      jan 25 11:06:53 osmc hyperiond[760]: INFO: Proto server created and started on port 19447
      jan 25 11:06:53 osmc hyperiond[760]: EFFECTENGINE INFO: effect finished
      jan 25 11:06:55 osmc hyperiond[760]: PROTOSERVER INFO: New connection
      jan 25 11:06:55 osmc hyperiond[760]: BLACKBORDER INFO: threshold set to 0.01 (3)
      jan 25 11:06:55 osmc hyperiond[760]: BLACKBORDER INFO: mode:default
      jan 25 11:06:55 osmc hyperiond[760]: PROTOCONNECTION INFO: Connected to Hyperion: 127.0.0.1:19447
      jan 25 11:07:06 osmc systemd[1]: Started Hyperion Systemd service.
      jan 25 11:08:42 osmc systemd[1]: Started Hyperion Systemd service.
      jan 25 11:08:50 osmc systemd[1]: Started Hyperion Systemd service.
      jan 25 11:08:56 osmc systemd[1]: Started Hyperion Systemd service.
      jan 25 11:14:49 osmc systemd[1]: Started Hyperion Systemd service.

      • Davy Uittenbogerd says:

        Ok, found out that ‘pgrep hyperiond’ had an output greater than ‘1’.

        So I edit the code with just changing the -eq argument to -ge.
        So my script looks like this now:

        #!/bin/bash

        PROCESS_NUM=`pgrep hyperiond | wc -l`

        if [ $PROCESS_NUM -ge 1 ]

        then

        curl -v -H “Accept: application/json” -H “Content-type: application/json” -X POST -d ‘{“id”:1,”jsonrpc”:”2.0″,”method”:”GUI.ShowNotification”,”params”:{“title”:”Hyperion”,”message”:”Disabled”,”image”:”/home/osmc/hyperion.png”}}’ http://127.0.0.1:8080/jsonrpc

        sudo service hyperion stop

        else

        curl -v -H “Accept: application/json” -H “Content-type: application/json” -X POST -d ‘{“id”:1,”jsonrpc”:”2.0″,”method”:”GUI.ShowNotification”,”params”:{“title”:”Hyperion”,”message”:”Enabled”,”image”:”/home/osmc/hyperion.png”}}’ http://127.0.0.1:8080/jsonrpc

        sudo service hyperion start

        fi

        • Sarybe says:

          “pgrep hyperiond” is all the time greatest to 1 because it’s a PID. But normaly “pgrep hyperiond | wc -l” is equal to 1. If it’s more than 1 you have another process running. Check with the “top” command.

          • Davy Uittenbogerd says:

            I have two instances of Hyperion running. One for the backlight and on for the ‘surround’ AtmoOrbs. So, I think that’s the issue I have.

          • Sarybe says:

            Indeed if you run at the same time hyperion backlight and AtmoOrbs this is normal.
            -ge 1 is s more appropriate 🙂

  2. Colin Shorts says:

    I have a problem with Hyperion (and boblight when I used that) that meant I’d get the odd pixel coming on and changing colour, so I prefer to just set the colour to black (000000) and then unset it again to allow hyperion to display colour as normal during playback. Sadly you can’t check the current colour of hyperion, so I’m stop/starting the daemon with a slightly modified version of the script (it’s on osmc).

    My next plan is to stop controlling the WS2801’s directly from the pi using SPI and move it to an arduino, and failing that switch the led power off using a relay. On another note, as I use Yatse as a remote for Kodi I’ve setup a custom command to toggle Hyperion ‘on’ and ‘off’ – it took me a while to figure out that you just use ‘Blue’, it had to be capitalised like that to work.

    Thanks for making me make my tv (and room) more colourful 🙂