mirror of https://github.com/arendst/Tasmota.git
Updated Rules: IF ELSE ELSEIF and AND OR Support (markdown)
parent
c86bf41cc6
commit
6933e071e5
|
@ -26,15 +26,15 @@ Note: All the commands executed _**within an IF block**_ are performed via `Back
|
||||||
`<statement-list>`
|
`<statement-list>`
|
||||||
- `<statement>` {`;` `<statement>`}
|
- `<statement>` {`;` `<statement>`}
|
||||||
|
|
||||||
<statement>
|
`<statement>`
|
||||||
- {`<Sonoff-Tasmota-command>` | `<if-statement>`}
|
- {`<Sonoff-Tasmota-command>` | `<if-statement>`}
|
||||||
|
|
||||||
In English:
|
## In English
|
||||||
IF statement supports 3 formats:
|
IF statement supports 3 formats:
|
||||||
|
- `IF (<condition>) <statement-list> ENDIF`
|
||||||
|
- `IF (<condition>) <statement-list> ELSE <statement-list> ENDIF`
|
||||||
|
- `IF (<condition>) <statement-list> [ELSEIF (<condition>) <statement-list> ]* ELSE <statement-list> ENDIF`
|
||||||
|
|
||||||
`IF (<condition>) <statement-list> ENDIF`
|
|
||||||
`IF (<condition>) <statement-list> ELSE <statement-list> ENDIF`
|
|
||||||
`IF (<condition>) <statement-list> [ELSEIF (<condition>) <statement-list> ]* ELSE <statement-list> ENDIF`
|
|
||||||
`<condition>` is a logical expression, for example:
|
`<condition>` is a logical expression, for example:
|
||||||
- `VAR1 >= 10`
|
- `VAR1 >= 10`
|
||||||
- Multiple comparison expression with logical operator `AND` or `OR` between them. `AND` has higher priority than `OR`. For example:
|
- Multiple comparison expression with logical operator `AND` or `OR` between them. `AND` has higher priority than `OR`. For example:
|
||||||
|
@ -42,14 +42,14 @@ IF statement supports 3 formats:
|
||||||
Parenthesis can be used to change the priority of logical expression. For example:
|
Parenthesis can be used to change the priority of logical expression. For example:
|
||||||
`UPTIME > 100 AND (MEM1 == 1 OR MEM2 == 1)`
|
`UPTIME > 100 AND (MEM1 == 1 OR MEM2 == 1)`
|
||||||
|
|
||||||
`<statement-list>` For example:
|
`<statement-list>`
|
||||||
- A Sonoff-Tasmota command (e.g.,`LedPower on`)
|
- A Sonoff-Tasmota command (e.g.,`LedPower on`)
|
||||||
- Another IF statement (`IF ... ENDIF`)
|
- Another IF statement (`IF ... ENDIF`)
|
||||||
- Multiple Sonoff-Tasmota command or IF statement separated by `;`. For example:
|
- Multiple Sonoff-Tasmota commands or IF statements separated by `;`. For example:
|
||||||
`Power1 off; LedPower on; IF (Mem1 == 0) Var1 Var1+1; Mem1 1 ENDIF; Delay 10; Power1 on`
|
`Power1 off; LedPower on; IF (Mem1 == 0) Var1 Var1+1; Mem1 1 ENDIF; Delay 10; Power1 on`
|
||||||
`Backlog` is implied and is not required (saves reule set buffer space).
|
`Backlog` is implied and is not required (saves reule set buffer space).
|
||||||
|
|
||||||
Examples:
|
## Example
|
||||||
Rule used to control pressure cooker with a Sonoff S31. Once it is finished cooking, shut off the power immediately.
|
Rule used to control pressure cooker with a Sonoff S31. Once it is finished cooking, shut off the power immediately.
|
||||||
```
|
```
|
||||||
Rule1
|
Rule1
|
||||||
|
|
Loading…
Reference in New Issue