LUA: Fibaro Button

LUA: Fibaro Button

Since it is very simple to set the Fibaro Button in the Fibaro control units (either HC2 or HCL) using the so-called Magic Scenes, in this short blog we will show you how to use the LUA language and the Fibaro Button together.

If you prefer the LUA scripting language, this short manual is for you.

How to add the Fibaro Button into HC2?

  • Demount the Fibaro Button, turning it counterclockwise, and remove the piece of paper.
  • In the HC2 control unit set the Learning mode to add the device (Inclusion).
  • Push the Fibaro button 6x in a row.
  • Wait until the process is completed - then the icon of the Fibaro Button device is displayed in the Fibaro web interface.

Creating a LUA scene

  • In the Fibaro HC2 web interface select the Scenes section.
  • Then Add the scene.
  • Add the scene in LUA.
  • Enter the code mentioned below (you can modify it according to your needs and requirements).
  • Name the scene and save it.

LUA: Script

--[[
%% properties
%% events
1329 CentralSceneEvent
%% globals
--]]

-- 1329 ID vasho Fibaro Button zariadenia

local button_source = fibaro:getSourceTrigger()["event"]["data"]

if (tostring(button_source["keyAttribute"]) == "Pressed") then
  	fibaro:debug('Fibaro Button bolo 1x stlačené.')
        -- po odkomentovani sa spusti scena s ID 11 (ID sceny zmente)	
        --fibaro:startScene(11)
elseif (tostring(button_source["keyAttribute"]) == "Pressed2") then
  	fibaro:debug('Fibaro Button bolo 2x stlačené.')
        --fibaro:startScene(12)
elseif (tostring(button_source["keyAttribute"]) == "Pressed3") then
  	fibaro:debug('Fibaro Button bolo 3x stlačené.')
        --fibaro:startScene(13)
elseif (tostring(button_source["keyAttribute"]) == "Pressed4") then
  	fibaro:debug('Fibaro Button bolo 4x stlačené.')
        --fibaro:startScene(14)
elseif (tostring(button_source["keyAttribute"]) == "Pressed5") then
  	fibaro:debug('Fibaro Button bolo 5x stlačené.')
        --fibaro:startScene(15)
elseif (tostring(button_source["keyAttribute"]) == "HeldDown") then
  	fibaro:debug('Fibaro Button bolo podržané.')
        --fibaro:startScene(16)
end

How to remove the Fibaro Button from the HC2 network?

  • In the HC2 control unit set the Learning mode to remove the device (Exclusion).
  • Push the Fibaro button 6x in a row.
  • Wait until the process is completed.

Leave a CommentLeave a Reply

Blog search

Latest Comments

Recently Viewed

No products

Menu

Compare 0