KODI / Hyperion on/off

Hello together,

i am currently using my selfmade ambilight running on a raspberry pi 3 with hyperion…

Now i have a question: is it possible to use a “Switch” or something else to turn on or off hyperion when i am not want to use it?

Greetz :slight_smile:

Sorry I can’t provide you with a definitive answer but Hyperion has a JSON interface that you can use within OpenHAB. Check the documentation at https://hyperion-project.org/wiki/hyperion-remote-JSON-interface.

Can I assume you are running Kodi, Hyperion and openhab2 on the same Raspberry Pi?

If so, you can create one or more shell scripts to start and stop the Hyperion service executed in a rule using the Exec Binding every time your Switch item changed.

If not, HTTP Binding and the above linked JSON interface may be the way to go.

I also use hyperion and got it working like this:

I was fiddling around A LOT with Hyperion and OpenHAB 2. It is true that Hyperion features a JSON interface but it is NOT HTTP!. I almost went crazy with this.

After different iterations (Using HTTP which obviously didn’t work, SSHing to the Hyperion Pi, inet-daemons) I decided to have the following setup:

  • Install the hyperion-remote app on the OpenHAB Pi (it takes shell-style command line parameters and connects to your remote Hyperion instance to fire the commands)
  • Use OpenHAB rules to execute the commands on the command line

Why?

Well, there are some nice aspects with this setup:

  • No need to create security holes with passwordless SSH keys
  • No extensive quoting required (like with the Exec binding)
  • No setup on Hyperion Pi required
  • Commands can be changed at any time at the central OpenHAB instance
  • Other services (Hyperion Android App, …) can use Hyperion and read a valid status

You definately could build the JSON data by yourself, but the hyperion-remote works way too well to reinvent the wheel.


My full setup:

items:

Switch living_tv_ambilight (living, lights)

rules:

rule "Ambilight An/Aus schalten"
  when Item living_tv_ambilight received command
  then
  	var String args;
    switch(receivedCommand){
  		case OFF: args = "-c 000000"
  		case ON:  args = "-x"
  	}

  	var String connection = "ambilight:19444";
  	var String cmd = 'hyperion-remote -a ' + connection + ' ' + args;

  	executeCommandLine(cmd);
end

rule "Map Ambilight On/Off to Lux"
  when Item living_lux changed
  then
    var int power_off_over_lux = 100
    if(living_tv.state == ON){
      logWarn("Map Ambilight On/Off to Lux", "Delaying action...")
      Thread::sleep(60000)
      logWarn("Map Ambilight On/Off to Lux", "Action")
      if(living_lux.state > power_off_over_lux && living_tv_ambilight.state == ON)
        living_tv_ambilight.sendCommand(OFF)
      if(living_lux.state < power_off_over_lux && living_tv_ambilight.state != ON)
        living_tv_ambilight.sendCommand(ON)
    }
end

A rule that controls the TV by infrared commands (not shown above) fires a living_tv_ambilight.sendCommand(OFF) while turning off the TV to switch the ambilight off as well. Otherwise I am stuck with the well-known no-cable-connected bluescreen of the TV grabber USB stick.

-c 000000 sets the color (RRGGBB) to black. -c black is possible, too.
-x removes the color setting (going back to default operation, showing ambilight or animations)

You can also start any of the animations. I recommend you to try out the Android App to discover the animations and features, if you don’t know all of them, yet.

I hope this helps :slight_smile:

1 Like

Thank you both for your very useful and informative posts. I will bookmark them for later usage.

@gersilex you are talking about installing a hyperion-remote app on the openHAB system. Can you share a link where I can download this app? Thanks.

Sure, I use this one:
https://raw.githubusercontent.com/hyperion-project/hyperion/master/bin/install_hyperion.sh
Just download and run it on your openhab instance. This is the same
procedure the HyperCon configuration tool uses to install hyperion.

Yes, this is a full hyperion setup, but without a proper config it won’t do
anything at all and therefore won’t take any ressources on your OpenHAB
machine.

Christoph Weitkamp bot@community.openhab.org schrieb am Mi., 19. Apr.
2017 um 17:28 Uhr:

I get it. I thought hyperion-remote app is an additional software.

Thank you for your patience!

Hi,

I tried it like you described above with my setup of two pis (one for openhab and the other one for hyperion) but the hyperion-pi doesn’t react at all if I execute these commands on the openhab-pi:

[19:28:13] pi@openHABianPi:~$ hyperion-remote -a 192.168.2.13:19444 -x
hyperion-remote:
        version   : V1.03.2 (brindosch-99d9396/d3713a8-1469452981
        build time: Jul 25 2016 06:54:18
Connected to 192.168.2.13:19444
Clear priority channel 100

or

 hyperion-remote -a 192.168.2.13:19444 -c FF9200
hyperion-remote:
        version   : V1.03.2 (brindosch-99d9396/d3713a8-1469452981
        build time: Jul 25 2016 06:54:18
Connected to 192.168.2.13:19444
Set color to 255 146 0

Setting colors and turning the ambilight on/off works works perfectly fine with the android app.

Do I have to activate the remote function on my hyperion-pi in order to get it working?

This is weird. You are doing exactly the same thing like me. Except for it’s working for me.

21:42:20.691 [INFO ] [lipse.smarthome.io.net.exec.ExecUtil] - executed commandLine 'hyperion-remote -a ambilight:19444 -c 000000'

You do not have to enable anything to enable this feature and you confirmed it working by using the Android app.

I’d recommend to try different arguments (for testing, not in the openhab rule) like these:

-l (lowercase L) to see if your connection works. Mine looks like this when offline/online:

root@openhab ~# hyperion-remote -a ambilight:19444 -l                                                                                                
hyperion-remote:
        version   : V1.03.2 (brindosch-99d9396/d3713a8-1469452981
        build time: Jul 25 2016 06:54:18
Unable to connect to host

root@openhab ~# hyperion-remote -a ambilight:19444 -l | head
hyperion-remote:
        version   : V1.03.2 (brindosch-99d9396/d3713a8-1469452981
        build time: Jul 25 2016 06:54:18
Connected to ambilight:19444
Get server info
Server info:
{
   "activeEffects" : [],
   "activeLedColor" : [],
   "adjustment" : [
(... the complete config comes here ...)

You should also check the priority of your different data sources. You can see from --help that the priority defaults to 100. This means your command will override/overrule all sources greater than 100.

Set those priorities with the HyperCon Software. For example, your /dev/video0 source could have a priority of 200 and your intro animation (if any) could have 190. The Intro animation will overrule the video0 source until it’s finished or aborted. And if you send a command with the default priority of 100, it should overrule both of the other data sources / animations, because the priority number is higher.

For testing or as permanent fix, you could also change the priority number when sending commands with hyperion-remote

root@openhab ~# hyperion-remote -a ambilight:19444 -p 1 -c FF0000
hyperion-remote:
        version   : V1.03.2 (brindosch-99d9396/d3713a8-1469452981
        build time: Jul 25 2016 06:54:18
Connected to ambilight:19444
Set color to 255 0 0

Remember to also set the priority when cancelling your override:

root@openhab ~# hyperion-remote -a ambilight:19444 -p 1 -x
hyperion-remote:
        version   : V1.03.2 (brindosch-99d9396/d3713a8-1469452981
        build time: Jul 25 2016 06:54:18
Connected to ambilight:19444
Clear priority channel 1

:slight_smile:

1 Like

Thanks for the hint with the priority :slight_smile:
Now it works fine. The android app seems to have a priority of 50 so I just have to add the argument ‘-p’ to my command and use a higher priority and voilà it works :smiley:

Just found this, may be of some use.
https://openhab.jfrog.io/openhab/li...g.openhab.binding.hyperion-2.1.0-SNAPSHOT.jar

Hi,

That link doesn’t appear to be working. I tink it should be https://openhab.jfrog.io/openhab/libs-pullrequest-local/org/openhab/binding/org.openhab.binding.hyperion/2.1.0-SNAPSHOT/org.openhab.binding.hyperion-2.1.0-SNAPSHOT.jar

I can confirm this to be working. It takes a while to process, (more than 5000ms as pointed out by the log), so you have to be patient between color changes. It is not as smooth as using the native Hyperion Android app.

Actually I fixed the processing issue by increasing number of threads as mentioned here: Handler takes more than 5000ms for processing event

One short term workaround would be to increase the safeCall threadpool size. You could try to add the line

org.eclipse.smarthome.threadpool:safeCall=10

to conf/services/runtime.cfg and see if that helps.

You can use the TCP binding.[quote=“Hrushikesh_Ghatpande, post:14, topic:26860”]
It takes a while to process, (more than 5000ms as pointed out by the log), so you have to be patient between color changes. It is not as smooth as using the native Hyperion Android app.
[/quote]

The communication should be the same (instantaneous) as the android app as the communication is a simple TCP packet.

However I’d appreciate if you could move the binding discussion to https://community.openhab.org/t/hyperion-binding-looking-for-testers/ for better visibility.

Ambilight components

Led stripes and some connectors

  • LED stripe: We need a special led stripe. I recommend the APA102 strip, very robust and you don´t need much time for the color calibration
  • Power supply: The leds consumes much power, too much for a Pi. So we need a second power supply.
  • Connectors: To connet the stripe parts with each other and to supply the power. Additional to wire up tha data cables from the Raspberry PI GPIO

Hyperion On/Off Scenario.