Operators

Arithmetic

Operator Description Example
+ Adds two operands. 10 + 20 = 30
Subtracts second operand from the first. 10 − 20 = -10
* Multiplies both operands. 10 * 20 = 200
/ Divides numerator by de-numerator.
10 / 20 = 2
10 / 3 = 3.333…
\ [1] Integer divides numerator by de-numerator. 10 \ 3 = 3
% Remainder after an integer division.
20 % 10 = 0
11 % 3 = 2
[1]

The backslash is also used as an escape character. So if you want to use the intdivide operator inside a rule you must write your rulses like this:

{
   "rules": {
      "rule": "IF 3 \\ 2 = 1 THEN switch DEVICE light TO on",
      "active": 1
   }
}

Relational

Operator Description Example
==
Checks if the first and second (nummeric)
operand are equal.
20 == 10 = false
10 == 10 = true
!=
Checks if the first and second (nummeric)
operand are unequal.
20 != 10 = true
10 != 10 = false
>=
Checks if the first operand is greater or
equal to the second operand.
20 >= 10 = true
10 >= 20 = false
10 >= 10 = true
>
Checks if the first operand is greater than
the second operand.
20 > 10 = true
10 > 20 = false
10 > 10 = false
<=
Checks if the first operand is smaller or
equal to the second operand.
20 <= 10 = false
10 <= 20 = true
10 <= 10 = true
<
Checks if the first operand is smaller than
the second operand.
20 < 10 = false
10 < 20 = true
10 < 10 = false

New in version 8.0: ISNOT operator added

Deprecated since version 8.1.0.

Operator Description Example
ISNOT
Checks if the first and second (character)
operand are equal.
a ISNOT b = true
a ISNOT a = false
IS
Checks if the first and second (character)
operand are equal.
a IS b = false
a IS a = true

Logical

Operator Description Example
AND
Checks if the first and second operands are
true.
- values greater of smaller then 0 are true
- strings equals to 0 are false
- strings other than 0 are true
1 AND 1 = true
1 AND 0 = false
foo AND false = true
true AND true = true
false AND false = true
OR
Checks if the first or second operands are
true.
- values greater of smaller then 0 are true
- strings equals to 0 are false
- strings other than 0 are true
0 OR 0 = false
1 OR 0 = true
foo OR false = true
true OR true = true
false OR false = true

Other

New in version 8.1.0.

Operator Description Example
.
(single dot)
Concatenates two strings
a . b == ‘ab’
a . ‘ ‘ . b == ‘a b’
RANDOM(1, 2) . ‘34’