Global variables allow you to store information which then can be used by scenes to either trigger them or change the way they operate.

There are two types of Global variables: standard variables and predefined variables.

We will go through both of these below.


Standard Variables:

A standard variable contains a numerical value.

To create a standard variable click on the Panels tab at the top and locate the Variables Panel section on the left hand side.

Once we are in the Variables Panel, click on the first Add button.

Now we have created our first Global variable we can create a simple scene that changes the value based on the weather.

When the rain causes the Global variable to change, another scene can be triggered by the change. We have created an example to the right that says if the Global variable is 1 then close the blinds.


Using Lua on the Home Center 2, you can perform calculations and various other ways to change a value of a Global Variable.

An example of this would be a counter that counts the number of times a doorbell is pressed while the occupants of a home are out. A predefined Global variable would be set so the system knows the user is out and if the doorbell is pressed while the user is out then it will count and add each press to a variable value. This counted value can then be used to determine another action when the user comes home.

Example:

  1. -- the door bell has been pressed while we were away
  2. -- Add 1 to the global variable called 'counter'
  3. fibaro:setGlobal('counter', fibaro:getGlobalValue('counter') + 1)


Predefined Variables:

Predefined variables use words instead of numbers and allow you to limit the content of the variables you create.

To create a predefined variable click on the Panels tab at the top and locate the Variables Panel section on the left hand side.

Once we are in the Variables Panel, click on the second Add button.

A pop up box will appear allowing us to name the variable and give it values.

In the first box we are going to use HomeMode as the example and set one of the values to In and the other to Out. You can add as many values as you require.

Click save once this is done.

This type of Global variable can work in the same way as the standard variables shown above, however now that the variables have named values our scenes can become more readable as the values have meaning.

There is no limit to the number of Global Variables that can be created on your Home Center. They can be used to trigger multiple scenes, pass values between scenes, and keep track of the overall state of the house.

Using a 'HomeMode' Global Variable that defines whether or not the house is occupied, we can cause scenes to behave in different ways if we are at home or out. We can automatically change a Global Variable at different times of the day and in this way have 'moods' in the house based on Morning, Afternoon, Evening, Night. The imagination is the limit.