Updated Rule Cookbook (markdown)

Michael Ingraham 2019-08-29 15:01:25 -04:00
parent 0a53109b89
commit d7c8114385
1 changed files with 12 additions and 4 deletions

@ -665,8 +665,13 @@ Turn on light at dusk until your nighttime and again in the morning before dawn.
What if the sun sets after your nighttime, as in during the summer? Then the timer will turn off the light at "night", but then the Sunset timer will turn it on again, so it stays on all night. What if the sun sets after your nighttime, as in during the summer? Then the timer will turn off the light at "night", but then the Sunset timer will turn it on again, so it stays on all night.
``` ```
Rule1 Rule1
Rule1
on Time#Initialized do event chkSun endon on Time#Initialized do event chkSun endon
on Time#Minute=%sunset% do event chkSun endon on Time#Minute=%sunset% do event chkSun endon
on Time#Minute=%mem2% do event chkSun endon
on Time#Minute=%sunrise% do event chkSun endon
on Time#Minute=%mem1% do event chkSun endon
Rule2
on event#chkSun do backlog var1 0; event chkSunrise=%time%; event chkSunset=%time%; event chkmorn=%time%; event chknight=%time%; event setPower endon on event#chkSun do backlog var1 0; event chkSunrise=%time%; event chkSunset=%time%; event chkmorn=%time%; event chknight=%time%; event setPower endon
on event#chkSunrise<%sunrise% do var1 1 endon on event#chkSunrise<%sunrise% do var1 1 endon
on event#chkSunset>=%sunset% do var1 1 endon on event#chkSunset>=%sunset% do var1 1 endon
@ -677,15 +682,18 @@ on event#setPower do power1 %var1% endon
``` ```
Backlog mem1 360; mem2 1350 Backlog mem1 360; mem2 1350
Rule1 1 Becklog Rule1 1; Rule2 1
``` ```
- **Explanation:** - **Explanation:**
\# When device restarts, calculate if the light should be on or off \# When device restarts, calculate if the light should be on or off
`on Time#Initialized do event chkSun endon` `on Time#Initialized do event chkSun endon`
\# At Sunset, calculate if the light should be on or off \# Calculate if the light should be on or off
`on Time#Minute=%sunset% do event chkSun endon` `on Time#Minute=%sunset% do event chkSun endon`
`on Time#Minute=%mem2% do event chkSun endon`
`on Time#Minute=%sunrise% do event chkSun endon`
`on Time#Minute=%mem1% do event chkSun endon`
\# Calculate if the light should be on or off \# Calculate if the light should be on or off
`on event#chkSun do backlog ` `on event#chkSun do backlog `
@ -716,8 +724,8 @@ Rule1 1
\# Set variables for Morning (06h00) and Night (22h30) times \# Set variables for Morning (06h00) and Night (22h30) times
`Backlog mem1 360; mem2 1350` `Backlog mem1 360; mem2 1350`
\# Turn on the rule set \# Turn on the rule sets
`Rule1 1` `Backlog Rule1 1; Rule2 1`
[Back To Top](#top) [Back To Top](#top)