Is there a way to set a Hue light color?

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
rizzah
Posts: 75
Joined: Monday 17 October 2016 16:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Groningen
Contact:

Is there a way to set a Hue light color?

Post 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.
febalci
Posts: 331
Joined: Monday 03 July 2017 19:58
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Is there a way to set a Hue light color?

Post 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.
AmySoto
Posts: 1
Joined: Monday 20 November 2017 9:52
Target OS: Linux
Domoticz version:
Location: Daytona Beach
Contact:

Re: Is there a way to set a Hue light color?

Post by AmySoto »

Thanks a lot for the suggestions)
Get our best essay writing help fast and cheap!
Kerel
Posts: 28
Joined: Friday 02 December 2016 8:38
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Is there a way to set a Hue light color?

Post 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.
rizzah
Posts: 75
Joined: Monday 17 October 2016 16:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Groningen
Contact:

Re: Is there a way to set a Hue light color?

Post by rizzah »

Alright, good tips!

Thanks.
rizzah
Posts: 75
Joined: Monday 17 October 2016 16:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Groningen
Contact:

Re: Is there a way to set a Hue light color?

Post by rizzah »

@febalci

Would you mind sharing your whole curl syntax?
rizzah
Posts: 75
Joined: Monday 17 October 2016 16:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Groningen
Contact:

Re: Is there a way to set a Hue light color?

Post 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&param=setcolbrightnessvalue&idx=149&hue=86&brightness=200&iswhite=false
Amsterdam020
Posts: 55
Joined: Saturday 05 March 2016 21:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5629
Contact:

Re: Is there a way to set a Hue light color?

Post 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&param=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


Rp3, youlesss, rfxcom, philips hue, dsb1820
febalci
Posts: 331
Joined: Monday 03 July 2017 19:58
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Is there a way to set a Hue light color?

Post 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.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Is there a way to set a Hue light color?

Post by dannybloe »

In the next version of dzVents 2.4 you can do myLight.setRGB(124, 233, 11)
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Is there a way to set a Hue light color?

Post 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 ]
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
triton
Posts: 15
Joined: Monday 03 April 2017 15:01
Target OS: Linux
Domoticz version: 4.9701
Location: Netherlands
Contact:

Re: Is there a way to set a Hue light color?

Post 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.
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Is there a way to set a Hue light color?

Post 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?
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
triton
Posts: 15
Joined: Monday 03 April 2017 15:01
Target OS: Linux
Domoticz version: 4.9701
Location: Netherlands
Contact:

Re: Is there a way to set a Hue light color?

Post 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
}
kazze
Posts: 3
Joined: Tuesday 02 January 2018 9:54
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Is there a way to set a Hue light color?

Post by kazze »

Triton, thanks a lot!!! This was really helpful!!
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Is there a way to set a Hue light color?

Post 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.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Maxx
Posts: 58
Joined: Saturday 27 January 2018 20:59
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Is there a way to set a Hue light color?

Post 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.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Is there a way to set a Hue light color?

Post by dannybloe »

openURL is exactly like curl. It uses the curl libs inside domoticz. Perhaps you have to set the request header properly.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest