hi,
ich hab das nicht mit den Philips Hue umgesetzt sondern mit einem RGBW Modul und einem Wandschalter mti 4 Tasten. Vielleicht hilft dir das:
--[[
%% properties
734 sceneActivation
%% globals
--]]
local tasterID = 734
--local led = 122
local led = 445
local steps = 15
function RgbToTable (string)
rgbw = {0,0,0,0}
rgbw[0],rgbw[1],rgbw[2],rgbw[3]= string.match(string, "(%d+),(%d+),(%d+),(%d+)")
return rgbw
end
function setcolor (rgbw)
fibaro:call(led, "setColor", rgbw[0], rgbw[1], rgbw[2], rgbw[3])
end
function checkmax(value)
if value > 255 then
fibaro:call(led, "turnOff")
fibaro:sleep(200)
fibaro:call(led, "turnOn")
fibaro:sleep(200)
value = 255
end
return value
end
local button = tonumber(fibaro:getValue(tasterID, "sceneActivation"));
fibaro:debug('es wurde gedrückt: '..button)
local color = fibaro:getValue(led, "color")
local rgbw = RgbToTable(color)
---while 1,2,3 long, dimm color up ---
while tonumber(fibaro:getValue(tasterID, "sceneActivation")) == 13 do
rgbw[0] = rgbw[0] + steps
rgbw[0] = checkmax(rgbw[0])
setcolor(rgbw)
fibaro:sleep(200)
end
while tonumber(fibaro:getValue(tasterID, "sceneActivation")) == 23 do
rgbw[1] = rgbw[1] + steps
rgbw[1] = checkmax(rgbw[1])
setcolor(rgbw)
fibaro:sleep(200)
end
while tonumber(fibaro:getValue(tasterID, "sceneActivation")) == 33 do
rgbw[2] = rgbw[2] + steps
rgbw[2] = checkmax(rgbw[2])
setcolor(rgbw)
fibaro:sleep(200)
end
while tonumber(fibaro:getValue(tasterID, "sceneActivation")) == 43 do
rgbw[3] = rgbw[3] + steps
rgbw[3] = checkmax(rgbw[3])
setcolor(rgbw)
fibaro:sleep(200)
end
---button 4 long = all off, short = all on ---
if button == 42 or button == 32 or button == 22 or button == 12 then
fibaro:call(led, "setColor", 255, 255, 255, 255)
end
if button == 41 then
if (rgbw[0] + rgbw[1] + rgbw[2] + rgbw[3]) > 0 then
fibaro:call(led, "setColor", 0, 0, 0, 0)
else
fibaro:call(led, "setColor", 255, 255, 255, 255)
end
end
--if button == 43 or button == 45 then
-- fibaro:call(led, "setColor", 0, 0, 0, 0)
--end
-----reset color on button press 1=r 2=g 3=b-----
if button == 11 then
rgbw[0] = 0
setcolor(rgbw)
end
if button == 21 then
rgbw[1] = 0
setcolor(rgbw)
end
if button == 31 then
rgbw[2] = 0
setcolor(rgbw)
end
fibaro:debug("ende")