Skip to content

Controlling multiple devices

redPanther edited this page Mar 6, 2016 · 7 revisions

NOTE there is a new solution for connecting multiple hyperions together (and use multiple LED devices). see PR #518 and issue #486


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!

In this article I'll try to 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 /etc/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 /etc 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.

"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

sudo /usr/bin/hyperiond /etc/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

NAME=$DAEMON

and change it to

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

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

DAEMONOPTS="/etc/hyperion.config.json" to DAEMONOPTS="/etc/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

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.