Guest User

Untitled

a guest
Aug 29th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. --[[
  2. %% properties
  3. 734 sceneActivation
  4. %% globals
  5. --]]
  6.  
  7. local tasterID = 734
  8. --local led = 122
  9. local led = 445
  10. local steps = 15
  11.  
  12. function RgbToTable (string)
  13. rgbw = {0,0,0,0}
  14. rgbw[0],rgbw[1],rgbw[2],rgbw[3]= string.match(string, "(%d+),(%d+),(%d+),(%d+)")
  15. return rgbw
  16. end
  17.  
  18. function setcolor (rgbw)
  19. fibaro:call(led, "setColor", rgbw[0], rgbw[1], rgbw[2], rgbw[3])
  20. end
  21.  
  22. function checkmax(value)
  23. if value > 255 then
  24. fibaro:call(led, "turnOff")
  25. fibaro:sleep(200)
  26. fibaro:call(led, "turnOn")
  27. fibaro:sleep(200)
  28. value = 255
  29. end
  30. return value
  31. end
  32.  
  33. local button = tonumber(fibaro:getValue(tasterID, "sceneActivation"));
  34. fibaro:debug('es wurde gedrückt: '..button)
  35.  
  36. local color = fibaro:getValue(led, "color")
  37. local rgbw = RgbToTable(color)
  38.  
  39. ---while 1,2,3 long, dimm color up ---
  40. while tonumber(fibaro:getValue(tasterID, "sceneActivation")) == 13 do
  41. rgbw[0] = rgbw[0] + steps
  42. rgbw[0] = checkmax(rgbw[0])
  43. setcolor(rgbw)
  44. fibaro:sleep(200)
  45. end
  46. while tonumber(fibaro:getValue(tasterID, "sceneActivation")) == 23 do
  47. rgbw[1] = rgbw[1] + steps
  48. rgbw[1] = checkmax(rgbw[1])
  49. setcolor(rgbw)
  50. fibaro:sleep(200)
  51. end
  52. while tonumber(fibaro:getValue(tasterID, "sceneActivation")) == 33 do
  53. rgbw[2] = rgbw[2] + steps
  54. rgbw[2] = checkmax(rgbw[2])
  55. setcolor(rgbw)
  56. fibaro:sleep(200)
  57. end
  58. while tonumber(fibaro:getValue(tasterID, "sceneActivation")) == 43 do
  59. rgbw[3] = rgbw[3] + steps
  60. rgbw[3] = checkmax(rgbw[3])
  61. setcolor(rgbw)
  62. fibaro:sleep(200)
  63. end
  64.  
  65. ---button 4 long = all off, short = all on ---
  66. if button == 42 or button == 32 or button == 22 or button == 12 then
  67. fibaro:call(led, "setColor", 255, 255, 255, 255)
  68. end
  69. if button == 41 then
  70. if (rgbw[0] + rgbw[1] + rgbw[2] + rgbw[3]) > 0 then
  71. fibaro:call(led, "setColor", 0, 0, 0, 0)
  72. else
  73. fibaro:call(led, "setColor", 255, 255, 255, 255)
  74. end
  75.  
  76. end
  77. --if button == 43 or button == 45 then
  78. -- fibaro:call(led, "setColor", 0, 0, 0, 0)
  79. --end
  80.  
  81. -----reset color on button press 1=r 2=g 3=b-----
  82. if button == 11 then
  83. rgbw[0] = 0
  84. setcolor(rgbw)
  85. end
  86. if button == 21 then
  87. rgbw[1] = 0
  88. setcolor(rgbw)
  89. end
  90. if button == 31 then
  91. rgbw[2] = 0
  92. setcolor(rgbw)
  93. end
  94.  
  95. fibaro:debug("ende")
Add Comment
Please, Sign In to add comment