Updated Rules (markdown)

blakadder 2019-05-07 18:24:42 +02:00
parent 76b6d1215d
commit 06b8f3491e
1 changed files with 35 additions and 32 deletions

@ -26,11 +26,12 @@ Every rule needs to follow this syntax:
**`do`** is the separator between the `<trigger>` and `<command>` **`do`** is the separator between the `<trigger>` and `<command>`
**`endon`** marks the end of that rule. It can be followed by another rule. Alternative you can end the rule with `break` instead. **`endon`** marks the end of that rule. It can be followed by another rule.
Alternatively you can end the rule with `break`.<br>
**`break`** will stop the execution for all the triggers that follow this rule inside the rule buffer. If a trigger that ends with `break` occurs, the following triggers of that rule buffer will not be executed. This allows the rules to simulate "IF .. ELSEIF .. ELSE .. ENDIF". **`break`** will stop the execution for all the triggers that follow this rule inside the rule buffer. If a trigger that ends with `break` occurs, the following triggers of that rule buffer will not be executed. This allows the rules to simulate "IF .. ELSEIF .. ELSE .. ENDIF".
Rules are defined by using the [`Rule<x>`](Commands#rule) command. After defining one you have to activate the rule (turn it on) using `Rule<x> 1`. On other hand you can deactivate the rule using `Rule<x> 0`. Rules are defined by using the [`Rule<x>`](Commands#rule) command. After defining one you have to activate the rule (turn it on) using `Rule<x> 1`. Similarly you can deactivate the rule using `Rule<x> 0`.
See [Commands](Commands#Rules) for a complete list of rules related commands. See [Commands](Commands#Rules) for a complete list of rules related commands.
@ -40,10 +41,12 @@ Rules inside a buffer can be concatenated and have to be in one line:
```on <trigger1> do <command> endon on <trigger2> do <command> endon ...``` ```on <trigger1> do <command> endon on <trigger2> do <command> endon ...```
Spaces after `on`, around `do` and before `endon or break` are mandatory. A rule is **not** case sensitive. Spaces after `on`, around `do` and before `endon` or `break` are mandatory. A rule is **not** case sensitive.
Example of a define rule command: Example of a complete define rule command:
```Rule1 on <trigger1> do <command> break on <trigger2> do <command> endon``` ```
Rule1 on <trigger1> do <command> break on <trigger2> do <command> endon
```
### Rule Trigger ### Rule Trigger
@ -65,34 +68,34 @@ Comparison operators are:
"|" operator is used for modulo remainder = 0 (i.e., exact division) "|" operator is used for modulo remainder = 0 (i.e., exact division)
``` ```
Available triggers: Some of available triggers:
Trigger | When it occurs | Trigger | When it occurs |
------------------|-------------| ------------------|-------------|
System#Boot | occurs once after MQTT is initialized. Due to the command execution order it cannot occur earlier than that. `System#Boot` | occurs once after MQTT is initialized. Due to the command execution order it cannot occur earlier than that.
Mqtt#Connected | when MQTT is connected `Mqtt#Connected` | when MQTT is connected
Mqtt#Disconnected | when MQTT is disconnected `Mqtt#Disconnected` | when MQTT is disconnected
Wifi#Connected | when Wi-Fi is connected `Wifi#Connected` | when Wi-Fi is connected
Wifi#Disconnected | when Wi-Fi is disconnected `Wifi#Disconnected` | when Wi-Fi is disconnected
Time#Initialized | once when NTP is initialized and time is in sync `Time#Initialized` | once when NTP is initialized and time is in sync
Time#Initialized>120 | once, 120 seconds after NTP is initialized and time is in sync `Time#Initialized>120` | once, 120 seconds after NTP is initialized and time is in sync
Time#Set | every hour when NTP makes time in sync `Time#Set` | every hour when NTP makes time in sync
Time#Minute | every minute `Time#Minute` | every minute
Time#Minute==241 | every day once at 04:01 (241 minutes after midnight) `Time#Minute==241` | every day once at 04:01 (241 minutes after midnight)
Time#Minute\|5 | every five minutes `Time#Minute\|5` | every five minutes
Clock#Timer=3 | when global `Timer3` is activated `Clock#Timer=3` | when global `Timer3` is activated
Rules#Timer=1 | when countdown `RuleTimer1` expires `Rules#Timer=1` | when countdown `RuleTimer1` expires
Event#User | when command Event `User` is executed. You can define your own events. `Event#User` | when command Event `User` is executed. You can define your own events.
Power1#State | when a power output is changed<br>use Power1#state=0 and =1 for comparison, not =off or =on<br>Power2 for Relay2, etc. `Power1#State` | when a power output is changed<br>use `Power1#state=0` and `Power1#state=1` for comparison, not =off or =on<br>Power2 for Relay2, etc.
Power1#Boot | after Tasmota starts `Power1#Boot` | after Tasmota starts
Button2#State | when a button changes state:<br>`0` = OFF<BR>`1` = ON<BR>`2` = TOGGLE<BR>`3` = HOLD `Button2#State` | when a button changes state:<br>`0` = OFF<BR>`1` = ON<BR>`2` = TOGGLE<BR>`3` = HOLD
Switch1#State | when a switch changes state:<br>`0` = OFF<BR>`1` = ON<BR>`2` = TOGGLE<BR>`3` = HOLD<BR>(`SwitchTopic 0` must be set for this to trigger) `Switch1#State` | when a switch changes state:<br>`0` = OFF<BR>`1` = ON<BR>`2` = TOGGLE<BR>`3` = HOLD<BR>(`SwitchTopic 0` must be set for this to trigger)
Switch1#Boot | occurs after Tasmota starts `Switch1#Boot` | occurs after Tasmota starts
Dimmer#State | when a the value for Dimmer is changed `Dimmer#State` | when a the value for Dimmer is changed
Dimmer#Boot | occurs after Tasmota starts `Dimmer#Boot` | occurs after Tasmota starts
<a id="ADC0"> </a> Analog#A0div10 | when the `A0` input changes by more than 1% it provides a value between 0 and 100 <a id="ADC0"> </a> `Analog#A0div10` | when the `A0` input changes by more than 1% it provides a value between 0 and 100
VARx#State | when a the value for a Variable is changed `VARx#State` | when a the value for a Variable is changed
MEMx#State | when a the value for a Persistent Variable is changed `MEMx#State` | when a the value for a Persistent Variable is changed
Connected sensors can be a trigger in the form as they are represented in the `TelePeriod` or `Status 8` JSON message. Connected sensors can be a trigger in the form as they are represented in the `TelePeriod` or `Status 8` JSON message.
@ -111,7 +114,7 @@ Devices using RF ([Sonoff RF Bridge](Sonoff-RF-Bridge-433)) or IR are also suppo
Trigger | When it occurs | Trigger | When it occurs |
------------------|-------------| ------------------|-------------|
|`IrReceived#Data=801`| whenever an IR signal for a RC5 remote control button 1 is received| |`IrReceived#Data=801`| whenever an IR signal for a RC5 remote control button 1 is received|
|IrReceived#Data=0x00FF9867|whenever an IR signal with hex code 0x00FF9867 is received| |`IrReceived#Data=0x00FF9867`|whenever an IR signal with hex code 0x00FF9867 is received|
|`RfReceived#RfKey=4`| whenever the [RF Bridge](Sonoff-RF-Bridge-433) receives a recognized RfKey 4 signal |`RfReceived#RfKey=4`| whenever the [RF Bridge](Sonoff-RF-Bridge-433) receives a recognized RfKey 4 signal
[Back To Top](#top) [Back To Top](#top)
@ -166,6 +169,6 @@ Sets Mem2 to the current time (minutes elapsed since midnight)
<br> <br>
After a Wi-Fi reconnect event publish to stat/topic/BLACKOUT a payload containing timestamps of when the Wi-Fi disconnected in *From:* and when the Wi-Fi connected in *To:*. After a Wi-Fi reconnect event publish to stat/topic/BLACKOUT a payload containing timestamps of when the Wi-Fi disconnected in *From:* and when the Wi-Fi connected in *To:*.
***For examples of various rules see [Rule Cookbook](Rule-Cookbook).*** **For examples of various rules use [Rule Cookbook](Rule-Cookbook).**
[Back To Top](#top) [Back To Top](#top)