|  Help center

MiOS search

Variables

Overview

A variable is a user-created container used to house a specific piece of data. You can use variables in meshbot triggers on devices with capabilities which may be at a range of levels. You can also set the value of an existing variable in a meshbot action.

There are a variety of different variable types which you can use, including ‘Integer’, ‘Boolean’, ‘Scaleable’ and more:

 

  • For example, you might create an ‘Integer’ variable named ‘Battery Warning Level’ to notify you if a device’s battery drops below 10%. You could use the same variable in triggers for any device that has batteries:
  • … or create a ‘Turn On AC’ integer variable with ‘18’ as its value, then create a trigger which turns on your air conditioning if it detects a temperature higher than this variable
  • You can use a single variable in as many different meshbots as you want. If you update the variable’s value then it also gets updated in all triggers which feature the variable. For example, you could create ‘scalable’ illuminance variables and use them in triggers for multiple different lamps:
Usage in meshbots

You can use variables in multiple places in meshbot triggers and actions:

Triggers – compare a device’s value with a variable

You can use a variable in the right-hand side of a trigger to compare a device’s current setting to a variable’s value.

Example 1 – You want to receive a notification if your humidifier’s battery level falls below 10% power.

  • Create an Integer variable named ‘Battery Warning Level’ and assign it a value of 10.
  • Next, create a meshbot trigger which goes true if your humidifier’s ‘Battery’ capability is less than the ‘Battery Warning Level’ variable.
  • Finally, create an action to send you a notification if the trigger goes true:

You can re-use the same variable on any battery-powered device for which you want a similar notification.

Example 2 – Turn on your air-conditioning if the temperature goes above 18 c.

  • Create an Integer variable called ‘Turn On AC’ with ‘18’ as its value.
  • Create a trigger which turns on your air conditioning device if it detects a temperature higher than this variable:
Actions – set a variable’s value

You can set or update the value of a local variable in a meshbot action:

There are many uses for this feature, including the ability to store the collective states of multiple items in a single variable (a great time saver). For example, let’s say you want all three windows in your apartment to be closed before running a scene. You plan to use this ‘all windows closed’ condition as the trigger for multiple, independent scenes.

You can create a local boolean variable that goes ‘True’ if all three windows are closed, and ‘False’ if one or more windows are open. You can then use the variable in all meshbots that you want to make conditional on the ‘all closed’ state.

  • Create a boolean variable called ‘All Windows Closed’ and give it an initial value of ‘False’. This starting value doesn’t really matter as we will later use a meshbot action to determine its real value anyway.
  • Next, create a meshbot trigger that becomes true if all three windows are closed.
  • Setup the meshbot actions to update the variable accordingly:

    • True action = set the ‘All Windows Closed’ variable to ‘True’.
    • False action = set the ‘All Windows Closed’ variable to ‘False’.
  • The final meshbot should look something like this:

Now that you have this data stored in a single variable, you can reuse the variable in other meshbots that you want predicate on the ‘All Windows Closed’ status.

For example, you may want to wait until all windows are closed before turning on your air-conditioning unit. You might also have a separate meshbot which only turns on your house alarm if all windows are closed, etc.

This saves you time over adding all three window devices to multiple meshbots. See the next section, ‘Use a variable as a Node Type’ for some examples of this.

Triggers – use a variable as a ‘Node Type’

You can also use variables as the main ‘Node Type’ in a trigger condition. This lets you compare a variable’s current value to a value you enter, or the value of another variable.

Example 1 – Compare a variable with a specific value

You can create a trigger which activates if a variable achieves a specific value. The type of value you can specify depends on the variable type (integer, boolean, scale, color, etc).

The following screenshot follows on from our example in the previous section where we used an action to set the value of a boolean variable. It shows how you can create a trigger which turns on the air conditioning IF the ‘All Windows Closed’ variable is ‘True’:

Example 2 – Compare a variable with another variable

The following example shows a trigger which becomes true if the value of a ‘Relative Humidity’ variable exceeds that of a ‘High Humidity’ variable. In both cases you would have to already have set up meshbots to (i) Capture and store the current relative humidity and (ii) Define the value of ‘High Humidity’.

Integer

‘Integer’ is a simple variable that lets you define a number as its value. The number has no set scale so you can use it to reference different scales depending on the device in your trigger. For example, you can use it to represent a percentage, light dimmer level, temperature, power level, humidity level and more.

The following example shows an integer variable named ‘Twenty percent capacity’ with a corresponding value of ‘20’:

 

You could use this same variable in multiple triggers. For example, here it is being used as a condition in two different triggers – one for a light’s dimmer level and the other for a smoke detector’s battery level:

…of course, the example above will only work on device capabilities which have a scale range of 0-100.

String

The ‘string’ variable lets you create a variable with letters and/or special characters + numbers as its value.

You can create string values which are:

  • Blank.
  • All letters or all special characters.
  • Any combination of letters, special characters and numbers.
  • But you cannot create a string value which is only numbers.
Boolean

‘Boolean’ variables are variables with a binary ‘True’ or ‘False’ value. You can use this type of variable on any device which features true and false (or ‘on/off’) states. For example, switches, lightbulbs, televisions etc. This is especially useful for capabilities that support boolean values, but don’t have them in their native settings.

Color

The ‘Color’ variable lets you set a hex value which corresponds to a specific color. You can select a color by directly entering a hex into the ‘Variable Value’ field, or by clicking the color icon then choosing from the color picker:

You can also use the sample tool to choose any color on your desktop:

You can then use the variable in triggers for devices which allow you to choose color values:

Token

‘Token’ variables are used to present multiple choices to users in radio buttons or drop-down lists. Use the checkboxes to choose the ‘current’ key-value pair.

Scalable

‘Scalable’ variables let you use a device value of a specific scale in your meshbot triggers.

  • There are 37 different types of scaleable value that you can choose. These include ‘Temperature’, ‘Frequency’, ‘Angle’, ‘Length’, ‘Illuminance’, ‘Loudness’ and more.
  • Many types let you choose from multiple units of measurement. For example, the temperature scaleable lets you specify a value in fahrenheit or celsius. The ‘Mass’ scaleable lets you choose between kilograms or pounds.
  • The ‘Temperature’ scalable is unique in that it automatically converts the value to match the scale used on your target device. For example:

    • You create a ‘Temperature’ variable with a value of ‘32’ and scale = ‘Fahrenheit’.
    • You use that variable in a trigger with a device that uses celsius.
    • EZLogic converts the celsius reading from the device to the fahrenheit scale of the variable (‘0’ to ‘32’), so the trigger still works.
  • For all other types of scalable, you must make sure your unit of measurement matches the units on your target device.

Here are a few examples of scalable variables you could create:

‘Save Output’ feature

The ‘save output’ feature lets you create or update a variable value with the response from a http request or NuCAL service. The following example shows how a variable could store the response from a http request for carbon data:

You can then create a Lua script to extract specific values from the output for use in a trigger.