Updated Rule Cookbook (markdown)

Michael Ingraham 2019-11-18 14:11:15 -05:00
parent a70728d7a7
commit 07b719af7a
1 changed files with 2 additions and 6 deletions

@ -1497,28 +1497,24 @@ Backlog Rule1 1; Rule2 1; Rule3 1
#### Roller shutter push-button toggle #### Roller shutter push-button toggle
With e.g. Shelly 2.5 configured for a roller shutter with two relays you can also connect your regular push-button switches and set up inverted toggle behaviour. Pressing a push-button once makes the roller shutter move in a direction, pressing it again stops it. The rules each use a variable to remember the state they're in, where `0 == Stopped` and `1 == Moving`. With a device (e.g., Shelly 2.5) configured for a roller shutter with two relays, you can also connect your regular push-button switches and set up inverted toggle behavior. Pressing a push-button once makes the roller shutter move in a direction, pressing it again stops it. The rules each use a variable to remember the state they're in, where `0 == Stopped` and `1 == Moving`.
```lua ```lua
Backlog SwitchTopic 0; SwitchMode1 4; SwitchMode2 4 Backlog SwitchTopic 0; SwitchMode1 4; SwitchMode2 4
Rule1 Rule1
ON System#Boot DO Var1 0 ENDON
ON Switch1#State==1 DO Add1 1 ENDON ON Switch1#State==1 DO Add1 1 ENDON
ON Var1#State==0 DO ShutterStop1 ENDON ON Var1#State==0 DO ShutterStop1 ENDON
ON Var1#State==1 DO ShutterClose1 ENDON ON Var1#State==1 DO ShutterClose1 ENDON
ON Var1#State>=2 DO Var1 0 ENDON ON Var1#State>=2 DO Var1 0 ENDON
ON Shutter1#Close DO Var1 0 ENDON ON Shutter1#Close DO Var1 0 ENDON
Rule2
ON System#Boot DO Var2 0 ENDON
ON Switch2#State==1 DO Add2 1 ENDON ON Switch2#State==1 DO Add2 1 ENDON
ON Var2#State==0 DO ShutterStop1 ENDON ON Var2#State==0 DO ShutterStop1 ENDON
ON Var2#State==1 DO ShutterOpen1 ENDON ON Var2#State==1 DO ShutterOpen1 ENDON
ON Var2#State>=2 DO Var2 0 ENDON ON Var2#State>=2 DO Var2 0 ENDON
ON Shutter1#Open DO Var2 0 ENDON ON Shutter1#Open DO Var2 0 ENDON
Backlog Rule1 1; Rule2 1 Rule1 1
``` ```
[Back To Top](#top) [Back To Top](#top)