RGBW-Sync

Anbei ein Skript zum syncen von RGBW-Modulen. (Funktioniert nun auch bei Programmen)

--[[
%% properties
33 color
33 currentProgram
%% globals
--]]
 
local fromID = 33; <- ID des setzenden RGBW-device (bitte auch 2x unter den properties ändern)
local toID = 26; <- ID des zu syncenden RGBW-device
 
-- Allows us to set the colour from a string like 'r,g,b,w'
function setTheColour (deviceID, colourString)
  local RGBWTable= {}
  local i = 1
 
  for value in string.gmatch(colourString,"(%d+)") do
    RGBWTable[i] = value
    i = i + 1
  end
 
  fibaro:call(deviceID, "setColor", RGBWTable[1], RGBWTable[2], RGBWTable[3], RGBWTable[4])
end
 
local trigger = fibaro:getSourceTrigger()
if (trigger['type'] == 'property') then
  if (trigger['propertyName'] == 'currentProgram') then
    fibaro:debug('RGBW-Programm gestartet. Sync')
    fibaro:call(toID, 'startProgram', fibaro:getValue(fromID, 'currentProgramID'))
    if (fibaro:getValue(fromID, 'currentProgramID') == '0') then
      fibaro:debug('ProgrammID = 0. Setze Farbe')
      setTheColour(toID, fibaro:getValue(fromID, 'color'));
    end
  elseif (trigger['propertyName'] == 'color') then
    if (fibaro:getValue(fromID, 'currentProgramID') == '0') then
      fibaro:debug('Color gesetzt. Sync')
      setTheColour(toID, fibaro:getValue(fromID, 'color'));
    end
  end
end

Merci.
Funktioniert super. Echt klasse

Grüße
gringo

Haut perfekt hin, Daniel! :slight_smile:

Vielen Dank.

Gruß

Christian