Synchronising RGBW modules


Fibaro's RGBW Controllers allow you to set the colour of RGB or RGBW LED strip or run preconfigured colour changing programs. If you have several RGBW devices and want to synchronise them, you can use Lua on the Home Center 2.


WHAT DO I NEED TO DO


The Fibaro RGBW module has the ability to show a set colour, or to run through a sequence of colours defined in 'programs'. (It can of course be off too). We need to detect when one RGBW controller changes either of its color or currentProgramID properties. When they change, the new values need to be repeated to the other RGBW devices. We also need to watch out for two pitfalls:

  1. When a program is turned off, the currentProgramID property is set to 0. However, calling startProgram with a value of 0 will not have any effect on the RGBW controller. In order to turn off a running program you need to use setColor and either set it to a particular colour or 0,0,0,0 for off.
  2. When the program on the RGBW controller changes, the color property gets set to 0,0,0,0. As such we only want to react to a change in the color property when the currentProgramID property is 0 otherwise we will turn off the program as soon as we turn it on.


WHAT WILL I NEED?


Two Fibaro RGBW Controllers – we will keep an eye on one of them, and if it changes, duplicate the changes onto the second one.

A Fibaro Home Center 2 – you need to use Lua which is only available on this Fibaro device.


LET'S GO!


To get the two devices talking, you will need to create the following scene:


--[[
%% properties
81 currentProgramID
81 color
%% globals
--]]

local fromID = 81
local toID = 402

-- 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'] == 'currentProgramID') then
fibaro:call(toID, 'startProgram', fibaro:getValue(fromID, 'currentProgramID'))
if (fibaro:getValue(fromID, 'currentProgramID') == '0') then
setTheColour(toID, fibaro:getValue(fromID, 'color'))
end
elseif (trigger['propertyName'] == 'color') then
if (fibaro:getValue(fromID, 'currentProgramID') == '0') then
setTheColour(toID, fibaro:getValue(fromID, 'color'))
end
end
end

  1. Click Scenes on the top menu.
  2. Click Add scene from the menu on the left.
  3. Give you scene a name and select the room it applies to.
  4. Since this scene will only be run automatically, change the Show the scene in interfaces? box to No.
  5. Click the Advanced tab.
  6. Select the second Save button – in the Lua section.
  7. Type in the code above. (Hint: You can double click the code and cut and paste it in).
  8. Change the device ID on lines 3, 4 and 8 from 81 to the ID of the master RGBW controller.
  9. Change the device ID on line 9 to the ID of the slave RGBW controller.
  10. Click the blue save button on the right side popup menu.


WHERE NOW?


Your two RGBW controllers can now both be controlled from the master RGBW controller. If you want to control more than one slave device, just duplicate lines 9, 27, 29 and 33 and change the variable name from toID to something else. For more information on Lua, see our support page at http://www.fibarouk.co.uk/support/lua/