Skip to content

variable

Description

The variable block is used to share one value between multiple places in a logic project. All instances of the block configured with the same variable name refer to the same shared value.

The block has one input and one output. It does not require the use of inputs labeled with the tag block. Every change received on the input of any variable instance is immediately forwarded to the output of all instances using the same variable name.

The variable value is not stored permanently. After the project is restarted, the variable returns to the null state and remains there until the first new value is received.

Configuration parameters

Parameter name Value
name Required name of the variable shared by variable blocks. The name must be 1 to 25 characters long, may contain only ASCII letters, digits, and the _ character, and its first character must not be a digit.

Input handling

The block accepts every change sent to its only input. All value types used in the project are supported, including:

  • null
  • boolean values true and false
  • integers
  • floating-point numbers
  • text

After receiving a new value, the block:

  • stores it as the current value of the variable specified by the name parameter
  • forwards the same change to the output of all variable blocks using the same variable name
  • updates the description shown below the block

The block does not require any tag inputs and does not impose any restrictions on the type of the transmitted value.

Block outputs

The block has one output. Every new value written to the shared variable with the given name appears on the output, regardless of which variable instance introduced it.

The description shown below the block displays:

  • the number of active variable block instances using the same variable name
  • the current variable value in text form

Example descriptions:

  • 1: null means there is one instance of this variable and no stored value
  • 3: true means there are three instances of the same variable and the current boolean value is true
  • 2: 21.5°C means there are two instances of the same variable and the current numeric value is 21.5°C

Errors returned by the block

The block can show the following error messages:

Error code Error description
Variable name configuration error. The name parameter is missing in the configuration, is empty, or is not a text value.
Invalid variable name. The variable name does not meet the requirements: its length is outside the 1-25 range, it contains forbidden characters, or it starts with a digit.

Usage examples

  • If two variable blocks have name = living_room_mode, entering the value true on the input of the first one causes the value true to appear on the output of both blocks.
  • If one variable block named target_temp receives the value 21.5, every other variable block named target_temp immediately starts providing the same value.
  • If a variable block named scene_name receives the text evening, the description below all blocks using this variable shows a value containing evening.
  • After the project is restarted, the value of the alarm_state variable is not preserved. Until a new value is written, the block description indicates the null state.