HUE/JSON Color

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

Moderator: leecollings

Post Reply
Lachris
Posts: 7
Joined: Tuesday 31 May 2016 12:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

HUE/JSON Color

Post by Lachris »

Hello,

Im very new to all this Domoticz, Im looking for getting a HUE bulb showing a specific color in dzVents
From the domoticz Log i get a setcolbrightnessvalue, when I set the color I want under Switches:

Status: setcolbrightnessvalue: ID: 1de, bri: 100, color: '{m: 2, RGB: 000000, CWWW: 6b94, CT: 148}'

I found this under:
API/JSONURL
Specify Domoticz JSON color object and brightness
Example: Specify color mode with a dim blue color
/json.htm?type=command&param=setcolbrightnessvalue&idx=130&color={"m":3,"t":0,"r":0,"g":0,"b":50,"cw":0,"ww":0}&brightness=100

SO:
m should be set to: 2
r+g+b: 0?

How to replicate that color?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: HUE/JSON Color

Post by waaren »

Lachris wrote: Saturday 08 September 2018 7:26 ..
I am looking for getting a HUE bulb showing a specific color in dzVents
What about according to the dzVents wiki ?

Code: Select all

light = domoticz.devices("your RGBW devicename") 
light.setRGB( red, green, blue ) 
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Lachris
Posts: 7
Joined: Tuesday 31 May 2016 12:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: HUE/JSON Color

Post by Lachris »

But is it possible to make the setcolbrightnessvalue as I wrote with RGB?

I guess it only works with color and not white ambiance??
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: HUE/JSON Color

Post by waaren »

I am not 100% sure but I don't think this is already implemented as a native dzVents method for the RGBWW devices. @dannybloe ?

If not yet implemented, you can use this.

Code: Select all

return {
    on         = { devices     = { "triggerDevice" }},       

    logging    = { level       =   domoticz.LOG_DEBUG, 
                   marker      =   "setcolbrightnessvalue" }, 
                   
    execute = function(dz)
       local colorTable     = {}               -- define and populate the colorTable
       colorTable.m         = 2                -- ColorMode         [0 .. 4]
       colorTable.t         = 0                -- Color temperature [0 .. 255]
       colorTable.r         = 0                -- red level         [0 .. 255]   
       colorTable.g         = 0                -- greenlevel        [0 .. 255]   
       colorTable.b         = 0                -- blue level        [0 .. 255]   
       colorTable.cw        = 0                -- Cold white level  [0 .. 255]
       colorTable.ww        = 0                -- Warm white level  [0 .. 255]
       
       local brightness     = 97               -- Brightness        [0 .. 100] 
       local deviceIDX      = 157              -- your RGBWW device IDX
       
       local colorString    = "{"              -- transform table contents into formatted string 
       for k,v in pairs(colorTable) do 
            colorString = colorString .. '"' .. k .. '":' .. v .. "," 
       end
       colorString = colorString:sub(1, -2) .. "}"  -- Remove last , and add }
       
       local url            = dz.settings["Domoticz url"] ..      -- prepare url 
                              "/json.htm?type=command&param=setcolbrightnessvalue&idx=" .. deviceIDX ..
                              "&color=" .. colorString ..
                              "&brightness=" .. brightness
       dz.log("colorTable: ".. colorString,dz.LOG_DEBUG)
       dz.openURL(url)                               
     end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest