* Redesign command Tariff to now default to 0 (=disabled) and allowing to set both Standard Time (ST) and Daylight Savings Time (DST) start hour (#6282)
* Commands Tariff1 23 = Tariff1 ST, Tariff2 7 = Tariff2 ST, Tarriff3 22 = Tarrif1 DST, Tariff4 6 = Tariff2 DST, Tariff9 0/1 = Weekend toggle
The major features of IF statement are:
- Support IF, ELSEIF, ELSE
- Support not only comparison but also using logical expression as condition
- Support run multiple commands
- Support nested IF statement
- All the commands run by IF statement will go to the BACKLOG!
- No limit for logical operators, parenthesis and nested IF statement. Depends on your RAM!
Extended Backus-Naur Form of IF statement:
<if-statement> ::=
IF "(" <logical-expression> ")" <statement-list> {ELSEIF "(" <logical-expression> ")" <statement-list>} [ELSE <statement-list>] ENDIF
<logical-expression> :=
<comparison-expression> |
(<comparison-expression> | <logical-expression>) {(AND | OR) <logical-expression>} |
"(" <logical-expression ")" {(AND | OR) <logical expression>}
<comparison-expression> ::=
<math-expression> ("=" | "<" | ">" | "|" | "==" | "<=" | ">=" | "!=") <math-expression>
<statement-list> ::=
<statement> {";" <statement>}
<statement> ::=
<Sonoff-Tasmota-command> | <if-statement>
In English:
If statement support 3 format:
1. IF (<condition>) <statement-list> ENDIF
2. IF (<condition>) <statement-list> ELSE <statement-list> ENDIF
3. IF (<condition>) <statement-list> [ELSEIF (<condition>) <statement-list> ]* ELSE <statement-list> ENDIF
<condition> is a logical expression which can be:
1. A comparison expression for example:
VAR1 >= 10
2. Multiple comparison expression with logical operator "AND" or "OR" between them. "AND" has higher priority than "OR". Fox example:
UPTIME > 100 AND MEM1 == 1 OR MEM2 == 1
3. Parenthesis can be used to change the priority of logical expression. For example:
UPTIME > 100 AND (MEM1 == 1 OR MEM2 == 1)
<statement-list> can be:
1. A Sonoff-Tasmota command. For example:
ledpower on
2. A IF statement ("IF .... ENDIF")
3. Multiple Sonoff-Tasmota command or IF statement split with ";". For example:
Power1 off; Ledpower on; if (mem1 == 0) Var1 Var1+1; mem1==1 endif; Delay 10; POWER1 on
4. Do not need to lead with "BACKLOG" for multiple commands.