Skip to main content

Variables Blocks

note

Screenshots in this guide may look slightly different from what you see on your device. Please follow the actual interface for reference.

Overview

In automation logic, variables are essential for flexibility and scalability. With Aqara Studio, you can not only assign live device data as variables, but also define custom variables of multiple types: Boolean, String, and Numeric.

These variables enable data storage and calculations, comparisons, text concatenation, and even advanced custom data-processing scripts.

The variables category includes the following blocks:

Variables blocks overview

Point Data

Feature

Use the Point Data block to save real-time data collected by devices (such as temperature, humidity, brightness, switch status) as variables.

Components

Point Data block components

This is a dual-point block:

Connection point/ParameterRequiredDescription
Input PointIt is used to control devices. It can connect to other Point Data blocks, Math, Logic, String Concat, or JavaScript blocks. It obtains their values to update its own value.
Output PointIt outputs real-time data. It Can connect to other Point Data blocks, Math, Logic, String Concat, or JavaScript blocks.

How to Use

Here's how to use the Point Data block:

  1. After selecting the block, a device selection window appears. You can view all available local device variables of the target device. Check the items you need to add listener blocks anywhere on the canvas and start listening in real time.

    Select local device variables
  2. Connect value-providing blocks to the left side of the block, or connect value-consuming blocks to the right, such as Point Data, Math, Logic, Numeric Variables, String Concat, or JavaScript blocks.

    Connect other value-required blocks

Boolean Variables

Feature

Use this block to create a local boolean variable when you need to define a boolean value, or store and pass boolean data during a flow.

Components

Boolean Variables block introduction

This is a dual-point block with 1 parameter:

Connection point / ParameterRequiredDescription
Input pointIt receives Boolean variables, and supports connection to the JavaScript block only.
ValueIts meaning depends on input and output connections:
  • When the input point connects to a JavaScript block, this field shows the boolean value output by the script.
  • When the output point connects to a JavaScript block, you can set this value manually as a script parameter.
Output pointIt outputs a boolean value, and supports connection to the JavaScript block only.
note

The input point, boolean value, and output point are all optional. Connect or configure them based on your actual logic needs.

How to Use

Here's how to use the Boolean Variables block:

Use as a script parameter

  1. Define a boolean value in the Boolean Variables block.
  2. Connect a JavaScript block to the right side.

Record script result

Use boolean block to record script result
  1. Configure a JavaScript block to process input data and output a boolean value.
  2. Connect a Boolean Variables block after the script block. After execution, the boolean value in the card displays the result.

Numeric Variables

Feature

Use this block to create a local numeric variable when you need to define a number, or to store and pass numeric data in a flow.

Components

Numeric Variables block introduction

This is a dual-point block with 1 parameter:

Connection point / ParameterRequiredDescription
Input PointIt receives a numeric value, and supports connections to Math and JavaScript.
ValueIts meaning depends on input and output connections:
  • When the input point connects to Math or JavaScript, this field displays the calculation result or script result.
  • When the output point connects to Math, Logic, or JavaScript, set this value manually as a parameter.
Output PointIt outputs your defined number, and supports connections to Math, Logic, and JavaScript.
note

The input point, number value, and output point are all optional. Connect or configure them based on your actual logic needs.

How to Use

Depending on your need, you can use the Numeric Variables block as follows:

Use as parameters for Math, Logic, or JavaScript

  1. Use the Numeric Variables block to define a number.
  2. Connect a Math, Logic, or JavaScript block to the right side.

Record script result

  1. Configure a JavaScript block to process input data and output a number.
  2. Connect a Numeric Variables block after the script block. After execution, the number in the card shows the result.

Record Math or Logic results

  1. Connect a Math block or Logic block to the left side to receive its result.

String Variables

Feature

Use this block to create a local string variable when you need to define a string, or to store and pass string data in a flow.

Components

String Variables block introduction

This is a dual-point block with 1 parameter:

Connection point / ParameterRequiredDescription
Input PointIt receives string content, and supports connections to JavaScript and String Concat.
ValueIts meaning depends on input and output connections:
  • When the input point connects to JavaScript, this field displays the string content output by the script.
  • When the output point connects to JavaScript or String Concat, set this value manually as a script parameter or part of concatenation.
Output PointIt oputputs a string, and supports connections to JavaScript or String Concat.
note

The input point, string content, and output point are all optional. Connect or configure them based on your actual logic needs.

How to Use

Depending on your need, you can use the String Variables block as follows:

Use as a script parameter or part of concatenation

  1. Use the String Variables block to define a string.
  2. Connect a JavaScript or String Concat block to the right side.

Record script result

  1. Configure a JavaScript block to process input data and output a string.
  2. Connect a String Variables block after the script block. After execution, the string in the card shows the result.

Record concatenation result

  1. Connect a String Concat block to the left side to receive its result.

Global Variable

Variables created by blocks like Boolean Variables, Numeric Variables, and String Variables are local by default and only available within the current automation flow.

If you need to reuse variables across multiple automation flows, use global variables.

Set Global Variables

You can set global variables in two ways:

Convert an existing local variable

Right-click an existing variable block and select Set as global variable to convert it into a global variable definition block.

Right-click an existing variable block

Create a global variable

  1. Click Global variable at the top of the canvas and select New Variable in the dialog.

    Create a new global variable
  2. In the dialog, set the variable type, name, and value. Then click Confirm.

    Set global variable
  3. After confirming, place the variable block anywhere on the canvas. It serves as the definition of the global variable and can be referenced by other flows.

Use Global Variables

  1. Click Global Variables at the top of the canvas and select the variable you need in the dialog.

    Select the added global variable
  2. Click anywhere on the canvas to create the global variable block. This block is a single-output block Based on its type, connect it to other blocks as described in the relevant sections above.

  3. Click anywhere on the canvas to create the global variable block. This is a dual-point block. It can receive new values or output its current value. Depending on the variable type, connect it to other blocks as described in the relevant sections above.

    Add the selected global variable