Page 1 of 2

[689] Hyperion integration

Posted: Monday 18 January 2016 18:01
by deennoo
Hello,

Just set up an Hyperion solution.

Hyperion is a DIY Ambilight for TV/movie etc etc.

This well documented : https://github.com/tvdzwan/hyperion/wiki and really stable

It's works as a web server.

Using it with XBMC is a real pleasure, and adding a video grabber you can appli Hyperion to your ISPTVbox or DVB reciever (if not inclued on your TV).

Hyperion can be use as "light" with Android/ios/webapp, and got some cool effect, of course we can use script to drive it for "effects", but not really user friendly for RGB color.

As this solution, is stable, well documented, can give a real WAF to our home automation, this can be really cool if it can be Drive by Domoticz :

Somes exemples :
- When Movie/tv show is end, turn TV and all accessorie OFF
- When it's lover time, set hyperion on a charming candel mode (using a 433 Remote or NFC Tag, or any thing you can use to define this).
- When is party (defin by a google calendar event) set Hyperion on disco mode

Re: [689] Hyperion integration

Posted: Thursday 21 January 2016 14:39
by iMars
With the following commands you can change the effect/color:

Code: Select all

echo '{ "command": "effect", "effect": {"name": "Full color mood blobs"}, "priority": 100 }' | nc x.x.x.x 19444
echo '{ "command": "clear", "priority": 100 }' | nc x.x.x.x 19444
echo '{ "command": "color", "color": [255,255,255], "priority": 100 }' | nc x.x.x.x 19444
Edit: wrong button, submit instead of preview :oops:

With "runcommand" in a LUA script you can execute a command:

Code: Select all

runcommand = "echo '{ "command": "color", "color": [255,255,255], "priority": 100 }' | nc x.x.x.x 19444"
Where x.x.x.x is ofcourse the IP of hyperion
Create a device this way: http://blog.quindorian.org/2015/01/esp8 ... -of-x.html
And use the following script (not the one on the page mentioned above):

Code: Select all

pi@domoticz:~$ cat domoticz/scripts/lua/script_device_MoodLight.lua
commandArray = {}

DomDevice = 'MoodLight' --name device
IP = 'x.x.x.x' -- ip address hyperion
Port = '19444'
-- default color (one color, dimmable)
DomR = 255 --RED
DomG = 31  --GREEN
DomB = 0   --BLUE

if devicechanged[DomDevice] then
        if(devicechanged[DomDevice]=='Off') then
                DomValue = 0;
                print('Turn '..DomDevice..' off...')
        elseif(devicechanged[DomDevice]=='On') then
                DomValue = 31;
                print('Turn '..DomDevice..' on...')
        else
                DomValue = (otherdevices_svalues[DomDevice]);
        end
        print('DomValue for '..DomDevice..' changed to:'..DomValue)
        DomR = math.ceil(DomValue / 31 * DomR)
        DomG = math.ceil(DomValue / 31 * DomG)
        DomB = math.ceil(DomValue / 31 * DomB)
        runcommand = "echo  '{ \"color\": [" .. DomR .. "," .. DomG .. "," .. DomB .. "], \"command\": \"color\", \"priority\": 10 }' | nc " .. (IP) .. " " .. (Port) .. " ";
        print (runcommand);
        os.execute(runcommand);
end

return commandArray
pi@domoticz:~$
This create a dimmer which can fade only one color (I've got 4 dimmers for my Hyperion).

Note: Domoticz has priority 10, XBMC/Kodi has priority 1. When movie is playing, i've got ambilight, when movie stops, it goes back to the color set with domoticz ;)

Re: [689] Hyperion integration

Posted: Thursday 21 January 2016 15:00
by iMars
Ofcourse a full integration would be even better! Or a dummy rgb dimmer, which can pass the corrosponding hex code to a LUA script, that combining my script would make it possible to have ONE switch for all kinds of colors :idea:

Re: [689] Hyperion integration

Posted: Thursday 21 January 2016 16:59
by deennoo
iMars wrote:Ofcourse a full integration would be even better! Or a dummy rgb dimmer, which can pass the corrosponding hex code to a LUA script, that combining my script would make it possible to have ONE switch for all kinds of colors :idea:
Thanks for your help !

I really love this idea, and a rolling menu to choose which effect we want when "planning" a scene.

Very Nice Blog !!

I plan to do some looks like of your Ikea Hack but with a DIY Philips Hue Bridge (who act as a bulb too : https://github.com/sticilface/Esp8266-Hue) + ws2812b + Wemos Mini D1 : bridge part is ok, and well reconnize by domoticz, waiting my ws2812b strip.

Re: [689] Hyperion integration

Posted: Thursday 21 January 2016 18:26
by deennoo
First feedback : perfect !

Just one issue :
- i use v4l2 grabber, not kodi ones.

when turn "virtual dimmer" off that doesn't enable v4l2, my led strip stay off until i restart hyperion.

Any idea ?

Re: [689] Hyperion integration

Posted: Thursday 21 January 2016 21:13
by deennoo
Got a solution : sending clearall when dimmer is off, freeing v4l2 led strip.

Now have to know how set this on lua script

Re: [689] Hyperion integration

Posted: Friday 22 January 2016 7:15
by iMars
deennoo wrote:Got a solution : sending clearall when dimmer is off, freeing v4l2 led strip.

Now have to know how set this on lua script
Use my script, and instead of color 0,0,0 > use echo '{ "command": "clear", "priority": 100 }' | nc x.x.x.x 19444

Code: Select all

commandArray = {}

DomDevice = 'MoodLight' --name device
IP = 'x.x.x.x' -- ip address hyperion
Port = '19444'
-- default color (one color, dimmable)
DomR = 255 --RED
DomG = 31  --GREEN
DomB = 0   --BLUE

if devicechanged[DomDevice] then
        if(devicechanged[DomDevice]=='Off') then
                --DomValue = 0;
                print('Turn '..DomDevice..' off...')
                runcommand = "echo  '{ \"command\": \"clear\", \"priority\": 10 }' | nc " .. (IP) .. " " .. (Port) .. " ";
                print (runcommand);
                os.execute(run command);
                return commandArray;
        elseif(devicechanged[DomDevice]=='On') then
                DomValue = 31;
                print('Turn '..DomDevice..' on...')
        else
                DomValue = (otherdevices_svalues[DomDevice]);
        end
        print('DomValue for '..DomDevice..' changed to:'..DomValue)
        DomR = math.ceil(DomValue / 31 * DomR)
        DomG = math.ceil(DomValue / 31 * DomG)
        DomB = math.ceil(DomValue / 31 * DomB)
        runcommand = "echo  '{ \"color\": [" .. DomR .. "," .. DomG .. "," .. DomB .. "], \"command\": \"color\", \"priority\": 10 }' | nc " .. (IP) .. " " .. (Port) .. " ";
        print (runcommand);
        os.execute(runcommand);
end

return commandArray
By the way... it isn't my blog, I've reused his information and adjusted it for hyperion.

Re: [689] Hyperion integration

Posted: Friday 22 January 2016 9:03
by deennoo
will try it ! thanks !

Good blog by the way !

Re: [689] Hyperion integration

Posted: Friday 22 January 2016 10:17
by deennoo
It perfectly Works !

Thanks for your help !!

Re: [689] Hyperion integration

Posted: Friday 22 January 2016 10:54
by deennoo
Next step ?

Get a "color picker"

Set One Dummy dimmer for each color who write on variable is value.
Set One Dummy dimmer for "lighting level" (Value variable for Hyperion remote / Level Variable for domoticz dimmer)

When Moving one of the dummy color slider it send to hyperion Red Dimmer + Blue Dimmer + Green Dimmer value to flollow :

Code: Select all

runcommand = "echo  '{ \"color\": [" .. DomR .. "," .. DomG .. "," .. DomB .. "], \"command\": \"color\", \"priority\": 10 }' | nc " .. (IP) .. " " .. (Port) .. " ";
Where DomR is value set last time you move slider
Where DomG is value set last time you move slider
Where DomB is value set last time you move slider

Re: [689] Hyperion integration

Posted: Friday 22 January 2016 11:19
by iMars
deennoo wrote:Next step ?

Get a "color picker"

Set One Dummy dimmer for each color who write on variable is value.
Set One Dummy dimmer for "lighting level" (Value variable for Hyperion remote / Level Variable for domoticz dimmer)

When Moving one of the dummy color slider it send to hyperion Red Dimmer + Blue Dimmer + Green Dimmer value to flollow :

Code: Select all

runcommand = "echo  '{ \"color\": [" .. DomR .. "," .. DomG .. "," .. DomB .. "], \"command\": \"color\", \"priority\": 10 }' | nc " .. (IP) .. " " .. (Port) .. " ";
Where DomR is value set last time you move slider
Where DomG is value set last time you move slider
Where DomB is value set last time you move slider
I don't want to use this option, I've tried it, and its not handy. Only 31 red's, 31, blue's and 31 green's. Stil, you should be able to create 32.768 different colors, yet not do-able. I've created 4 sliders for the most used colors: light yellow for normal light, yellow, orange and red. All 4 with sliders like my first posted script.

Re: [689] Hyperion integration

Posted: Friday 22 January 2016 13:12
by deennoo
OK !

Thanks for your feedback

Next step again ?

Made my hyperion follow my Milight color value...

Looks crazy that we are only 2 using hyperion & domoticz

Re: [689] Hyperion integration

Posted: Monday 25 January 2016 11:41
by ab1976
I/m also using the solution from hyperion and was looking for a similair olution you are working on :-)

Re: [689] Hyperion integration

Posted: Monday 25 January 2016 17:26
by deennoo
Got a New probleme,

For fun i want some switch to load and stop effect :

Base on iMars elements i made this script, no lua error but no reaction from hyperion :

Code: Select all

commandArray = {}

DomDevice = 'Hyperion Arc en Ciel' --name device
IP = '192.168.0.245' -- ip address hyperion
Port = '19444'


if devicechanged[DomDevice] then
        if(devicechanged[DomDevice]=='Off') then
                
                print('Turn '..DomDevice..' off...')
                runcommand = "echo  '{ \"command\": \"clear\", \"priority\": 10 }' | nc " .. (IP) .. " " .. (Port) .. " ";
                print (runcommand);
                os.execute(runcommand);
                return commandArray;
        elseif(devicechanged[DomDevice]=='On') then
                print('Arc En ciel Rapide !')
                runcommand = "echo  '{ \"command\": \"effect\", \"effect\": {\"name\": \"Rainbow swirl fast\" }, \"priority\": 100 }' | " .. (IP) .. " " .. (Port) .. " ";
                os.execute(runcommand);
end
end

return commandArray
Any Idea please ?

Re: [689] Hyperion integration

Posted: Tuesday 26 January 2016 21:04
by iMars
deennoo wrote:Got a New probleme,

For fun i want some switch to load and stop effect :

Base on iMars elements i made this script, no lua error but no reaction from hyperion :

Code: Select all

commandArray = {}

DomDevice = 'Hyperion Arc en Ciel' --name device
IP = '192.168.0.245' -- ip address hyperion
Port = '19444'


if devicechanged[DomDevice] then
        if(devicechanged[DomDevice]=='Off') then
                
                print('Turn '..DomDevice..' off...')
                runcommand = "echo  '{ \"command\": \"clear\", \"priority\": 10 }' | nc " .. (IP) .. " " .. (Port) .. " ";
                print (runcommand);
                os.execute(runcommand);
                return commandArray;
        elseif(devicechanged[DomDevice]=='On') then
                print('Arc En ciel Rapide !')
                runcommand = "echo  '{ \"command\": \"effect\", \"effect\": {\"name\": \"Rainbow swirl fast\" }, \"priority\": 100 }' | " .. (IP) .. " " .. (Port) .. " ";
                os.execute(runcommand);
end
end

return commandArray
Any Idea please ?
Take a good look at your code :geek:

You can run the command from a terminal (I work on a Mac, If you work on Windows, ssh with putty to domoticz or your hyperion linux ;) ).
I ran your command: echo '{ "command": "effect", "effect": {"name": "Rainbow swirl fast" }, "priority": 10 }' | <my ip> 19444 and it didn't work... because you've forgotten the "nc" right after the "|" before your <ip> :lol:
The right syntax is: echo '{ "command": "effect", "effect": {"name": "Rainbow swirl fast" }, "priority": 10 }' | nc <your ip> 19444

I fixed your code:

Code: Select all

commandArray = {}

DomDevice = 'Hyperion Arc en Ciel' --name device
IP = '192.168.0.245' -- ip address hyperion
Port = '19444'


if devicechanged[DomDevice] then
	if(devicechanged[DomDevice]=='Off') then
		print('Turn '..DomDevice..' off...')
		runcommand = "echo  '{ \"command\": \"clear\", \"priority\": 10 }' | nc " .. (IP) .. " " .. (Port) .. " ";
		print (runcommand);
		os.execute(runcommand);
		-- skip this, its not needed -- return commandArray;
	elseif(devicechanged[DomDevice]=='On') then
		print('Arc En ciel Rapide !')
		runcommand = "echo  '{ \"command\": \"effect\", \"effect\": {\"name\": \"Rainbow swirl fast\" }, \"priority\": 10 }' | nc " .. (IP) .. " " .. (Port) .. " ";
		os.execute(runcommand);
	end
end

return commandArray
Also use the same priority everywhere ;)

Re: [689] Hyperion integration

Posted: Tuesday 26 January 2016 23:21
by deennoo
Thanks for this what mean "nc" ?

Re: [689] Hyperion integration

Posted: Wednesday 27 January 2016 9:00
by iMars
deennoo wrote:Thanks for this what mean "nc" ?
Google is your friend ;)

The "|" sign pipes the output (the echo '...') to the nc command, which is used to talk to the ip of hyperion

Re: [689] Hyperion integration

Posted: Friday 16 September 2016 10:03
by deennoo
Small improvement for those who run Domoticz on a Syno and want to use netcat command.

It appear that Netcat on a Syno stay ON and don't kill connection this give an error on Domoticz Log because LUA script run more than 10 secondes, and Domoticz freeze during this time.

You just have to had -c value to your netcat command, this give :

Code: Select all

runcommand = "echo  '{ \"command\": \"effect\", \"effect\": {\"name\": \"Rainbow swirl fast\" }, \"priority\": 10 }' | nc -c " .. (IP) .. " " .. (Port) .. " ";
No more error anymore

Re: [689] Hyperion integration

Posted: Sunday 06 August 2017 10:43
by elgringo
I don't know if anybody is intereseted, but i made a python plugin (for the beta version):
https://github.com/ericstaal/domoticz/t ... n/hyperion

Allows you to control rgb values and select mode

Re: [689] Hyperion integration

Posted: Sunday 06 August 2017 13:58
by deennoo
will test it this night ! thx !

Some question about it : did you parse effect from hyperion or did your already write on plugin usual effect ?

how to install it ? just paste the plugin.py file ?