Updated Rules (markdown)

Adrian Scillato 2018-05-20 18:01:43 -03:00
parent 132103905a
commit 2f653b1ac8
1 changed files with 10 additions and 1 deletions

@ -248,4 +248,13 @@ mqtt: ``cmnd/[topic]/event anyname=number``
Everything together:
``rule on event#togglevar1 do event toggling1=%var1% endon on event#toggling1<1 do event setvar1=1 endon on event#toggling1>0 do event setvar1=0 endon on event#setvar1 do var1 %value% endon on event#getvar1 do var1 endon on event#message do publish stat/sonoff/log %value% endon``
``rule on event#togglevar1 do event toggling1=%var1% endon on event#toggling1<1 do event setvar1=1 endon on event#toggling1>0 do event setvar1=0 endon on event#setvar1 do var1 %value% endon on event#getvar1 do var1 endon on event#message do publish stat/sonoff/log %value% endon``
**NOTE**
Note that the following won't work:
``rule on event#setvar1 do backlog var1 %value%; power1 %var1% endon``
Well at least not as you probably would expect. The var1 value used by the power1 command will be the value present before the backlog command is executed. This is so, because the rule will replace %var1% BEFORE the backlog commands are put in the backlog-log.