Say you want multiple things to be true or have an alternative scenario that can also be true as follows:
- Temperature is greater than 10°C
- Lights are on
- Distance to home is less than 100m
You can evaluate this without having to include nested IFs by using this shortcut.
Description and Parameters 📖
To declare a statement for evaluation the syntax is as follows:
NUMBER :OPERATOR: NUMBER
🔟 :==: 🔟
These statements can then be combined using logical and (&&) and logical or (||) as follows:
🔟 :==: 🔟 && 9️⃣ : !=: 9️⃣ || 2️⃣ :==: 2️⃣
The full list of operators is as follows:
- == Equal To
- != Unequal To
- < Less Than
- > Greater Than
- <= Less Than or Equal To
- >= Greater Than or Equal To
- && AND
- || OR
1. Don’t evaluate more than two variables against each other such as:
1️⃣ :==: 3️⃣ :<=: 5️⃣ :==: 0️⃣
Instead you can write this as:
1️⃣ :==: 3️⃣ && 3️⃣ :<=: 5️⃣ && 5️⃣ :==: 0️⃣
Logically they mean the same thing however the function can’t handle the former.
2. You can pass a single variable for evaluation (without an operator) such as:
In this case, it is the equivalent of testing for non-zero. False if zero, True otherwise.
Following from this, you can include single variables in a larger statement such as:
🔟 && 1️⃣ && 0️⃣ || 1️⃣ :==: 1️⃣
3. Check your inputs
Pass all inputs as numbers or variables that can be converted to numbers. Strings are not yet supported as they present ambiguity. This is because the shortcut itself accepts a string as an input and has to identify the operators. Passing strings as variables could result in improper identification of operators.
Spaces have no effect when passing inputs however new lines do.
- Convert inputs to numbers. In most cases this can be done using simple maths or conversions. E.g Testing if lights are on you can use brightness :>: 0 instead of passing their state “on” or “off”. However you could just easily convert “on” or “off” to 1 or 0.
- Emojis like 0️⃣ are used to denote variables being compared.
- The “:” delimiter is necessary for accurately distinguishing which input is which.
Latest Release Notes
1.3 - May 30, 2021, 3:10 a.m.
Changed the input syntax and added the greater than or equal to and less than or equal to operator. The syntax is made to be almost like C bar the “:” delimiter required for text formatting.