Need help with Elk M1 Rules

upstatemike

Senior Member
I'm trying to convert a Stargate event into an Elk M1 Rule and am having a hard time figuring out how to do it efficiently. All the event does is monitor eleven inputs shared between the Stargate and Elk units and turns on a relay whenever one or more of the inputs is on and shuts the relay off again whenever all the inputs are clear. The inputs monitor eleven lighting zones in the basement and the relay operates an indicator over the door to the basement stairs to let me know if any lights have been left on. Here is the existing Stargate event:
 
Event: Basement Indicator
If
(DI: Basement Stairs) is ON
or (DI: Wood Room)
or (DI: Lab1)
or (DI: Lab2)
or (DI: Lab3)
or (DI: Lab4)
or (DI: Storage Room)
or (DI: Furnace Room)
or (DI: Pump Room)
or (DI: Workshop)
or (DI: Telephone Room)
Then
(RELAY: SG16) ON
Else
(RELAY: SG16) OFF
End
 
How can I replicate this in the Elk M1 without using a whole ton of separate rules?
 
I think you would have to do something like this.
 
Whenever every 1 minute   (or x seconds, if you need faster indications)
  AND Zone 017 IS Secure
  OR  Zone 018 IS Secure
  OR  Zome 019 IS Secure
    ...
    THEN Turn Output 016 ON
 
Whenever every 1 minute
  AND  Zone 017 IS Not Secure
  AND  Zone 018 IS Not Secure
  AND  Zone 019 IS Not Secure
    ...
    THEN Turn Output 016 OFF
 
My assumption is that when a light is on, the zone input is closed, indicating secure status. 
 
So, if one or more of the zones is secure,  the indicator light will be turned on.  If all the zones are not secure, then no lights are on, and the indicator is turned off.
 
upstatemike said:
Looks like you are correct... back to the drawing board!
 
The simple solution is to use separate rules to turn on the Output that controls the indicator light.
 
i.e.
 
Whenever Zone 17 Becomes Secure
  Then Turn Output 016 ON
Whenever Zone 18 Becomes Secure
  Then Turn Output 016 ON
...
 
This gives you the same result as if you had an OR operator.  You don't need to use time as a trigger, since the change of state of just the single zone will trigger the rule.
 
I know you said you'd prefer not to use separate rules, but this approach doesn't really use any more rule space than if you were able to write everything as a single rule.   
 
I used to do something kinda similar to keep track of all exterior doors.  I had a rule for each zone - when it became not-secure, it'd increase a counter - and whenever the zone became secure, it decreased the counter.  If the counter hit zero, the alerts turned off.  As long as the counter was >=1, then it would turn on an output that would beep the keypads.  
 
I have indoor-only cats, but contractors and kids kept leaving the damned doors open - this was hugely helpful, and brought a little extra attention to the fact that I had a good security system to strangers in my house.
 
I'm not running an Elk right now - but if you need rule examples, I probably have a copy cached on the other computer...  I think it'd work perfectly for what you're trying to do.
 
I can do a rule for each zone but with eleven inputs involved that seems like a lot of rules. Maybe doesn't take up much rule space but what about rule count? Is there a limit to the number of rules?
 
Reminds me just how well designed the Stargate rules engine is!
 
upstatemike said:
I can do a rule for each zone but with eleven inputs involved that seems like a lot of rules. Maybe doesn't take up much rule space but what about rule count? Is there a limit to the number of rules?
 
Reminds me just how well designed the Stargate rules engine is!
 
Elk doesn't document the limits of the rules engine very clearly, but my understanding is that the M1G has a limit of 528 rules (a rather strange number).   Each Whenever, AND and Then clause counts as a rule. Earlier I said that writing things as separate rules doesn't really use any more rule space.  So that isn't quite true - I'd forgotten that the Then clauses count as rules.
 
If you were able to write all those OR conditions for 11 inputs into a single rule, it would total 13 rules.  Writing them separately as 11 separate rules takes up 22 rules. A small difference overall in this particular case.
 
OK at least I know I can do it on the M1 if the Stargate ever fails but for now I'll leave it on the single Stargate event for easier editing and management.
 
Back
Top