Categoriearchief: FIBARO Blog

Hier vindt u onze ervaringen met het Fibaro Home Center 2 systeem.

Geofencing with IFTTT on Fibaro


  • IFTTT account with IFTTT App installed on iphone (Not yet tested with Android).
  • Fibaro controller available through port-forwarding
  1. Create Global Variable for User with 2 possible values (aanwezig(=present) and afwezig(=away) or choose your own.
  2. Create virtual Device with 2 buttons

    Choose 2 buttons, choose toevoegen (add)

    Change icons (if you want, available on Gateway Pictures).
    Change buttons from String to LUA Code
    Add Lua Code:fibaro:setGlobal(“Bram”,”Aanwezig”);
    This will only set the Global variable “Bram to either “Afwezig” or “Aanwezig” (or “Present” and “Away” if you prefer).
    If you want to call a scene directly from this you can add:
    fibaro:startScene (<nr of scene you want to start>);
  3. Save Virtual Device
  4. Create a user on fibaro with access to only the just created virtual device.
  5. Create New Applet in IFTTT:
  6. Search for Location:
  7. Select Location:

    Adjust the location to your liking, do not make the range too small, so IFTTT has time to react.
    Click “Create trigger”.
  8. Now we provide the action:
    Click “that”:
  9. Search for webhooks:

    Click “Webhooks”.
  10. Click “Webrequest”:
  11. Fill in all the fields as follows:

    URL = http://<user>:<Password>@<IPADRESS>:<PORT>/api/callAction?deviceID=<DeviceID>&name=pressButton&arg1=<Buttonnr>
    <user> is the user created in step 4
    <Password> the password of the above user
    <IPADRESS> the external ipadress of the Fibaro controller
    <PORT> the port the Fibaro can be reached on (through portforwarding)
    <DeviceID> the DeviceID of the virtual device created in steps 2 & 3
    <Buttonnr> the Nr of the button to be activated (First button =1, etc)Set Method to “Get”

    Set content Type to “text/plain”.

    Select “Create Action”.

  12. Select Finish.
    If you do not want to be notified each time the applet runs, turn off notifications
  13. Your done!
    Each time you enter the specified area, IFTTT when it detects this, will send a request to the Fibaro controller, pressing the specified button on the virtual device.
    You can of course expand this with exiting an area, etc..
    Have Fun!

Using the Aeon Labs keyfob in Scene Modus on Home Center 2

HC2 Firmware: 4.017 beta

When adding the Aeon Labs Keyfob to the current (beta) firmware can be a bit of a challange. First of all it is difficult to setup the device correctly, and some times, the device won’t function in scene modus.

Inclusion of the device

First let us include the device:

  1. Make sure the keyfob is in management modus (you can easilty check this by pressing button 3. In management modus, it won’t react and no LED will light).
  2. Choose add device on  HC2 to add a new Z-Wave device;
  3. Press button 4 (Learn) just once;
  4. If the HC2 seems to “hang” (no reaction after one minute) stop the proces and try adding it again with one press of the Learn button on the back.

Now switch the mode from management to scene by pressing the mode button once (also located at the back). The switch will be confirmed by a green LED for 2 seconds.

Scene mode

If everything went ok, your device should now be working in scene mode. You can check this also visually by pressing one of the buttons on top. If a green LED will light up, you’re ok and can skip the next step.

If a red LED lights up, you have to set a variable to let the keyfob function in scene mode:

  • Parameter 250 with value 1. This enables scene mode.
  • Wakeup the device by pressing the Learn button on the back for 2 seconds.
Set Parameter 250 to value 1

 Keyfob Lua Scene

Now its time to define a scene to “catch” the scene ID’s sent by the remote controller.

Create a LUA based scene by selecting “Add scene in LUA”.  Copy the following lines of code and adjust where needed (put the ID from your keyfob here).

You can test the scene by selecting Start and pressing one of the buttons on the keyfob.

%% properties 
18 sceneActivation 
%% globals 

local ButtonPressed = fibaro:getValue(18, "sceneActivation") 

if ( tonumber(ButtonPressed) == 1) then 
  fibaro:debug("Keyfob button 1 pressed") 
elseif ( tonumber(ButtonPressed) == 2) then 
  fibaro:debug("Keyfob button 2 pressed") 
elseif ( tonumber(ButtonPressed) == 3) then 
  fibaro:debug("Keyfob button 3 pressed") 
elseif ( tonumber(ButtonPressed) == 4) then 
  fibaro:debug("Keyfob button 4 pressed") 
elseif ( tonumber(ButtonPressed) == 5) then 
  fibaro:debug("Keyfob button 5 pressed") 
elseif ( tonumber(ButtonPressed) == 6) then 
  fibaro:debug("Keyfob button 6 pressed") 
elseif ( tonumber(ButtonPressed) == 7) then 
  fibaro:debug("Keyfob button 7 pressed") 
elseif ( tonumber(ButtonPressed) == 8) then 
  fibaro:debug("Keyfob button 8 pressed") 
  fibaro:debug("No response") 

Adding a daytime variable to Fibaro HC

When you are programming your scenes within Fibaro HC 2 or Lite, you may probably wanted to know what part of day it is (i.e. to turn on a light when no light detector is available).

Within Fibaro it is quite easy to define variables. These can be used throughout the scenes and makes it possible to react on certain times or situations.

Adding a predefined variable

Adding a predefined variable is pretty straight forward and can be done in the panels section.

Add a predefined variable
Add a predefined variable

When done, save and close the panel. Don’t forget to initially set the variable to the correct part of day.

Create scenes

To actually change the variable, we need to create scenes. In our case we have defined two possible situations, i.e. ‘after sunrise‘ and ‘after sunset’.

Make sure to check the box “Start when Home Center 2/Lite starts”. After creating the scenes, the variable will be updated corresponding the part of day.

An working example

In our situation we created a real live situation, which works pretty well in our case.

As we don’t have a light detection at a certain section within the house, or if we don’t want to do direct association, we turn on the light when our variable holds the value “After sunset” and a trigger is breached:

Turn on a light when daypart is "After sunset"
Turn on a light when daypart is “After sunset”


Adding the Vision Siren to Fibaro Home Center 2

When you add the Vision sirene to Fibaro Home Center, it will be marked as an On/Off switch. The controlled device is “Other Device”, which makes the sirene somewhat unusuable, as this will result in no sirene when an alarm occurs.

There are two versions of the Vision sirene. One works on batteries, the other one accepts chargers voltage DC 12V – 39V or AC 9V – 28V, which leaves a wide choice. We choose a charger with 12V DC.

Installation of the module is quite easy. Just remove the white plate and remove the small black jumper located near the large capacitor and put it back into the position where two pin heads are covered.

Inclusion in Fibaro HC2

Now on to the inclusion in the Home Center 2.  As with any new module, go to the Devices tab, and then add a new device. After succesfull inclusion there will be a new ON/OFF device. As you will see, the producer is unknown and the controlled device is marked as “Other Device”.

Vision added to Fibaro HC2
Vision added to Fibaro HC2

After replacing the default icon, we change the controlled device to “Lightning”. This is necessary to use the built-in alarm panel from Fibaro. Your device will look like this:

Change icon and controlled device
Change icon and controlled device

Fibaro Alarm Panel

Now its time to configure the Fibaro Alarm Panel. As we changed the controlled device above to lightning, you can pick the “Vision Sirene” in the “PANIC” alarm scene.

Now the sirene is part of the elements to be activated on alarm. It will sound an alarm when a detection is made or another Panic situation occurs. It would be nice to stop it at any given time (also during the alarm). This is optional, as you can set the duration of the alarm with the configuration parameters (listed below). You can use a scene for this, and configure it to turn off with a pincode. You can always access this scene and turn it off in case of a false trigger.

Parameter Settings

If you do not make any scenes the siren will (by default) sound for 30 seconds. Parameter  0:

  • 0 = Flash Siren and active (default)
  • 1 = Siren only
  • 2 = Flash only

Parameter 1: 

  • 0 = 30 seconds (default)
  • 1 = 60 seconds
  • 2 = 120 seconds
  • 3 = don’t stop

Using the Keyfob with Home Center

Adding the Zwave.Me Keyfob (2) to the Home Center 2 is not that easy. For a reference I added this as a post, so when you follow the steps below,  it is possible to add and activate scenes with the keyfob.

Let’s start with including the device into Home Center:

  1. Press and hold down all 4 buttons together for at least 5 seconds; the green light should be blinking;
  2. Put your Fibaro Home Center in association / learning mode;
  3. Press button 3 onetime for inclusion / exclusion of the keyfob;
  4. When home center asks for you to wake up the device, repeat steps 1 and 2, but press button 2 this time (this will wake up the device which is the home center watiing for).

That should do it! Now it’s time to define some parameters for the keyfob to function correctly. You should do this yourself. Go to your newly added device and click on the advanced tab. The configuration looks like this: Keyfob Parameters Keyfob Parameters

Click save and do the wakeup procedure again for the parameters to be set directly (or do you wanna wait? :))

Scene Activation

For everything to work you should create a new scene. Make it active by default and not visible in the interface. Here is some example code which you can refer to:

%% properties 
131 sceneActivation 
%% globals 
local ButtonPressed = fibaro:getValue(131, "sceneActivation"); 
if ( tonumber(ButtonPressed) == 11) then 
fibaro:debug("Keyfob button 1 pressed")
elseif ( tonumber(ButtonPressed) == 21) then 
fibaro:debug("Keyfob button 2 pressed") 
elseif ( tonumber(ButtonPressed) == 12) then 
fibaro:debug("Keyfob button 3 pressed") 
elseif ( tonumber(ButtonPressed) == 22) then 
fibaro:debug("Keyfob button 4 pressed")
fibaro:debug("No response") 

You need to change the id to your keyfob id (number 131, 2 times).

Create some scenes and attach them to the keyfob. Now its time to test!

Creating a remote control for Samsung Smart TV

In this post I show you how you can control a Samsung Smart TV (model 2010, type UE4700) with Fibaro Home Center 2. Most Samsung TV’s will work with the TCP protocol and are able to receive commands. The following list represents the commands which may be sent to the TV:

# Key Reference # Normal remote keys
 #KEY_W_LINK #Media P
 #KEY_RSS #Internet
 #KEY_MTS #Dual
# Bonus buttons not on the normal remote:
There are also some commands which don’t work:
#Don't work/wrong codes:
Now that we now the commands we can program a remote control.
For a reference I created a remote control which looks likes the original one.
First start with creating the virtual device, in my case Samsung TV.
Fill in the ip address of the TV and port 55000.
If you need extra controls, it’s as easy as creating a new button and use the
following Lua code:
-- <configuration> -- 
tvIpAddress = "" 
tvPort = 55000 
keycodestring = "KEY_POWEROFF" 

tvAuthString = string.char(0x00,0x14,0x00,0x69,0x70,0x68,0x6f,0x6e,0x65,0x2e,0x2e,0x69,0x61,0x70,0x70,0x2e,0x73,0x61,0x6d,0x73,0x75,0x6e,0x67,0x38,0x00,0x64,0x00,0x14,0x00,0x4d,0x54,0x6b,0x79,0x4c,0x6a,0x45,0x32,0x4f,0x43,0x34,0x77,0x4c,0x6a,0x45,0x78,0x4d,0x41,0x3d,0x3d,0x18,0x00,0x4e,0x45,0x4d,0x74,0x4e,0x7a,0x49,0x74,0x51,0x6a,0x6b,0x74,0x4e,0x44,0x4d,0x74,0x4d,0x6a,0x51,0x74,0x4f,0x45,0x49,0x3d,0x04,0x00,0x54,0x51,0x3d,0x3d)
-- </configuration> -- 

-- character table string 
local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' 

-- encoding to base64 
function enc(data) 
    return ((data:gsub('.', function(x) 
        local r,b='',x:byte() 
        for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end 
        return r; 
    end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x) 
        if (#x < 6) then return '' end 
        local c=0 
        for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end 
        return b:sub(c+1,c+1) 
    end)..({ '', '==', '=' })[#data%3+1]) 

-- helper function 
function num2bytes(num)    
    local retStr="" 
    for i=1,2 do 
        retStr = retStr .. string.char(num%256) 
        num = math.floor(num/256) 
      return retStr 

tcpSocket = Net.FTcpSocket(tvIpAddress, tvPort) 

-- say hello to the TV ;) 
bytes, errorCode = tcpSocket:write(tvAuthString) 

keycodebase = string.char(0x00,0x13,0x00,0x69,0x70,0x68,0x6f,0x6e,0x65,0x2e,0x69,0x61,0x70,0x70,0x2e,0x73,0x61,0x6d,0x73,0x75,0x6e,0x67) 

-- payload 
payloadinit = string.char(0x00,0x00,0x00) 
keycode = enc(keycodestring) 

keycodesize = num2bytes(string.len(keycode)) 

payloadsize = num2bytes(string.len(payloadinit .. keycode ..keycodesize)) 

-- combining the message 
message = keycodebase .. payloadsize .. payloadinit .. keycodesize .. keycode 

-- sending keycode 
bytes, errorCode2 = tcpSocket:write(message) 

if errorCode == 0 and errorCode2 == 0 
  -- printing log under virtual device 
  fibaro:log("transfer OK: " .. keycodestring) 
  fibaro:log("transfer failed") 

Note the –configuration — part of the Lua code above. The key part is the only thing which needs to be changed for each button / slider.

Using my minimote to arm and disarm motion detectors

The purpose of this post is to use virtual devices for arming and disarming my motion sensors. Previously I succeeded in adding the video camera’s, see also Adding Foscam like camera’s to Fibaro HC2. The minimote is also already added by the gateway, see Using my minimote with Fibaro Home Center.

The minimote is programmed in such a way that it is capable of starting scenes. See for a working example the post mentioned earlier.

Starting a scene which arm or disarm the motion sensors is pretty straightforward. First introduce a variable which holds the status of the sensors (in this case “alarm_ingeschakeld” – which holds a true (1) or false (0) value for the status armed).

Minimote - Armed Variable
Minimote – Armed Variable

After that create an Armed scene, which holds the following script (note the variable):

and for disarming the sensors (within the Disarm Scene):

Note: in the (working) example above, only my four foscam camera’s are armed. Eventually all other (motion-based) sensors can be armed or disarmed in the scenes above. 

Statistics on my NAS with the help of Fibaro HC2

As beautifull as fibaro home center 2 is with displaying usage statistics, it also lacks the possibility to easily see e.g. weather, temperature and other humidity values or statistics.

This blog contains a way of archiving statistics from the Fibaro Home Center, saving them within a mysql database and presenting them on my own webserver.  Sounds easy, right?

It is actually. The tools used to achieve this are:

  1. NAS Server with the following packages installed/configured
    • PHP
    • MySQL
    • Apache
  2. Fibaro Home Center 2
  3. Forum:

First of all we create a virtual device with 3 buttons:

  1. Temperature & Humidity
  2. Temperature & Weather
  3. Consumption for all supported devices (also includes declared energy values)

Each button gets its own piece of code for uploading the reported values to my NAS.

Uploading temperature & humidity values;
local updatechart = Net.FHttp("") 
local deviceType = "temperature_sensor" 
local deviceType2 = "humidity_sensor" 
local i = 0 
local maxNodeID = 250
for i = 0, maxNodeID do
 local type = fibaro:getType (i);
 x , y = string.find (type, deviceType) or string.find (type, deviceType2) 
 if x ~= nill then 
   local deviceName = fibaro:getName(i) 
   local deviceValue = fibaro:getValue(i, "value") 
   deviceName = string.gsub(deviceName, "%s+", "%%20");
   payload = "/fibaro-stats/data_post.php?type=" .. type .. "&name=" .. deviceName .. "&value=" .. deviceValue.. "&id=" .. i 
   response, status, errorCode = updatechart:GET(payload) 
fibaro:log('devices uploaded');
Note: my NAS is located at IP If the number of devices succeed 250, you may need to adjust maxNodeID.
Statistics - Button1
Statistics – Button1
Uploading temperature & weather values;
local updatechart = Net.FHttp("") 
local deviceName = fibaro:getName(3) 
local data0 = tonumber(fibaro:getValue(3, "Temperature")) 
local data1 = tonumber(fibaro:getValue(3, "Humidity"))

payload = "/fibaro-stats/data_post.php?type=temperature_sensor&name=" .. deviceName .. "&value=".. data0.. "&id=900" 
response, status, errorCode = updatechart:GET(payload) 
payload = "/fibaro-stats/data_post.php?type=humidity_sensor&name=" .. deviceName .. "&value=".. data1.. "&id=901" 
response, status, errorCode = updatechart:GET(payload)

fibaro:log("Weather uploaded");
Note: my NAS is located at IP If the number of devices succeed 250, you may need to adjust maxNodeID.
Statistics - Button2
Statistics – Button2
Uploading consumption for all supported devices;
local updatechart = Net.FHttp("") 
local deviceUnit = "W" 
local i = 0 
local maxNodeID = 250

for i = 0, maxNodeID do 
  local type = fibaro:get(i, 'unitSensor'); 
  local type2 = fibaro:get(i, 'unit'); 
  local deviceValue = "" 
  x , y = string.find (type, deviceUnit) or string.find (type2, deviceUnit) 

  if x ~= nill or y ~= nill then 
    local deviceName = fibaro:getName(i); 
    if fibaro:getType (i) == "multi_level_sensor" then 
      deviceValue = fibaro:getValue(i, "value") 
      deviceValue = fibaro:getValue(i, "valueSensor") 
    deviceName = string.gsub(deviceName, "%s+", "%%20");
    payload = "/fibaro-stats/data_post.php?type=consommation&name=" .. deviceName .. "&value=" .. deviceValue.. "&id=".. i 
    response, status, errorCode = updatechart:GET(payload);
fibaro:log('Devices uploaded');
Note: my NAS is located at IP If the number of devices succeed 250, you may need to adjust maxNodeID.
Statistics - Button3
Statistics – Button3

Create a scene which runs every minute and launches button 1, 2 and 3:

%% properties 
%% autostart 
%% globals 
while true do 
  fibaro:call(61, "pressButton", "1"); 
  fibaro:call(61, "pressButton", "2"); 
  fibaro:call(61, "pressButton", "3"); 

Configuring my NAS

Now its time to configure my Qnap NAS. I already have a webserver running. (Almost) every nas has the possibility to become a webserver. So will yours probably.

On your webserver website location (in my case /share/Web) upload and extract the following file: fibaro-stats (all with big thanks to byackee – see forum) in a map called e.g. fibaro-stats.

Create a table (e.g. fibaro-stats) within MySQL and define access rights for a new user. I personally don’t want to interrupt my other databases so I made a seperate user here, called fibaro with the password test (needs to be configured for your own needs).

After this you may import the following file: HighStock (extract first, then import).

Last thing to do is to configure the file with your previous values and you’re set to go!

$host = "localhost";
$login = "fibaro";
$password = "test";
$table = "fibaro-stats";

Using my minimote with Fibaro Home Center

For some time now I have a minimote at home. This is a kind of keyfob device, capable of sending 8 different scenes to the gateway controller. The manufacturer is Aeon Labs.

Previously I succeeded in adding the device to Fibaro. But after that nothing happened, i.e. no paramters could be applied, etc to control the device.

After some digging around on Internet I found the following solution. It may look pretty difficult, but it is in fact straight forward. First we make sure the device is recognized correctly, this means it looks like the following picture:

Minimote - Setup
Minimote – Setup

As the device has no parameters there is nothing to configure on the advanced tab. Proceed with adding a new scene, in my case I called it also Minimote (make sure you activate the scene):

Minimote - Scene
Minimote – Scene

The magic happens in the processing of the scene. Here is the code:

 %% properties
 52 sceneActivation
 %% globals
local ButtonPressed = fibaro:getValue(52, "sceneActivation")
if ( tonumber(ButtonPressed) == 1) then
 fibaro:debug("MiniMote button 1 pressed")
elseif ( tonumber(ButtonPressed) == 2) then
 fibaro:debug("MiniMote button 2 pressed") 
elseif ( tonumber(ButtonPressed) == 3) then
 fibaro:debug("MiniMote button 3 pressed")
elseif ( tonumber(ButtonPressed) == 4) then
 fibaro:debug("MiniMote button 4 pressed")
elseif ( tonumber(ButtonPressed) == 5) then
 fibaro:debug("MiniMote button 5 pressed / Zolderlamp Uit")
 fibaro:call(27, "turnOff")
elseif ( tonumber(ButtonPressed) == 6) then
 fibaro:debug("MiniMote button 6 pressed / Zolderlamp Aan")
 fibaro:call(27, "turnOn")
elseif ( tonumber(ButtonPressed) == 7) then
 fibaro:debug("MiniMote button 7 pressed")
elseif ( tonumber(ButtonPressed) == 8) then
 fibaro:debug("MiniMote button 8 pressed")
 fibaro:debug("No response")

The header contains the number of the device (in my case 52). The rest is freely configurable. In the (working) example above I use different kind of calls (like a direct call and a call to activate a scene). Other examples are welcome!

P.S. Don’t forget to start the scene 🙂