I'm looking for members here who are interested in understanding the Elk rules engine. I think that a discussion about the following code can help lead to that end.
I came up with the following logic to be able to end executing rules at any point in the rule list and it is not as complicated as it appears on the surface. All normal rules would need to include an "and counter1 =0" statement for this to work. In order to end further execution of rules you would end any rule with a "then" clause that set the counter1 to the value of 2.
Here's how it works:
Setting counter1 = 2 causes all following rules in the list to be ignored because counter1 is not equal to 0.
Then the second to last rule sets counter1 to1 which causes an event that causes the rules list to be read/evaluated again but nothing fires again because counter1 is not equal to 0.
Then the last rule finally resets counter1 to zero and again nothing fires because enough time has passed for the initial event that started all of this has expired.
Spanky if you read this I would appreciate it if you could give me the advantage of your knowledge of how rules work and tell me if I'm way off base or if this looks do-able.
Here's a simple example where nothing will ever fire after rule 1.
BEGIN LIST OF AUTOMATION RULES
1 WHENEVER SUNRISE
AND quit rules (Counter 1) IS EQUAL TO 0
THEN TURN ALL UNITS OFF, HOUSECODE A
THEN SET quit rules (Counter 1) TO 2
2 WHENEVER SUNRISE
AND quit rules (Counter 1) IS EQUAL TO 0
THEN TURN ALL UNITS OFF, HOUSECODE A
3WHENEVER SUNSET
AND quit rules (Counter 1) IS EQUAL TO 0
THEN TURN ALL LIGHTS ON, HOUSECODE A
END LIST OF AUTOMATION RULES AND BEGIN CONTROL RULES
BEGIN LIST OF CONTROL RULES
4 WHENEVER quit rules (Counter 1) CHANGES TO 2
THEN SET quit rules (Counter 1) TO 1
THEN TURN Output 001 (Out 1) ON FOR 1 SEC
5 WHENEVER quit rules (Counter 1) CHANGES TO 1
AND Output 001 (Out 1) STATE IS OFF
THEN SET quit rules (Counter 1) TO 0
I came up with the following logic to be able to end executing rules at any point in the rule list and it is not as complicated as it appears on the surface. All normal rules would need to include an "and counter1 =0" statement for this to work. In order to end further execution of rules you would end any rule with a "then" clause that set the counter1 to the value of 2.
Here's how it works:
Setting counter1 = 2 causes all following rules in the list to be ignored because counter1 is not equal to 0.
Then the second to last rule sets counter1 to1 which causes an event that causes the rules list to be read/evaluated again but nothing fires again because counter1 is not equal to 0.
Then the last rule finally resets counter1 to zero and again nothing fires because enough time has passed for the initial event that started all of this has expired.
Spanky if you read this I would appreciate it if you could give me the advantage of your knowledge of how rules work and tell me if I'm way off base or if this looks do-able.
Here's a simple example where nothing will ever fire after rule 1.
BEGIN LIST OF AUTOMATION RULES
1 WHENEVER SUNRISE
AND quit rules (Counter 1) IS EQUAL TO 0
THEN TURN ALL UNITS OFF, HOUSECODE A
THEN SET quit rules (Counter 1) TO 2
2 WHENEVER SUNRISE
AND quit rules (Counter 1) IS EQUAL TO 0
THEN TURN ALL UNITS OFF, HOUSECODE A
3WHENEVER SUNSET
AND quit rules (Counter 1) IS EQUAL TO 0
THEN TURN ALL LIGHTS ON, HOUSECODE A
END LIST OF AUTOMATION RULES AND BEGIN CONTROL RULES
BEGIN LIST OF CONTROL RULES
4 WHENEVER quit rules (Counter 1) CHANGES TO 2
THEN SET quit rules (Counter 1) TO 1
THEN TURN Output 001 (Out 1) ON FOR 1 SEC
5 WHENEVER quit rules (Counter 1) CHANGES TO 1
AND Output 001 (Out 1) STATE IS OFF
THEN SET quit rules (Counter 1) TO 0