setRGB for Hue
Posted: Sunday 30 December 2018 21:15
I am struggling to get the actual status of my Hue lights in dzvents. I made a scripts based on a script of Waaren where I can store the actual value of the lights. I want to use this to detect if the lights are changed by an external source (like the philips app).
Somehow the value as stored in the "device.color table" does not seem reliable
this is the script:
The output is:
it shows both lights with the same rgb values, the problem is that the colors are different in reality. Is something wrong with my script?
I am not sure when the values are updated in the device.
Somehow the value as stored in the "device.color table" does not seem reliable
this is the script:
Code: Select all
-- Develop
return {
on = {
timer = {'every minute'},
},
data = { Color = { initial = {} },
RGBColors = { initial = {} },
},
logging = { level = domoticz.LOG_DEBUG,
marker = "Licht develop" },
execute = function(dz, item)
local AllLights = {37, 38}
local function colorTable2RGB(colorTable)
for k,v in pairs(colorTable) do
if k == "r" then
red = v
end
if k == "g" then
green = v
end
if k == "b" then
blue = v
end
end
return red, green, blue
end
local function checkAll()
for i, p in pairs(AllLights) do
dz.data.RGBColors = dz.utils.fromJSON(dz.devices(p).color)
local name = dz.devices(p).name
local Rood, Groen, Blauw = colorTable2RGB(dz.data.RGBColors)
dz.log(name)
dz.log('IDX is: ' .. p)
dz.log(dz.data.RGBColors)
dz.log('Rood is: ' .. Rood)
dz.log('Groen is: ' .. Groen)
dz.log('Blauw is: ' .. Blauw)
end
end
checkAll()
end
}Code: Select all
2018-12-30 21:07:00.417 Status: dzVents: Info: Licht develop: Eethoek_2
2018-12-30 21:07:00.417 Status: dzVents: Info: Licht develop: IDX is: 37
2018-12-30 21:07:00.417 Status: dzVents: Info: Licht develop: {["b"]=102, ["cw"]=0, ["g"]=202, ["ww"]=0, ["m"]=3, ["t"]=0, ["r"]=254}
2018-12-30 21:07:00.417 Status: dzVents: Info: Licht develop: Rood is: 254
2018-12-30 21:07:00.417 Status: dzVents: Info: Licht develop: Groen is: 202
2018-12-30 21:07:00.418 Status: dzVents: Info: Licht develop: Blauw is: 102
2018-12-30 21:07:00.418 Status: dzVents: Debug: Licht develop: Processing device-adapter for Eethoek_1: RGB(W) device adapter
2018-12-30 21:07:00.419 Status: dzVents: Debug: Licht develop: Processing device-adapter for Eethoek_1: Switch device adapter
2018-12-30 21:07:00.419 Status: dzVents: Info: Licht develop: Eethoek_1
2018-12-30 21:07:00.419 Status: dzVents: Info: Licht develop: IDX is: 38
2018-12-30 21:07:00.419 Status: dzVents: Info: Licht develop: {["b"]=102, ["cw"]=0, ["g"]=202, ["ww"]=0, ["m"]=3, ["t"]=0, ["r"]=254}
2018-12-30 21:07:00.419 Status: dzVents: Info: Licht develop: Rood is: 254
2018-12-30 21:07:00.419 Status: dzVents: Info: Licht develop: Groen is: 202
2018-12-30 21:07:00.419 Status: dzVents: Info: Licht develop: Blauw is: 102
2018-12-30 21:07:00.420 Status: dzVents: Info: Licht develop: ------ Finished Licht develop v0 I am not sure when the values are updated in the device.