diff --git a/Rule-Cookbook.md b/Rule-Cookbook.md index 5965783c..c1fedbda 100644 --- a/Rule-Cookbook.md +++ b/Rule-Cookbook.md @@ -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. ``` Rule1 +Rule1 on Time#Initialized 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#chkSunrise<%sunrise% 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 -Rule1 1 +Becklog Rule1 1; Rule2 1 ``` - **Explanation:** \# When device restarts, calculate if the light should be on or off `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=%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 `on event#chkSun do backlog ` @@ -716,8 +724,8 @@ Rule1 1 \# Set variables for Morning (06h00) and Night (22h30) times `Backlog mem1 360; mem2 1350` - \# Turn on the rule set - `Rule1 1` + \# Turn on the rule sets + `Backlog Rule1 1; Rule2 1` [Back To Top](#top)