Blocks to construct rules

Blocks can have parameters that define their behavior. For example, numeric values, strings, variables, etc. Blocks can be connected, forming a logical sequence of execution.


RULE

Any rule begins with the RULE block located in the Main tab
In this block you can specify:
● name of the rule - plain text with a limit of 48 characters
● rule type:
AUTOMATION - an automation rule that contains a condition for launching.
It is launched every time the trigger changes, if the condition is met - the actions specified in the rule are performed. Cannot be launched from an application
SCENARIO - a set of actions that can be launched from the application or from another rule or scenario
SCHEDULE - an automation rule that is launched according to a schedule, as well as a rule that can be launched when the controller is started.
● Rule ID - rule number that will be saved in the controller, if you specify 0 - the rule number will be assigned automatically when saving on the controller, if you specify an already existing id - the rule will be overwritten
GID - group identifier of the rule - is used to display the rules in the corresponding section, when saving the rule through the application - it is ignored
Enable - indicates whether the rule will be enabled or disabled
Print ast - enables the display of the rule code on the code panel (useful for learning and understanding AST)

This block has one slot where you can insert the body of the automation rule (a block or several blocks)

READ FROM STATE

The block for receiving data from the controller contains the following settings:is trigger - a switch that indicates whether a change in the state of the device will trigger the rule, if there is no trigger in the rule, the rule will not be triggered;state type - the final device from which we will read data (for example, a button or lighting); state id - id of the end device from which we will read data
To find out the state type and id for the device you need, go to the device manager in the i3 home application, select the controller on which the device is located, click "configure" and select "port settings table"
value type - which value will be read, the basic value main is available for any device. A separate article describes all settings and their value typedevice address - the address of the controller from which we read the value, if the rule is saved on the same controller, you can leave self, otherwise you need to specify the address of the controller, you can see this address in the i3 Home application, in the device manager, select the controller on which the device is located, click "configure" and select "port setting table", above the setting table is the device address.

WRITE TO STATE

The block for changing the state of devices contains the following settings:
state type - the final device to which we will record data (for example, lighting);
state id - id of the final device to which we will record data

To find out the state type and id for the device you need, go to the device manager in the i3 home application, select the controller on which the device is located, click "configure" and select "port settings table"

value type - which value will be read, the basic value main is available for any device. A separate article describes all settings and their value type
device address - the address of the controller from which we read the value, if the rule is saved on the same controller, you can leave self, otherwise you need to specify the address of the controller, you can see this address in the i3 Home application, in the device manager, select the controller on which the device is located , click "configure" and select "port setting table", above the setting table is the device address.

IF THEN ELSE

The "IF THEN ELSE" block is the key element to introduce branching logic into programs. This block allows you to define a condition (IF), execute a specific block of code if the condition is met (THEN), and otherwise execute another block of code (ELSE).
● Condition (IF):A condition that is assessed as true (TRUE) or false (FALSE) is defined. It can be an expression, a comparison of values, or any other logical condition.Example: If the variable "x" is greater than 10.● Execution when TRUE (THEN):The block of code inside this segment will only be executed if the condition in the "IF" is defined as true.This is where you place blocks of code that should be executed when the condition is true.● Execution when FALSE (ELSE):The block of code inside this segment will be executed if the condition in "IF" is defined as false.This is where you place blocks of code that should be executed when the condition is not true.
Using the "IF THEN ELSE" block allows the automation rule to respond to and interact with various conditions. This makes it a powerful tool for creating more complex and flexible automation rules in BlocklyPlease note that in order to run the rule, you must specify at least one block in which is trigger will be set, otherwise the rule will be saved but never run.

COMPARISION

Comparison blocks return TRUE or FALSE and are used in an IF block, there are four comparison blocks:Comparison - compares two values, supports the following operations:  - equal to;  - not equal;  - less;  - less than, equal to;  - more;  - more than, equal to;it is necessary to specify the type of values ​​that we are comparing int or float, both values ​​must be of the same type. Between - checks whether the value is within the specified range, it is necessary to specify the type of the value being compared int or float, the value being compared, the initial and final values ​​must be of the same type;Time is - time comparison, will return TRUE if the time corresponds to the specified time;Time between - checks whether the current time is within the specified range;

OPERATIONS

Blocks that allow you to perform operations with other blocksMath - mathematical operations, supports the following operations:    - add;  - subtract;  - multiply;  - divide;it is necessary to specify the type of operand values ​​int or float, both values ​​must be of the same type.NOT - is used to perform the logical operation "NOT", which turns a Boolean value into its opposite. The "NOT" block has one input that takes a Boolean value. This value will change to its opposite. The "NOT" block can only be used with Boolean values ​​or blocks that return Boolean values.Binary logic - binary operations, supported:AND - is used to perform a logical AND operation, which returns true if both input Boolean values ​​are also true.OR - is used to perform a logical "or" operation that returns true if at least one of the input Boolean values ​​is true.XOR - is used to perform an “exclusive or” logical operation that returns true if only one of the input Boolean values ​​is true.

LOOPS

Blocks that allow you to organize loops
While Do - used to create a "while" loop that allows certain blocks of code to be executed while a certain condition is true. A block holds a condition block that determines whether a block of code will be executed. The condition must return a Boolean value (true or false). The "do" block contains blocks that are executed as long as the condition is true. You can nest other blocks, logic operations, and variables to work within this loop. Be careful when defining the condition, as an incorrectly defined condition can lead to an infinite loop.
For - The "For" block has a field for entering the initial value of the "from" loop counter. This defines the value from which the counter starts its count, and the end value field of the loop counter "to", as well as the value by which the loop counter will be increased in each "step" iteration. A block holds a set of blocks that are executed in each iteration of the for loop.

VALUES

Blocks for working with constants and variables
CONSTANT - used to initialize and assign a value to an anonymous constant;
DATE TIME - used to initialize and assign a value to an anonymous time constant, in the format YYYY-MM-DD HH:MM:SS;
DELAY - pause in the rules, takes an int value in milliseconds;
RGBW COLOR - indicates the color of RGBW tapes;
SWITCH EVENT - value for Switch type state;
TIME NOW - current value on the controller;

TIME

SCHEDULE - the block that allows you to run the rules according to the schedule, has a field for entering Cron-expressions that define the time intervals and the rules for executing the blocks in the schedule block. A mask in linux cron format is specified

Didn’t find the answer to your question?

You can contact the technical support chatbot.Found a mistake on the site? Help us fix it!