Moderate_GraphicDifficulty Level: Moderate

This tutorial assumes a moderate level of knowledge of the Fibaro System.
The Minimote from Aeotec is great little device for calling up to 8 discrete scenes on your HC2, but we get a lot of requests from people asking us how to utilise it. So, here is an updated guide on how to get the most out of your Aeotec Minimote!

What do I need?

  • 1 or more Aeotec Minimote(s)
  • A Home Center 2

Let’s get started

The first thing you need to do, is include your Minimote into your Fibaro System.

  1. Make sure the Minimote has battery and is factory reset (not currently included to another system.) Do this by pressing and holding the “Associate” and “Learn” buttons simultaneously for 10 seconds. The device will flash flash the Blue LED for 2 seconds to indicate it has been successfully reset.
  2. Press the “Learn” button on the Minimote – the blue LED will start to slowly blink
  3. On your HC2, go to Devices > Add/Remove Devices and put the HC2 in Learning Mode.
  4. Once included, go into the device’s settings and make sure parameter 250 is set to “1”. This should be there by default, but if not set the parameter and wake the Minimote up (by pressing and holding the “Learn” button for 3 seconds.)
  5. Make a note of the Device ID that the system assigns to this device, you’ll need it later.
Next, we need to create a Virtual Device in our System that will be a virtual “copy” or “representation” of the physical device. This isn’t strictly necessary, but it will become clear why we want to do this a bit later…

You can create a device from scratch, or download one here. How you lay the device out is not important, what is important is that it has 8 buttons. You also don’t need to worry about the names on the buttons, feel free to change them to something more meaningful if that helps.

Tip: As of v4 onwards, you can now hide devices in your system. You can go ahead and hide the Zwave Device if you want to declutter your interface a bit, just go into the Device > Advanced and tick “This device is hidden in the system”
Now all we need to do is link the physical button presses on the device to the virtual buttons on the Virtual Device. We do that using a simple Lua scene.

  1. Create a new Lua Scene
  2. Copy and paste the following code into that scene
--[[
%% properties
201 sceneActivation
%% globals
--]]

--------- Your Device ID's Here ---------

local virtualDevID = 202  --Edit these values!!
local minimoteID = 201

------ Do not edit below this line ------

local buttonPressed = fibaro:getValue(minimoteID, 'sceneActivation')
fibaro:call(virtualDevID, 'pressButton', buttonPressed)
Make sure you edit your device ID’s accordingly, including the sceneActivation trigger in the header.
At this stage, we should see something like this:

You’ll have 3 new items in your system – a Physical Zwave Device, a Lua Scene and a Virtual Device.

The scene takes the button press on the physical device, and presses the corresponding button on the Virtual Device.

Finishing Up

Let’s now go and put some functionality to these buttons presses.

Open up the virtual device and go through changing the buttons types to Lua. From here, you just need to add whatever code you want to execute on a given button press.

 

ButtonCode

If you have downloaded the virtual device we have created, you’ll see a “fibaro:log” function has been added to each button. This is a great way of testing to make sure everything is working.

The Minimote has 8 discrete commands, that all use the “sceneActivation” property.

Single button presses return an odd value:

  • Button 1 = 1
  • Button 2 = 3
  • Button 3 = 5
  • Button 4 = 7

Press and hold actions return an even value:

  • Button 1 = 2
  • Button 2 = 4
  • Button 3 = 6
  • Button 4 = 8

So, if you want to map an action to turn on a light with a single press of Button 1, and off again with a press and hold of the same button, you would add the “turnOn” command to Button 1, and the “turnOff” command to Button 2.

That’s great, but why?

I know what you’re thinking – there is (arguably) a simpler way of triggering Lua code from a button press with just the Lua scene itself. It looks something along the lines of this:

--[[
%% properties
201 sceneActivation
%% globals
--]]

local ButtonPressed = tonumber(fibaro:getValue(201, 'sceneActivation'))
if ButtonPressed == 1 then
  --do something
elseif ButtonPressed == 2 then
  --do something else
elseif ButtonPressed == 3 then
  --do something else
elseif ButtonPressed == 4 then
  --do something else
elseif ButtonPressed == 5 then
  --do something else
elseif ButtonPressed == 6 then
  --do something else
elseif ButtonPressed == 7 then
  --do something else
elseif ButtonPressed == 8 then
  --do something else
else
  fibaro:debug('Error')
end
Functionally, this works in exactly the same way as the above method. However, using a Virtual Device gives you a couple of benefits:

  1. It makes it much easier to read and manage. A big stack of “ifelse” statements gets visually confusing, especially once you’ve added complex commands to all of the available button presses. The segregation of code on the Virtual Device is much friendlier.
  2. You can now push the buttons virtually. So if you don’t have the Minimote to hand, you can virtually push it’s buttons using the Virtual Device (just as the name suggests!)