Skip to content

Instantly share code, notes, and snippets.

@yoimbert
Last active February 20, 2017 21:30
Show Gist options
  • Save yoimbert/49ed5d5c77a1a0a0c3b4c4dbd6895389 to your computer and use it in GitHub Desktop.
Save yoimbert/49ed5d5c77a1a0a0c3b4c4dbd6895389 to your computer and use it in GitHub Desktop.
LedDuo HC2 Fibaro
-- Click Add scene from the menu on the left.
-- Give you scene a name and select the room it applies to.
-- Since this scene will only be run automatically, change the Show the scene in interfaces? box to No.
-- Click the Advanced tab.
-- Select the second Save button – in the Lua section.
-- Type in the code above. (Hint: You can double click the code and cut and paste it in).
-- Change the device ID on lines 3, 4 and 8 from 81 to the ID of the master RGBW controller.
-- Change the device ID on line 9 to the ID of the slave RGBW controller.
-- Click the blue save button on the right side popup menu.
-- http://www.fibarouk.co.uk/synchronising-rgbw-modules/
-- 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.
--[[
%% properties
-- ID RGBW Master
81 currentProgramID
81 color
%% globals
--]]
-- ID RGBW Master
local fromID = 81
-- ID RGBW Slave
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment