Newbie question about flags

rs691919

Member
Hi, very new to HAI programming and trying to figure out some things!  When a flag is turned on by a particular trigger, if that trigger continues to "fire", will the flag be reset?
 
For example, I want a flag to turn on when a motion dectector is "NOT READY":
 
When Dining Motion is NOT READY
                 THEN turn Dining Timer for 15 minutes
 
Let's say I set off the dining motion sensor and the flag turns on.  I walk out of the room.  I come back in the room 10 minutes later and the motion sensor detects me again.  At that point, does the Dining Timer flag reset to zero or keep counting down from the original 15 minutes?
 
 
Yes, the flag will continue to be reset to 15 minutes.
Each time the motion sensors BECOMES Not Ready.
If it never returns to Secure, then it cannot BECOME Not Ready and the flag will not be reset and will time out after 15 minutes.


A flag can be reset to a longer time than the time it has remaining as it is counting down but not a shorter time unless it is turned off first.
 
Ok, that makes sense.  So if I want to turn lights off when a room is not occupied for 15 min, would the following work:
 
1. When Dining Motion is NOT READY
            Then turn Dining Timer on for 15 minutes
2. Every 1 minute
             And if Dining Motion is Secure
             And if Dining Timer is OFF
                   Then turn Dining Room Lights off.
 
This goes back to the question I asked about occupancy sensors in the other HAI marketplace forum.  Thanks!
 
You could use the timer itself as a trigger.
 

WHEN Dining Timer OFF
    THEN Dining Room Lights OFF

 
 
 
Or you can set the timer on the lights themsleves without using an additional flag.
 

Code:
WHEN Dining Motion NOT READY
    THEN Dining Room Lights ON FOR 15 MINUTES
 
I played around with those too, but I don't want the lights to turn on when the motion is triggered -- otherwise my son would run all over the house triggering lights just for the fun of it!  And if i use the timer as a trigger by itself, the lights will go off after 15 minutes even if someone is in the room.  I want them to turn off only if someone is really not in the room for 15 minutes.  That's why I think an occupancy sensor will be better than a motion sensor, but I can't figure out if there are wireless occupancy sensors that are compatible with the Omni. 
 
You guys are close.... do this:
 
1. When Dining Motion is NOT READY
            Then turn Dining Timer on for 15 minutes
 
2. When Dining Timer is OFF
             And if Dining Motion is Secure
                   Then turn Dining Room Lights off.
 
3. When Dining Timer is OFF
             And if Dining Motion is NOT READY
                   Then turn Dining Timer on for 15 minutes
 
The first block hits the flag when motion is detected and starts the clock.
Second block waits for the 15 minutes to end.  If it ends and there is no motion, then kill the lights.
Third block waits for the 15 minutes to end as well... but only proceeds if the motion sensor is still not ready, and re-starts the whole shebang again.
 
Neillt's way will reset the timer even if the motion detector never transitions back to SECURE and ensure there is no motion.
 
Thanks for the reply, neillt.  Being new to this (and not a programmer by trade), I probably don't understand the nuances.  Would the way that I had suggested not work for my application or is there a reason that your code would be better? 
 
neillt's way doesn't rely on the EVERY trigger.
You want to minimize the use of those if you can.
 
His only takes action when something happens.
 
The motion goes unsecure, start a timer
The timer stops, check and see if there is still motion
If there is still motion, reset the timer
 
With the EVERY trigger you are checking EVERY 1 minute; even at 2 AM, even if something else is going on, even if you are on vacation.
 
Basic difference in how you treat motion detector events.
 
Picture this:
 
You are having a party.  There is enough motion that the motion detector never goes from "motion" (i.e. Not Ready) to "no motion" (i.e. secure).  The first time the detector trips the 15 minute timer starts.  During the 15 minutes the party folks keep the detector latched at Not Ready, and it never transitions to secure and back to not ready.  HAI panels only respond to changes in status, so it will never reset the timer, even though the sensor is still detecting motion.
 
So, since the timer never resets, the 15 minute timer expires and the lights turn off in the middle of your party.  By adding the block about checking the status of the detector, you won't turn off the lights that time around, and reset the timer to 15 minutes again.
 
The downside is that if for some reason the detector fails or is latched on, the auto-off feature won't work.
 
OK, I'm following you both (thanks again!).  In my version, if the party is going on and the motion sensor is NOT READY for more than 15 minutes, then all of a sudden goes SECURE because of a break in the action, then the lights will go off.  Is that correct?
 
In neillt's version, the motion sensor can be NOT READY for, say, 25 minutes but the Dining Timer will remain on because as soon as it goes off and the sensor is NOT READY, the timer turns back on again. Is my logic on track?
 
Back
Top