Jump to content
c4forums | The Control4 Community

Variables for security zones


sscase

Recommended Posts

I'm looking to set a status of a LED based on all the security zones.  I want it to be red if a zone is open.  My question is should I create a variable for each zone (basement window, kitchen window, mudroom window, office window, etc..) or create one variable with all of them in it?  I'm guessing the answer will be to create a variable for each one so it provides me flexibility in programming other events.

 

Thanks

Link to comment
Share on other sites


If you're planning to have that one LED to turn red if any of those zones is open, you'd create one variable for that LED (not one for each zone).

Variable would be number.

When zone opens, +1

When zone closes -1

 


If variable changes

IF variable is greater than 0

-set LED to RED

IF variable is less then or equal to 0

-set LED to Green

-variable = 0 {just to prevent underruns}

Link to comment
Share on other sites

Thanks, I understand the bottom part.  However, how do I create the "zone open +1" and "zone closes -1"?  Don't I need to create a variables (number) for each zone:

 

Garage Door (number) variable

Kitchen Window (number) variable

Office Window (number) variable 

etc..

 

So, then under my "LED turn red variable" I have the following conditions:

 

If Garage door is open

-variable (garage) = +1

If Garage door is closed

-variable (garage) = -1

etc....

 

I haven't done much with variables as numbers.  Maybe this is the convoluted way of doing it, I would prefer simple and elegant. 

 

Thanks!

Link to comment
Share on other sites

No, the variable you created is a number variable. Call it 'LED variable'

 

 

When zone x opens (exact wording depends on sensor type)

-variable [LED variable] +1

 

 

Reverse for close

 

What this effectively does is when ANY of these zones is open - the LED is red

If ALL zones are closed, it's green.

 

This, to my understanding is what you were looking for.

Link to comment
Share on other sites

I do it a different way, I create a macro and put the following in:

 

----------------------

if window/door1 is open 

turn led red

stop

 

if window/door2 is open

turn led red

stop

 

if window/door3 is open

turn led red

stop

 

if window/door4 is open 

turn led red

stop

 

turn led green

--------------------

 

Then I just call the macro from each window/door "When contact state changes".

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...