Updated Rules (markdown)

Michael Ingraham 2019-10-08 14:54:29 -04:00
parent ea8ba39cff
commit 3e0a82d309
1 changed files with 6 additions and 9 deletions

@ -10,16 +10,15 @@ Tasmota provides a Rule feature heavily inspired by the _ESPEasy_ implementation
## Introduction
Rules perform actions based on triggers (e.g., switch state change, temperature threshold, events like system boot, a defined timer elapsing, custom defined events, etc.) They are stored in flash and therefore will survive a reboot.
>Most pre-compiled binaries ([builds](Builds)) have the Rules feature enabled. The exception being `sonoff-minimal.bin` and `sonoff-classic.bin`. *If you are compiling your own firmware, in order to use rules, include `#define USE_RULES` in `user_config_override.h`.*
> Most pre-compiled binaries ([builds](Builds)) have the Rules feature enabled. The exception being `sonoff-minimal.bin` and `sonoff-classic.bin`. *If you are compiling your own firmware, in order to use rules, include `#define USE_RULES` in `user_config_override.h`.*
## Rule Syntax
**Nested rules are not supported.**
["IF/ELSE/ELSEIF" and "AND/OR" support](https://github.com/arendst/Sonoff-Tasmota/wiki/Rules---IF-ELSE-ELSEIF-and-AND-OR-Support) **6.6.0.11**
Every rule needs to follow this syntax:
- Optional ["IF/ELSE/ELSEIF" and "AND/OR"](Rules---IF-ELSE-ELSEIF-and-AND-OR-Support) support **6.6.0.11**
- Optional [use of expressions](Expressions-in-Rules) support **6.4.1.14**
Rule definition statement:
`ON <trigger> DO <command> [ENDON | BREAK]`
- **`ON`** - marks the beginning of a rule definition
- **`<trigger>`** - what condition needs to occur for the rule to execute
@ -39,7 +38,6 @@ Rules inside a rule set `Rule<x>` are concatenated and entered as a single state
Spaces after `ON`, around `DO`, and before `ENDON` or `BREAK` are mandatory. A rule is **not** case sensitive.
### Rule Trigger
A rule trigger can consist of:
- `[TriggerName]#[ValueName]`
- `[TriggerName]#[ValueName][comparison][value]`
@ -122,7 +120,6 @@ Trigger | When it occurs |
[Back To Top](#top)
### Rule Command
A rule command can be any command listed in the [Commands list](Commands). The command's `<parameter>` can be replaced with `%value%` which will use the value of the trigger.
`ON Switch1#State DO Power %value% ENDON`
@ -143,9 +140,9 @@ Use the `+` character to append a new rule to the rule set. For example:
### Rule Variables
There are ten available variables (double precision reals) in Tasmota, `Var1..Var5` and `Mem1..Mem5`. All `Var` will be empty strings when the program starts. The value of all `Mem` persists after a reboot. They provide a means to store the trigger `%value%` to be used in any rule.
There are ten available variables (double precision reals) in Tasmota, `Var1..Var5` and `Mem1..Mem5`. All `Var` will be empty strings when the program starts. The value of all `Mem` persists after a reboot. They provide a means to store the trigger `%value%` to be used in any rule.
The value of a `Var<x>` and `Mem<x>` can be:
The value of a `Var<x>` and `Mem<x>` can be:
- any number
- any text
- %var1% to %var5%