how to find out if the house is occupied

emck

Member
So I have a loop that check to see if the house is occupied or empty. 
 
Here is what I have
 
 
Code:
EVERY 5 MINUTES
                AND IF Inside Home OFF
                AND IF BackStairMotion NOT READY
                AND IF Living Motion NOT READY
                AND IF Dining Motion NOT READY
                AND IF Kitchen Motion NOT READY
                AND IF Master bed Motion NOT READY
                AND IF Edward Office NOT READY
                        THEN Ocupied FLAG ON
                        THEN Unocupied FL OFF

EVERY 5 MINUTES
                AND IF Inside Home OFF
                AND IF Edward Office SECURE
                AND IF BackStairMotion SECURE
                AND IF Living Motion SECURE
                AND IF Dining Motion SECURE
                AND IF Kitchen Motion SECURE
                AND IF Master bed Motion SECURE
                        THEN Ocupied FLAG OFF
                        THEN Unocupied FL ON
 
 
 
This code don’t seem to work, I was wandering why this doesn’t work and if there is a better way of doing this?
 
Thanks for your help
Edward
 
I'm an Elk guy not HAI, but the simple fact is that you're requiring a motion sensor to be tripped somewhere during that exact moment in time when the system checks the status.  That seems very optimistic since motion sensors only detect while something is moving (if you sit on the couch it won't see you until you move your arms or lean or something).
 
In the Elk world, I would do some equivalent of:
 
Whenever Edward Office becomes NOT-SECURE then Turn on output 99 for 15 minutes (restart if running)
Whenever BackStairMotion becomes NOT-SECURE then Turn on output 99 for 15 minutes (restart if running)
Whenever Living Motion becomes NOT-SECURE then Turn on output 99 for 15 minutes (restart if running)
Whenever Dining Motion becomes NOT-SECURE then Turn on output 99 for 15 minutes (restart if running)
Whenever Kitchen Motion becomes NOT-SECURE then Turn on output 99 for 15 minutes (restart if running)
 
Whenever Output 99 Turns On then set Occupied flag ON
Whenever Output 99 Turns Off then set Occupied flag OFF
 
Not sure the point of two separate flags for the same thing - a false occupied is the same as a true unoccupied...  and by triggering an extension of the timer every time motion is sensed that has a far better chance of success than someone triggering a motion at the exact moment the program cycles.
 
Here is the HAI version for Work2Play's code:

                WHEN Edward Office SECURE
                WHEN BackStairMotion SECURE
                WHEN Living Motion SECURE
                WHEN Dining Motion SECURE
                WHEN Kitchen Motion SECURE
                WHEN Master bed Motion SECURE
                        THEN Occupied FLAG ON for 15 minutes
 
Every time the motion is detected in one of the zones, the occupied flag will turn on for 15 minutes (you can choose the appropriate time for your situation). If no motion is detected during that time, the flag will turn off.
 
First you have "AND IF Inside Home OFF" in both blocks.
But I assume that is a typo not the actual code.

Whenever I have a large number of items I do this with counter flags to monitor the totality of the sensors.
e.g., I do this with windows so my HVAC won't turn on until all windows are closed.

Something like this

Code:
WHEN Inside Home OFF
WHEN BackStairMotion NOT READY
WHEN Living Motion NOT READY
WHEN Dining Motion NOT READY
WHEN Kitchen Motion NOT READY
WHEN Master bed Motion NOT READY
WHEN Edward Office NOT READY
    THEN INCREMENT Ocupied FLAG


WHEN Inside Home OFF
WHEN Edward Office SECURE
WHEN BackStairMotion SECURE
WHEN Living Motion SECURE
WHEN Dining Motion SECURE
WHEN Kitchen Motion SECURE
WHEN Master bed Motion SECURE
    THEN Decrement Ocupied FLAG


WHEN Ocupied FLAG ON
    THEN Unocupied FL OFF


WHEN Ocupied FLAG OFF
    THEN Unocupied FL ON
 
So as sensors become NOT READY the counter counts up and as they become SECURE it counts down.
If ANY sensor is NOT READY, then the flag has a non zero value, and is thus ON, and the unoccupied flag is OFF.
The unoccupied flag will only turn ON when ALL of the sensors are SECURE and the occupied flag turns OFF.
 
When testing for OCCUPIED you want to know when ANY motion sensor is activated (NOT SECURE). This is an OR condition not an AND as you have it in you first block of code. The part about "Inside Home OFF" needs to be AND'ED with all of the OR'ED motion sensors being activated.
 
But you still have the problem of only checking the sensors at a given moment in time.
 
Look at Work2Play's idea. That's what you want to do.
 
Just to point out, my code above is nested OR statements and doesn't rely on a timer running which can expire and induce a false result.
 
I'm not a HAI user so I have to ask, where are the ORs in that block of code? :wacko: ;)
 
Curious syntax but if it does the job.
 
Thanks so much for all the great replies. I tried the code below and when the flag occupied is on the Unocupied flag goes off and verse visa. But the flag doesn’t increment when a motion NOT READY am I missing something?
Code:
WHEN Inside Home OFF
WHEN BackStairMotion NOT READY
WHEN Living Motion NOT READY
WHEN Dining Motion NOT READY
WHEN Kitchen Motion NOT READY
WHEN Master bed Motion NOT READY
WHEN Edward Office NOT READY
    THEN INCREMENT Ocupied FLAG


WHEN Inside Home OFF
WHEN Edward Office SECURE
WHEN BackStairMotion SECURE
WHEN Living Motion SECURE
WHEN Dining Motion SECURE
WHEN Kitchen Motion SECURE
WHEN Master bed Motion SECURE
    THEN Decrement Ocupied FLAG


WHEN Ocupied FLAG ON
    THEN Unocupied FL OFF


WHEN Ocupied FLAG OFF
    THEN Unocupied FL ON
 
As mentioned you really don't need both flags - it's not a great habit to get into using two when one will do.
 
What is "Inside Home"?
 
Inside Home OFF is when the security system is off for the Home. I have 3 different areas (Home, Garage, Basement)
 
OK the you need to have logic that "says":
 
When the security system is OFF and ANY motion sensor is ACTIVATED then set the OCCUPIED flag to TRUE
 
When the security system is OFF and NO motion sensor is ACTIVATED then set the OCCUPIED flag to FALSE
 
Now the problem here is that if you are present but not moving MOTION sensors will go INACTIVE (There are things called OCCUPANCY sensors that work better for this but that is another topic).
 
So need to decide how to handle this. ONE way is to consider the house to be occupied if ANY motion sensor HAS been ACTIVED within some time period.
 
So that becomes:
 
When the security system is OFF and ANY motion sensor is ACTIVATED then start (or re-start) a TIMER for XX minutes AND set the OCCUPIED flag to TRUE
 
When the timer TIMES OUT then set the OCCUPIED flag to FALSE
 
As long as ANY motion sensor is activated within the time period XX minutes the TIMER will keep running and the OCCUPIED flag will stay TRUE. The OCCUPIED flag will only be reset to FALSE when NO motion sensor has been activated with the time period XX minutes and the timer TIMES OUT.
 
Of course if someone were to fall asleep on the couch and not move for twice XX minutes then the OCCUPIED flag will end up FALSE, which is incorrect.
 
Frederick C. Wilt said:
I'm not a HAI user so I have to ask, where are the ORs in that block of code? :wacko: ;)
 
Curious syntax but if it does the job.
The ORs are implied.
All of the WHEN lines are triggers, if ANY of them occur then the conditionals are evaluated, and if satisfied, the executable actions are taken. 
HAI has written OR statements in the conditionals.
 
it is possible for several trigegrs to then evaluate several differnt blocks of conditionals and then eventually take the same actions.
 
so this code:
 

WHEN Inside Home OFF
WHEN BackStairMotion NOT READY WHEN Living Motion NOT READY
WHEN Dining Motion NOT READY
WHEN Kitchen Motion NOT READY
WHEN Master bed Motion NOT READY
WHEN Edward Office NOT READY
    THEN INCREMENT Ocupied FLAG
 
Can be read as:
 

WHEN Inside Home OFF
OR
WHEN BackStairMotion NOT READY WHEN Living Motion NOT READY
OR
WHEN Dining Motion NOT READY
OR
WHEN Kitchen Motion NOT READY
OR
WHEN Master bed Motion NOT READY
OR
WHEN Edward Office NOT READY
    THEN INCREMENT Ocupied FLAG
 
If ANY of the triggers occur, then the flag will be incremented.
 
Back
Top