mirror of https://github.com/arendst/Tasmota.git
Updated Rule Cookbook (markdown)
parent
cbb03e193e
commit
2e25ab1412
|
@ -22,6 +22,7 @@
|
|||
- [PIR Configuration](Wemos-D1-Mini-and-HC-SR501-PIR-Motion-Sensor#alternative-tasmota-configuration-with-rules-recommended-method)
|
||||
- [Using clock timer to control a luminance-triggered switch only in mornings](#using-clock-timer-to-control-a-luminance-triggered-switch-only-in-mornings)
|
||||
- [Using an external button with single press - double press and hold](#using-an-external-button-with-single-press---double-press-and-hold)
|
||||
- [ANY action on single/double press for switches AND buttons (rules-based)](#any-action-on-singledouble-press-for-switches-and-buttons-rules-based)
|
||||
- [Enable or disable doorbell relay with HTTP call](#enable-or-disable-doorbell-relay-with-http-call)
|
||||
- [Force automatic reconnection to MQTT server via SD DNS](#force-automatic-reconnection-to-mqtt-server-via-sd-dns)
|
||||
- [Change distance to percentage](#change-distance-to-percentage)
|
||||
|
@ -879,7 +880,36 @@ Rule 1
|
|||
```
|
||||
|
||||
[Back To Top](#top)
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
#### ANY action on single/double press for switches AND buttons (rules-based)
|
||||
|
||||
There is a way to program this using rules if you wish to sacrifice a variable.<br>
|
||||
|
||||
**Commands:**
|
||||
```
|
||||
SwitchMode 5
|
||||
Rule1
|
||||
on switch1#state==2 do add1 1 endon
|
||||
on switch1#state==2 do power1 2 endon
|
||||
on var1#state!=0 do backlog delay 6;var1 0 endon
|
||||
on var1#state==2 do publish cmnd/othertasmota/POWER toggle endon
|
||||
|
||||
Rule1 on
|
||||
```
|
||||
|
||||
**Explanation:**
|
||||
|
||||
- each toggle of the switch triggers first condition and adds 1 to our variable (var1 in the example),
|
||||
- each toggle of the switch toggles the associated relay (```power1 2``` - but can do anything else instead, ```publish``` for example)
|
||||
- when var1 changes to non zero, we set it back to 0 but after a ```delay``` (arbitrarily chosen 6 here - 0.6 seconds)
|
||||
- when var1 reaches 2 (i.e. the switch has been toggled twice within the last 0.6 seconds), desired action is triggered (here: ```publish``` to othertasmota)
|
||||
|
||||
**Result:**
|
||||
|
||||
Every time you press the switch your light toggles state (as it should) but if you do it twice in a rapid succession, you can trigger another action elsewhere.
|
||||
|
||||
[Back To Top](#top)
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
#### Enable or disable doorbell relay with HTTP call
|
||||
|
|
Loading…
Reference in New Issue