Flag

uptito

Member
I'm trying to use flag on PC Access to program OP2 to automatically set alarm to night mode after certain time and if all zones are secured. I used flag to track zone status. But for some reason, it's not working as expected. In other words, if all zones are always secured, the flag never gets set as expected, I assume. However, it works fine if one of the zone statuses change from "not ready" to "secure." Isn't flag default value "Off"?

Here is the simple version of what I'm trying to accomplish which doesn’t work: I increment a flag every time any zone is violated; otherwise, decrement it. If flag is off and time is greater than 8:00Pm, set alarm to Night Mode.

WHEN Main Door Entry NOT READY
WHEN Back Door Entry NOT READY
WHEN Dinning Door Entry Thr Garage NOT READY
THEN INCREMENT Ready Alarm Flag
WHEN Main Door Entry SECURE
WHEN Back Door Entry SECURE
WHEN Dinning Door Entry Thr Garage SECURE
THEN DECREMENT Ready Alarm Flag
WHEN Ready Alarm Flag OFF
AND IF TIME IS GREATER THAN 8:00 PM
THEN PROGRAM ARM NIGHT
 
At the bottom, you are checking for WHEN the flag transitions to OFF, not IF it is OFF at any time.
So the last block of code ONLY trips when the flag transitions to OFF.

When the flag transitions to OFF (everytime), the Omni checks the time, if it is greater than 8:00 PM (and less than midnight), it programs ARM NIGHT.

But if the flag never transitons after 8:00 PM the block of code won't run.
If you want it to check at 8:00PM or some other time, you have to tell it to check at a time (which will occur once a day) or use an EVERY command.

Your flag increment.decrement look correct.

Try something like this to check at 8:PM:
Code:
TIMED 8:00 PM MTWTFSS
	AND IF Ready Alarm Flag OFF
		THEN PROGRAM ARM NIGHT

Use this to check once at 8:00PM and anytime after 8:00PM when the flag becomes secure (in case you go in and out).
Code:
TIMED 8:00 PM MTWTFSS
WHEN Ready Alarm Flag OFF
	AND IF Ready Alarm Flag OFF
	AND IF Time is GREATER THAN 7:59PM
		THEN PROGRAM ARM NIGHT

To constantly re-check (between 8:00pm and midnight), or anytime the flag transitions to OFF, try something like this:
Code:
EVERY 20 MINUTES
WHEN Ready Alarm Flag OFF
	AND IF Ready Alarm Flag OFF
	AND IF Time is GREATER THAN 7:59PM
		THEN PROGRAM ARM NIGHT

If you want to "roll over" the day to check the flag, for instance check from 8:00PM to 6:00AM, use a time clock.
Activate the time clock at 8:00PM and turn it off at 6:00 AM.
Then use a conditional, replace the "AND IF time is greater than..." line with:
Code:
AND IF Timeclock 1 is ON
 
That was a very helpful and detailed example. I'll give it a try tonight and see what happens. Thanks alot!!
 
Back
Top