Page 1 of 1
Is there a way to set a Hue light color?
Posted: Wednesday 22 November 2017 13:04
by rizzah
Hi,
I have not yet found a way to set a color to a hue light. Right now i can dim it with dimTo() but does anyone know how i can set the color?
Thanks.
Re: Is there a way to set a Hue light color?
Posted: Wednesday 22 November 2017 17:10
by febalci
I tried a lot but couldn't set the hue color to native Philips Bright scene. So what i did is to set a bash script to "Action On" and in the script i used Philips Hue API to set the specific Bright color scene: "curl --request PUT --data "{\"scene\":"...
Since the color values of hue lights do not equalize to RGB coloring scheme, I didn't tried the other colors. But i believe since you can use Dimmer Light Switch for hue lamps and can change colors, i believe you can still use RGB Hue Brightness values in the scripts. But do not expect to get a color value of native Philips Color.
Re: Is there a way to set a Hue light color?
Posted: Wednesday 22 November 2017 17:20
by AmySoto
Thanks a lot for the suggestions)
Re: Is there a way to set a Hue light color?
Posted: Wednesday 22 November 2017 22:34
by Kerel
I use a 'scene' for this. Just create a scene 'Set light to blue', choose your color and call this scene in your script.
Re: Is there a way to set a Hue light color?
Posted: Thursday 23 November 2017 8:39
by rizzah
Alright, good tips!
Thanks.
Re: Is there a way to set a Hue light color?
Posted: Thursday 23 November 2017 13:14
by rizzah
@febalci
Would you mind sharing your whole curl syntax?
Re: Is there a way to set a Hue light color?
Posted: Thursday 23 November 2017 13:41
by rizzah
Another way to play with it, is to use domoticz api, you would say its the saem as working in the web interface, however it seems easier to get it more bright using the url. Able to set it to brightness 200.
I used this url to get the IDX for my lights:
https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's
Then this url to manage the lights:
https://domoticz.vlanz.nl/json.htm?username=[USERNAME-HERE]=&password=[PASSWORD-HERE]=&type=command¶m=setcolbrightnessvalue&idx=149&hue=86&brightness=200&iswhite=false
Re: Is there a way to set a Hue light color?
Posted: Thursday 21 December 2017 20:05
by Amsterdam020
Hi,
I am playing around with changing the hue color of my light based on the current electricity use (based on youless).
The hue colorcode i then use in a json url to change the color of the hue light.
For the color codes see:
https://developers.meethue.com/document ... e-concepts
This is the url to change the hue of a philips ligth with domoticz
http://192.168.1.85:8080/json.htm?type= ... hite=false
Just change ipadres, idx of your philips hue ligth and the colorcode you wish
Code: Select all
#!/usr/bin/python
# -*- coding: utf-8 -*-
import time
import simplejson
import urllib2
for x in range(0, 400):
response = urllib2.urlopen("http://192.168.1.85:8080/json.htm?type=devices&rid=4").read()
result = simplejson.loads(response)
Usage = result['result'][0]['Usage']
c=Usage[:-5]
cc=int(float(c))
huecode=25500-6.375*cc
print c
print huecode
response = urllib2.urlopen("http://192.168.1.85:8080/json.htm?type=command¶m=setcolbrightnessvalue&idx=794&hue="+str(huecode)+"&brightness=255&iswhite=false").read()
result = simplejson.loads(response)
print "We're on time %d" % (x)
time.sleep(3) # delays for 10 seconds
Re: Is there a way to set a Hue light color?
Posted: Thursday 21 December 2017 20:29
by febalci
rizzah wrote: ↑Thursday 23 November 2017 13:14
@febalci
Would you mind sharing your whole curl syntax?
Hello rizzah. I created a bash script file:
Code: Select all
#!/bin/bash
curl --request PUT --data "{\"scene\": \"RIBQRaAv-jnjbvP\"}" http://192.168.1.80/api/Usercode/groups/1/action
Here instead of usercode you have to entee philips api usercode. And this is for a group of lights. You can get help from hue api.
Then you enter the script name to On Action of the device. So whenever you switch the light to on it gets the scene bright from hue api. Of course you also have to find scene name from your hue api.
Re: Is there a way to set a Hue light color?
Posted: Friday 22 December 2017 13:17
by dannybloe
In the next version of dzVents 2.4 you can do myLight.setRGB(124, 233, 11)
Re: Is there a way to set a Hue light color?
Posted: Sunday 18 February 2018 15:14
by Derik
dear all.
Is there perhaps someone that have the scene in to Hue working?
I mean the disco option, or romance or sunset rise etc.
I see a app with a lot of options..
Perhaps they can be use int domoticz..
Hope there is a person that can help me with this..
Thanks
[ From my party kids ]
Re: Is there a way to set a Hue light color?
Posted: Tuesday 20 February 2018 14:52
by triton
I currently use something like this:
Code: Select all
function hue_colors(bri,hue,sat,device)
local bridge = '<bridge ip>'
local data = '{\\"on\\":true, \\"sat\\":'..sat..', \\"bri\\":'..bri..', \\"hue\\":'..hue..'}'
os.execute('curl --request PUT --data "'..data..'" http://'..bridge..'/api/<API_ID_HERE>/lights/'..device..'/state')
end
You need to know the hue id for the light and just set the other values. You can query a light id to get the current values for bri, hue, sat:
Code: Select all
http://<API>/api/<API_ID/lights/<ID>
I'm currently using a table to hold some scenes, example is rewritten a bit from what I have. If I recall correctly the Read, Relax and Energie are settings from the hue app. Just wrote the values down. light ID is 1 in this example.
Code: Select all
local selector = {}
-- bri: hue: sat:
selector['Read'] = { '254', '8595', '121' }
selector['Relax'] = { '144', '7688', '199' }
selector['Energie'] = { '254', '41432', '75' }
hue_colors(selector['Read][1],selector['Read'][2],selector['Read'][3],1)
Hope this helps.
Re: Is there a way to set a Hue light color?
Posted: Tuesday 20 February 2018 20:41
by Derik
triton wrote: ↑Tuesday 20 February 2018 14:52
I currently use something like this:
Code: Select all
function hue_colors(bri,hue,sat,device)
local bridge = '<bridge ip>'
local data = '{\\"on\\":true, \\"sat\\":'..sat..', \\"bri\\":'..bri..', \\"hue\\":'..hue..'}'
os.execute('curl --request PUT --data "'..data..'" http://'..bridge..'/api/<API_ID_HERE>/lights/'..device..'/state')
end
You need to know the hue id for the light and just set the other values. You can query a light id to get the current values for bri, hue, sat:
Code: Select all
http://<API>/api/<API_ID/lights/<ID>
I'm currently using a table to hold some scenes, example is rewritten a bit from what I have. If I recall correctly the Read, Relax and Energie are settings from the hue app. Just wrote the values down. light ID is 1 in this example.
Code: Select all
local selector = {}
-- bri: hue: sat:
selector['Read'] = { '254', '8595', '121' }
selector['Relax'] = { '144', '7688', '199' }
selector['Energie'] = { '254', '41432', '75' }
hue_colors(selector['Read][1],selector['Read'][2],selector['Read'][3],1)
Hope this helps.
Please some more help..
i do not understand how you use this..
?
Dummy?
Lua?
or?
Re: Is there a way to set a Hue light color?
Posted: Thursday 22 February 2018 13:50
by triton
I'm using a selector switch (Hue Color) with the levels matching the hue color scene (Read, Relax etc.). Code is dzVents. Uses curl to talk directly to the Hue bridge. Accept for the switch off, thats done by domoticz talking to Hue.
Code: Select all
local function hue_colors(bri,hue,sat,device)
local bridge = '<bridge ip>'
local data = '{\\"on\\":true, \\"sat\\":'..sat..', \\"bri\\":'..bri..', \\"hue\\":'..hue..'}'
os.execute('curl --request PUT --data "'..data..'" http://'..bridge..'/api/<API_ID_HERE>/lights/'..device..'/state')
end
return {
active = true,
on = {
devices = {
'Hue Color'
}
},
execute = function(domoticz, scene)
local name = scene.levelName
print('Hue: switching color scene to: ' .. name)
local selector = {}
-- bri: hue: sat:
selector['Read'] = { '254', '8595', '121' }
selector['Relax'] = { '144', '7688', '199' }
selector['Energie'] = { '254', '41432', '75' }
if name == 'Off' then
domoticz.devices('Hue light 1').switchOff()
domoticz.devices('Hue light 2').switchOff()
domoticz.devices('Hue light 3').switchOff()
else
hue_colors(selector[name][1],selector[name][2],selector[name][3],3) -- light 1, hue id 3
hue_colors(selector[name][1],selector[name][2],selector[name][3],4) -- light 2, hue id 4
hue_colors(selector[name][1],selector[name][2],selector[name][3],6) -- light 3, hue id 6
end
end
}
Re: Is there a way to set a Hue light color?
Posted: Sunday 11 March 2018 19:28
by kazze
Triton, thanks a lot!!! This was really helpful!!
Re: Is there a way to set a Hue light color?
Posted: Monday 12 March 2018 7:42
by dannybloe
Why don't you use the
RGB(W) functions built into dzVents? Also, if you do want to make http calls (curl), better use dzVents
openURL() commands as they are non-blocking. Using os.execute(curl) is a recipe for blocking errors.
Re: Is there a way to set a Hue light color?
Posted: Monday 12 March 2018 20:07
by Maxx
For me a reason (to try) to use openURL is a little project I have been working on to store the current value of the Hue lamp (in Hue native brightness, Saturation and hue reading from the json table). Then give the light another color and after a while use the stored values to send the previous color to the lamp.
Reading the values by using the OpenURL is working fine.
To send the stored values I tried to use the OpenURL command but sofar without succes. I tried a lot of ways to include the required parameters in the OpenURL command with POST and set the "postData"
Because my limited programming skill it involves a lot of trial and error, as soon as I have more time I will try it again.
A function like "ReadRGB" would be nice or some examples with OpenURL POST commands with parameters.
Re: Is there a way to set a Hue light color?
Posted: Monday 12 March 2018 21:04
by dannybloe
openURL is exactly like curl. It uses the curl libs inside domoticz. Perhaps you have to set the request header properly.