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

Controlling Multiple Devices

Introduction

Hyperion has the ability to control multiple devices at once using its forwarding feature, you will need to create separate configurations for each of your LED devices however one instance of Hyperion will forward it to all others be it local or remote.

Please read also Network and distributed features

Multiple configurations setup (Raspbian)

While hyperion cannot control multiple devices lets say Philips Hue and a led strip at the same time (which makes us all very sad) it is possible to spawn multiple hyperion daemons each with their own config file controlling different devices which is, if not even more just as awesome!

This will explain how to have multiple hyperion daemons running each controlling their own device. I've tested this with a led strip and philips hue running on the latest version of OSMC and latest version of Hyperion on a Raspberry Pi. Some of the steps written below might be a little different on different linux distributions or hardware, but in general the basics stay the same.

Hyperion grabs its video frames from Kodi on a client server model which luckily gives us the opportunity to have multiple clients (in this case multiple hyperion daemons) grabbing frames from the same Kodi server.

First thing to do is setup Hyperion like you normally would. I in this case set it up to control my led strips on the back of my tv.

Create a configuration file using hypercon and put it in the default place /opt/hyperion/config/hyperion.config.json now start up hyperion and its controlling the leds like it should, all randy dandy..

Now create a second configuration file for lets say your Philips hue lights and name it something like hyperion.config2.json. Upload this again in /opt/hyperion/config/ making sure its not overwriting your first config file but has a different name.

Now edit this second configuration file and pay attention to the following sections.

Code:
"jsonServer" : { "port" : 19444 },

"protoServer" : { "port" : 19445 },
These are servers which hyperion will start but since these ports are already in use by your first hyperion daemon your second hyperion will fail to start with error binding to ports. The key here is changing these ports to some other port numbers taking in account that these should be available and not in use by some other programs. I simply changed them to 19446 and 19447 as they where free on my install. Maybe its also possible to just disable these servers, but i'm not sure what they are for so for me it made more sence to just give them different port numbers.

Now after changing these port numbers in the configuration file you can give your second hyperion a go. With the first hyperion daemon running and doing its thing start up the second daemon manually by going into your pi either with ssh or local and executing the following command

Code:
sudo /usr/bin/hyperiond /opt/hyperion/config/hyperion.config2.json
As you can see I gave my second configuration file as a command line argument to the daemon so it knows to use this one instead of the default one.

If all went well and your config is correctly setup your second hyperion should be running now giving you all kind of json output and is controlling your philips hue lights.

In case it doesn't work and you sure you changed the port numbers to free ports then there is probably another problem with your config. In this case you can stop the first hyperion daemon and first see if you can get your config running as a single daemon.

Now its all working and your super hyped calling up friends and making videos with your iphone but wait a minute! You don't want to be running this command every time you reboot your Pi right?

Lets create a startup script to finish off with a cherry on top.

Firstly we need to make a small edit in the original startup script of hyperion, otherwise it will conflict with the startup script of our second one.

Open up /etc/init.d/hyperion in your favorite editor (which should be vim) and edit the following line

Code:
NAME=$DAEMON
and change it to

Code:
NAME="hyperion1"
Now save it and put it back in place. Now make a copy of this startup script by doing so on your console

Code:
cp /etc/init.d/hyperion /etc/init.d/hyperion2
Now edit /etc/init.d/hyperion2 in your favorite editor (which is vim now) and change the following lines

Code:
DAEMONOPTS="/opt/hyperion/config/hyperion.config.json" to DAEMONOPTS="/opt/hyperion/config/hyperion.config2.json"

NAME="hyperion1" to NAME="hyperion2"
save and back in place.

Now you gotta make a hardlink to tell your linux to start this up on boot. You can do this by running the following command:

Code:
ln /etc/rc2.d/S01hyperion2 /etc/init.d/hyperion2
Now give that Pi a big ol' reboot and watch all your lights magically lid up.

Google ProtoBuffer and JSON message forwarding

Hyperion receives ProtoBuffer and JSON messages and has the option to forward those to other Hyperion instances be it local or on a remote (accessible) network.

So if you want to control multiple Hyperion instances as one for instance via android app or hyperion-remote you can use ProtoBuffer and/or JSON message forwarding.

Forwarding example #1 - ProtoBuffer and JSON forwarding combined

The below configuration example snippet has 3 Hyperion instances involved where one has this configuration and will forward both ProtoBuffer and JSON messages to 2 other instances.

Code:
"protoServer" :
{
  "port" : 19445
},
....
"jsonServer" :
{
  "port" : 19444
},
....
"forwarder" :
{
  "proto" : [ "127.0.0.1:20445","192.168.178.88:19445" ],
  "json"  : [ "127.0.0.1:20444","192.168.178.88:19444" ]
},
The main Hyperion instance should have a ProtoBuffer input via Kodi Hyperion addon for instance or be supplied by a standalone live capture grabber (e.g. hyperion-v4l2).

The other two instances of Hyperion are on localhost (127.0.0.1) and the other on a remote host (192.168.178.88) which should have their own configuration.
Multiple destinations are comma separated like in the example above.

Forwarding example #2 - JSON forwarding only

The below configuration example snippet has 3 Hyperion instances involved where one has this configuration and will forward JSON messages to 2 other instances.

Code:
"jsonServer" :
{
  "port" : 19444
},
....
"forwarder" : {
  json : ["127.0.0.1:20444" , "192.168.178.88:19444"]
},
The other two instances of Hyperion are on localhost (127.0.0.1) and the other on a remote host (192.168.178.88) which should have their own configuration. Multiple destinations are comma separated like the example above.

Forwarding troubleshooting

  • Please keep an eye on the ports. Avoid using same ports for different Hyperion instances on localhost. Also don't use ports that are used by other services like Hyperion JSON server, Boblight or system services.

This page has been seen 14,811 times.