Skip to content

const

Description

The const block stores one constant value and sends it to its output when it is triggered by an input event or by the set command from the command block. It also supports the reset command from the command block, which causes the block to send the null value.

The block has one input and one output. It does not require the use of inputs labeled with the tag block.

The constant value may have one of the following types:

  • boolean
  • numeric
  • text

If no other source is connected to the block input, then after the project starts the block sends the configured value once on its own.

Configuration parameters

Parameter name Value
Triggering edge (input_edge) Required parameter that defines which ordinary input event should cause the constant value to be sent again. Supported values are: rising, falling, both, true, false, null, none.
Value type (value_type) Required parameter that defines the type of the constant value. Supported values are: bool, num, str.
Value (value) Required parameter that defines the constant value sent to the output. Its interpretation depends on value_type.

Meaning of the input_edge parameter:

  • rising: react to a change interpreted as false -> true
  • falling: react to a change interpreted as true -> false
  • both: react to every change between logical states
  • true: react to every input event whose new value can be interpreted as logical true
  • false: react to every input event whose new value can be interpreted as logical false
  • null: react to every input event whose new value is null
  • none: do not react to ordinary input events

Meaning of the value_type parameter:

  • bool: the block stores the logical value true or false
  • num: the block stores a numeric value; integers, floating-point numbers, temperature, and percent are allowed
  • str: the block stores a text value

Input handling

The block reacts to ordinary events delivered to its only input and to the set and reset commands sent from the command block.

The block does not require any tag inputs.

Detailed operating rules:

  • if no other block is connected to the input, const sends the configured value by itself after initialization is finished
  • an ordinary input event that matches the input_edge condition causes the configured value to be sent again
  • for input_edge = none, all ordinary input events are ignored
  • the set command from the command block causes the configured value to be sent again regardless of the input_edge setting
  • the reset command from the command block causes the block to send the null value of the same type as the configured value
  • after the reset command, the next set command or the next valid input trigger sends the configured value again

Additional input interpretation rules:

  • for rising, falling, and both, the block requires values that can be interpreted logically
  • for true and false, the block reacts to every input event whose new value is interpreted respectively as true or false, even if the previous value was the same
  • for null, the block reacts only to input events whose new value is null

Block outputs

The block has one output.

The output always carries the value configured in the block parameters, unless the block receives the reset command, which sends the null value.

The way the value is emitted depends on the configured type:

  • for value_type = str, every emission has the form null -> text
  • for value_type = num, every emission has the form null -> number
  • for value_type = bool, every emission has the form of a change from the opposite logical state to the configured value, that is false -> true or true -> false

The description visible below the block shows the value currently prepared to be sent in text form, for example:

  • true
  • false
  • 25
  • 21.5°C
  • hello

After the reset command, the block description changes to null. After the configured value is sent again, the description returns to its text representation.

Errors returned by the block

The block can show the following error messages:

Error code Error description
Invalid input edge configuration. The input_edge parameter is invalid or was not set.
Missing value type configuration. The value_type parameter is missing in the configuration.
Invalid value type configuration. The value_type parameter has a value outside the supported list: bool, num, str.
Missing value configuration. The value parameter is missing in the configuration.
Invalid value configuration. The value parameter has an invalid form for the selected value type. This includes, among others, the case when bool is given a value other than true or false, or when a valid numeric value cannot be read for num.
Expected numeric value configuration. The value_type parameter is set to num, but the value parameter does not contain a numeric value.
Set description failed. The block cannot prepare a text description of the configured value. This is an internal error and means the value cannot be displayed correctly in the block description.

Usage examples

  • If value_type = str, value = hello, and no other block is connected to the input, then after the project starts const sends the value hello to the output by itself.
  • If value_type = num, value = 21.5°C, and input_edge = rising, then every rising edge on the input causes the value 21.5°C to be sent to the output.
  • If value_type = bool and value = true, then the set command from the command block causes the change false -> true to be sent, regardless of the input_edge setting.
  • If value_type = bool and value = false, then every valid trigger causes the change true -> false.
  • If the block receives the reset command, null appears at the output and the block description changes to null.