Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- %% properties
- 603 color
- 603 currentProgram
- %% globals
- --]]
- local fromID = 603; -- ID des setzenden RGBW-device (bitte auch 2x unter den properties ändern)
- local toID = 917; -- ID des zu syncenden RGBW-device
- local toID2 = 917; -- ID2 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'))
- fibaro:call(toID2, 'startProgram', fibaro:getValue(fromID, 'currentProgramID'))
- if (fibaro:getValue(fromID, 'currentProgramID') == '0') then
- fibaro:debug('ProgrammID = 0. Setze Farbe')
- setTheColour(toID, fibaro:getValue(fromID, 'color'));
- setTheColour(toID2, 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'));
- setTheColour(toID2, fibaro:getValue(fromID, 'color'));
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement