I use one $om for everything. I struggled with this in the beginning. It can be very complex and I spend hours viewing and debugging the code. I never felt that I fully grasped it all. However, it now works pretty well.

This is what I have in my .mht file:

X10MS,    N2,    ms_guestroom,            Sensors|Inside_Motion,        Lynx10PLC,    MS13
X10MS,    D2,    ms_laundry,                Sensors|Inside_Motion,        Lynx10PLC,    MS13
X10MS,    D6,    ms_livingroom,            Sensors|Inside_Motion,        Lynx10PLC,    MS13
X10MS,    DA,    ms_back_hall,            Sensors|Inside_Motion,        Lynx10PLC,    Motion
X10MS,    DB,    ms_back_hall_brightness,        Sensors|Brightness_Sensors,        Lynx10PLC,    Brightness
X10MS,    DC,    ms_powder_room,            Sensors|Inside_Motion,        Lynx10PLC,    MS13
X10MS,    P2,    ms_front_door,            Sensors|Outside_Motion,        Lynx10PLC,    MS13
X10MS,    P4,    ms_side_yard,            Sensors|Outside_Motion,        Lynx10PLC,    MS13
X10MS,    P7,    ms_bedroom_hall_mbr,    Sensors|Inside_Motion,        Lynx10PLC,    MS13
X10MS,    P9,    ms_bedroom_hall_kit,    Sensors|Inside_Motion,        Lynx10PLC,    MS13
X10MS,    PB,    ms_basement,            Sensors|Inside_Motion,        Lynx10PLC,    MS13
X10MS,    PD,    ms_bathroom,            Sensors|Inside_Motion,        Lynx10PLC,    MS13


MOTION,    livingroom_motion,        mo_livingroom
MOTION,    kitchen_motion,            mo_kitchen
MOTION,    computer_motion,        mo_computer
MOTION,    mbr_motion,                mo_mbr
MOTION,    mbr_closet_motion,        mo_mbr_closet
MOTION,    ms_bedroom_hall_mbr,    mo_bedroom_hall_mbr
MOTION,    ms_bedroom_hall_kit,    mo_bedroom_hall_kit
MOTION,    ms_livingroom,            mo_ms_livingroom
MOTION,    ms_back_hall,            mo_ms_back_hall
MOTION,    ms_guestroom,            mo_ms_guestroom
MOTION,    ms_basement,            mo_ms_basement
MOTION,    ms_bathroom,            mo_ms_bathroom
MOTION,    ms_laundry,                mo_ms_laundry
MOTION,    ms_powder_room,            mo_ms_powder_room

OCCUPANCY,    om
PRESENCE,    mo_kitchen,                om,    presence_kitchen
PRESENCE,    mo_mbr,                    om,    presence_mbr
PRESENCE,    mo_computer,            om,    presence_computer
PRESENCE,    mo_mbr_closet,            om,    presence_mbr_closet
PRESENCE,    mo_livingroom,            om,    presence_livingroom
PRESENCE,    mo_ms_livingroom,        om,    presence_livingroom2
PRESENCE,    mo_ms_back_hall,        om,    presence_back_hall
PRESENCE,    mo_bedroom_hall_mbr,    om,    presence_hallway_mbr
PRESENCE,    mo_bedroom_hall_kit,    om,    presence_hallway_kit
PRESENCE,    mo_ms_guestroom,        om,    presence_guestroom
PRESENCE,    mo_basement_door,        om,    presence_basement_door
PRESENCE,    mo_ms_basement,            om, presence_basement
PRESENCE,    mo_ms_bathroom,            om, presence_bathroom
PRESENCE,    mo_ms_laundry,            om, presence_laundry
PRESENCE,    mo_ms_powder_room,        om, presence_powder_room

And then in code:

# noloop=start

    $presence_kitchen->add_presence_timer(1, 'speak("kitchen presence") if $Debug{presence}');
    $presence_kitchen->add_vacancy_timer(120 , 'speak("kitchen vacant") if $Debug{presence}');
    $presence_kitchen->occupancy_expire(600);  # Expire after 10 mins
   
    $presence_livingroom->add_presence_timer(1, 'speak("living room presence") if $Debug{presence}');
    $presence_livingroom->add_vacancy_timer(120 , 'speak("living room vacant") if $Debug{presence}');
    $presence_livingroom->occupancy_expire(7200);  # Expire after 2 hours
    $presence_livingroom2->occupancy_expire(7200);  # Expire after 2 hours
   
    $presence_mbr->add_presence_timer(1, 'speak("bedroom presence") if $Debug{presence}');
    $presence_mbr->add_vacancy_timer(120, 'speak("bedroom vacant") if $Debug{presence}');
    $presence_mbr->occupancy_expire(600);  # Expire after 5 mins
   
    $presence_mbr_closet->add_presence_timer(1, 'speak("closet presence") if $Debug{presence}');
    $presence_mbr_closet->add_vacancy_timer(30, 'speak("closet vacant") if $Debug{presence}');
    $presence_mbr_closet->occupancy_expire(300);  # Expire after 5 mins
   
    $presence_hallway_mbr->add_presence_timer(1, 'speak("master hall presence") if $Debug{presence}');
    $presence_hallway_mbr->add_vacancy_timer(30, 'speak("master hall vacant") if $Debug{presence}');
    $presence_hallway_mbr->occupancy_expire(45); 
   
    $presence_hallway_kit->add_presence_timer(1, 'speak("kitchen hall presence") if $Debug{presence}');
    $presence_hallway_kit->add_vacancy_timer(30 , 'speak("kitchen hall vacant") if $Debug{presence}');
    $presence_hallway_kit->occupancy_expire(45); 

    $presence_guestroom->add_presence_timer(1, 'speak("guest room presence") if $Debug{presence}');
    $presence_guestroom->add_vacancy_timer(120 , 'speak("guest room vacant") if $Debug{presence}');
    $presence_guestroom->occupancy_expire(300);  # Expire after 5 mins

    $presence_basement->add_presence_timer(1, 'speak("basement presence") if $Debug{presence}');
    $presence_basement->add_vacancy_timer(120 , 'speak("basement vacant") if $Debug{presence}');
    $presence_basement->occupancy_expire(120);  # Expire after 2 mins

    $presence_basement_door->add_presence_timer(1, 'play "forcefieldon.wav"');
    $presence_basement_door->add_vacancy_timer(30 , 'play "forcefieldoff.wav"');
    $presence_basement_door->occupancy_expire(300);  # Expire after 5 mins

    $presence_bathroom->add_presence_timer(1, 'speak("master bath presence") if $Debug{presence}');
    $presence_bathroom->add_vacancy_timer(5 , 'speak("master bath vacant") if $Debug{presence}');
    $presence_bathroom->occupancy_expire(8*60);  # Expire after 8 mins
   
    $presence_computer->add_presence_timer(1, 'speak("computer room presence") if $Debug{presence}');
    $presence_computer->add_vacancy_timer(120 , 'speak("computer room vacant") if $Debug{presence}');
    $presence_computer->occupancy_expire(900);  # Expire after 15 mins
   
    $presence_laundry->add_presence_timer(1, 'speak("laundry room presence") if $Debug{presence}');
    $presence_laundry->add_vacancy_timer(120 , 'speak("laundry room vacant") if $Debug{presence}');
    $presence_laundry->occupancy_expire(300);  # Expire after 5 mins

    $presence_powder_room->add_presence_timer(1, 'speak("powder room presence") if $Debug{presence}');
    $presence_powder_room->add_vacancy_timer(120 , 'speak("powder room vacant") if $Debug{presence}');
    $presence_powder_room->occupancy_expire(300);  # Expire after 5 mins

    $presence_back_hall->add_presence_timer(1, 'speak("back hall presence") if $Debug{presence}');
    $presence_back_hall->add_vacancy_timer(30 , 'speak("back hall vacant") if $Debug{presence}');
    $presence_back_hall->occupancy_expire(45);  # Expire after 5 mins
   
   
    # Hallway attaches to all three rooms
    $om->set_edges($mo_mbr, 1, 6, 10);
    $om->set_edges($mo_bedroom_hall_mbr, 1, 2, 7, 11);
    $om->set_edges($mo_bedroom_hall_kit, 2, 3, 4);
    $om->set_edges($mo_kitchen, 2, 3, 4, 5);
    $om->set_edges($mo_livingroom, 4);
    $om->set_edges($mo_ms_livingroom, 4);
    $om->set_edges($mo_ms_back_hall, 5, 8, 12);
    $om->set_edges($mo_mbr_closet, 6);
    $om->set_edges($mo_ms_guestroom, 7);
    $om->set_edges($mo_ms_basement, 8);
    $om->set_edges($mo_basement_door, 8);
    $om->set_edges($mo_ms_bathroom, 10);
    $om->set_edges($mo_computer, 11);
    $om->set_edges($mo_ms_laundry, 12, 13);
    $om->set_edges($mo_ms_powder_room, 13);
   
    $om->tie_event('om_monitor($state, $object)');

# noloop=stop


And then for making sure lights only come on when I want do stuff like:


# noloop=start

use Light_Restriction_Item;
my $only_when_dark = new Light_Restriction_Item();
$only_when_dark->attach_hash_key(\%Save, 'dark_inside');
$only_when_dark->{object_name}='$only_when_dark';

my $only_when_light = new Light_Restriction_Item();
$only_when_light->attach_hash_key(\%Save, 'light_inside');
$only_when_light->{object_name}='$only_when_light';

my $not_sleeping = new Light_Restriction_Item();
#$not_sleeping->attach_hash_key(\%Save, 'sleeping_parents', 0, "");
$not_sleeping->attach_hash_key(\%Save, 'awake');
$not_sleeping->{object_name}='$not_sleeping';

my $only_when_home = new Light_Restriction_Item();
$only_when_home->attach_hash_key(\%Save, 'at_home');
$only_when_home->{object_name}='$only_when_home';

$mbr_Light->set_states(('off', '20', '40', '60', '80', '100', 'on'));
$mbr_Light->delay_off(120);
$mbr_Light->add ( $presence_mbr );
$mbr_Light->add ( $only_when_dark );
$mbr_Light->add ( $not_sleeping );
$mbr_Light->add ( $only_when_home );

# noloop=stop



On Fri, Jan 24, 2014 at 5:05 PM, Craig Lindholm <344clinton@gmail.com> wrote:
Hello.

Currently, I am using motion detectors (MS13a and MS16a) to turn the lights on/off using timers in the various rooms in my house, but while its ok for turning lights on, its not too good for turning them off when, for example, I am reading and not moving. Then I came across the article on "Occupancy_Monitor" from the Wiki, and would like to implement it. 

While the article has some great information, I am having trouble grasping how to use it and have some questions.

1) Do I need one $om per sensor or is $om a "one per house"? For example, do I use for two items:

-----------------------------------------------------------------
X10MS, B13, x10_example_motion_detector, , MS13
X10MS, B16, x10_example_motion_detector2, , MS13
MOTION, x10_example_motion_detector, example_motion_detector
MOTION, x10_example_motion_detector2, example_motion_detector2
OCCUPANCY, om
-> OCCUPANCY, om2
PRESENCE, example_motion_detector, om, presence_example_room
PRESENCE, example_motion_detector2, om2, presence_example_room2
and
$om->set_edges($example_motion_detector, 1, 2, 3);
$om2->set_edges($example_motion_detector2, 1, 2, 3);
------------------------------------------------------------------
or
-----------------------------------------------------------------
X10MS, B13, x10_example_motion_detector, , MS13
X10MS, B16, x10_example_motion_detector2, , MS13
MOTION, x10_example_motion_detector, example_motion_detector
MOTION, x10_example_motion_detector2, example_motion_detector2
-> OCCUPANCY, om
PRESENCE, example_motion_detector, om, presence_example_room
PRESENCE, example_motion_detector2, om, presence_example_room2
and
$om->set_edges($example_motion_detector, 1, 2, 3);
$om->set_edges($example_motion_detector2, 1, 2, 3);
------------------------------------------------------------------

Also, I am unsure how to use said monitor in my user code.
Can anyone please send me some sample code (.mht, and.pl code) on it's implementation? 

Thanks in advance

Craig

PS. I am using version: 3.0 on Raspberry Pi
Perl: 5.14.2

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
________________________________________________________
To unsubscribe from this list, go to: http://sourceforge.net/mail/?group_id=1365





--
-Craig