Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- %% properties
- 249 sceneActivation
- %% globals
- --]]
- local tasterID = 249
- local led = 122
- 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], 0)
- end
- function checkmax(value)
- if value > 255 then
- fibaro:call(122, "turnOff")
- fibaro:sleep(200)
- fibaro:call(122, "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(122, "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] + 10
- rgbw[0] = checkmax(rgbw[0])
- setcolor(rgbw)
- fibaro:sleep(200)
- end
- while tonumber(fibaro:getValue(tasterID, "sceneActivation")) == 23 do
- rgbw[1] = rgbw[1] + 10
- rgbw[1] = checkmax(rgbw[1])
- setcolor(rgbw)
- fibaro:sleep(200)
- end
- while tonumber(fibaro:getValue(tasterID, "sceneActivation")) == 33 do
- rgbw[2] = rgbw[2] + 10
- rgbw[2] = checkmax(rgbw[2])
- setcolor(rgbw)
- fibaro:sleep(200)
- end
- ---button 4 long = all off, short = all on ---
- if button == 41 or button == 42 then
- fibaro:call(led, "setColor", 255, 255, 255, 0)
- 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 or button == 12 then
- rgbw[0] = 0
- setcolor(rgbw)
- end
- if button == 21 or button == 22 then
- rgbw[1] = 0
- setcolor(rgbw)
- end
- if button == 31 or button == 32 then
- rgbw[2] = 0
- setcolor(rgbw)
- end
- fibaro:debug("ende")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement