Presence_Monitor.pm |
Example initialization:
These are to be placed in a *.mht file in your user code directory.
First, make sure you have an occupancy monitor:
OCCUPANCY, om
Then, create your presence objects:
PRESENCE, sensor_X, om, presence_X
This creates a new Presence_Monitor object of name 'presence_X' and attaches it to both the occupancy monitor and 'sensor_X'. The 'sensor_X' object must already have been defined and needs to be either a Door_Item or a Motion_Item.
Optional settings:
You can have occupancy automatically expire after X seconds of no activity (no doors opened or motion in the room):
$presence_X->occupancy_expire(3600); # Expire after 1 hour
When using this feature, consider how long a person might remain in the room without creating any motion. This will depend on the room and the motion detector coverage. Obviously a room with motion detector coverage only on the entrances/exits would need a longer expiration time. A hallway could have a pretty short expiration time, but a room in which you might sit and read a book for two hours needs a longer expiration time.
The purpose of this feature is to cause an errant occupancy to eventually expire. This is especially useful for rooms like a closet that might get false-positive presence and nobody else goes near it for a long time. Also for a room like a hallway that basically nobody ever stays in... yet there is lots of activity in and out and one of the outs might be missed.
Automating timers:
You can now add arbitrary commands to a presence object that will be run after a room has been vacant or occupied for the specified amount of time. Here are examples:
$om_presence_master_bedroom->add_presence_timer(15, 'speak("bedroom presence")');
$om_presence_master_bedroom->add_vacancy_timer(15, 'speak("bedroom vacant")');
These examples cause the specified text to be spoken after a room has been continuously occupied for 15 seconds or continuously vacant for 15 seconds.
Setting occupancy:
set_count(): This function can be used to set the number of people
in a specific room. Set to 0 to vacate the room, or a positive number
to set the number of people in the room.
Output states:
vacant: Nobody is in the room
predict: Somebody may be entering the room
occupied: Somebody is in the room
This is an object that is attached to the Occupancy Monitor (usually $om) as well as one Door_Item or Motion_Item. It maintains whether or not there is presence (or predicted presence) within a given room. You should have one per room in your house, even if the room has multiple motion detectors. Not only will this object show up on floorplan.pl, but it can also be attached to a Light_Object to make sure the light remains on when somebody is present. If the light has prediction enabled it will also cause the light to turn on when somebody may be entering the room.
Generic_Item
watch_dog
This watch_dog timer method will look for conditions where the room is occupied but no occupancy expiration timer is in play.
get_time_diff
Returns the number of seconds since the last motion in the room
NONE
Jason Sharpee jason@sharpee.com
Special Thanks to: Bruce Winter - MH
NONE
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Presence_Monitor.pm |