Hi Wade,

I know where you are coming from, I was there a little while ago.

This is some of the code that I use. Note that I define all of my items in the MHT file. NOT as per the first line in your sample code.

# =================================================================
# Sample from items.mht

# Standard Lights etc
X10A,       A5,     Verandah_Light,       House|Lights|Outside
X10I,       A2,     Neils_Bed_Lamp,       Master_Bedroom(1;1)|House|Master_Bedroom, CM11               

# The keypads are hidden, note the use of the word "hidden" in the line. This means that will not be displayed on the WEB page

# The next is a standard X10 RF wall plate
X10A,       D1,     KeyPad_Office_Lights, Keypad|hidden

# The next is my "Vehicle Announcer" that I have made, it plugs into the cigarrete lighter and annouces via MH
# when my car is leaving or arriving (It knows the differance).
X10A,       C13,    Car_Vo,             Vehicle|Louise|hidden,    RF                 



# =================================================================
# I have this in a library of routines that I'm gradually building.
# I have my own speak subroutine that I use, basically if security is on then movement and turning ON of lights
# is announced over the house speaker system.
sub main::MySpeak {
          my ($a, $b) = @_;
          if (state $mode_security eq "armed") {
            speak $a ;
           }
       }



# =================================================================
# Mode selection
sub Security_OFF {
        speak "Turning Security OFF";
        set $mode_security "unarmed";
  print "Turning Security OFF";
}; 


sub Security_ON {
  print "Security system ON - Print ";
  print_log "Security system ON - Print_Log";
        speak "Security system ON";
        set $mode_occupied "work";
        set $mode_mh "normal";
        set $mode_security "armed";
}; 

sub Arm_Security {
  print "Arming Security in 2 minutes";
        speak "Arming Security in 2 minutes";
  set $timer_security_startup 2*60, Security_ON, 1;
#  if $timer_security_startup(seconds_remaining_now ) == 60 {
#         speak "Arming Security in 2 minutes";
#       }
}; 


# =================================================================
# Weather
My Wife loves to know the weather
if (time_now '07:00 AM') {
  speak "Current Temperature is $Weather{TempInternet}" ;
  speak "Forecast is $Weather{Forecast}";
  speak "Forecast Max Temp is $Weather{ForecastMaxTemp}" ;
}

# =================================================================
# Master_Bedroom
#      
  MySpeak("Good morning!") if time_now "7 am" and $Weekday and !$Holiday;

        if (time_now '05:00 AM' and $Weekday and !$Holiday){
                print_log "Set Neils_Bed_Lamp to 30%";
                set $Neils_Bed_Lamp DIM;
        }

        if (time_now '07:00 PM') {
                print_log "Set Neils_Bed_Lamp to 50%";
                set $Neils_Bed_Lamp "50%";
        }


        if (time_now '06:15 AM') {
                print_log "Set Neils_Bed_Lamp to ON";
                set $Neils_Bed_Lamp ON;
        }

        if (time_now '07:00 AM') {
                print_log "Set Neils_Bed_Lamp to OFF";
                set $Neils_Bed_Lamp OFF;
        }

        if (time_now '11:59 PM') {
                print_log "Set Neils_Bed_Lamp to OFF";
                set $Neils_Bed_Lamp OFF;
        }



# ==================================
# These come from a X10 RF keypad module
if (state_now $KeyPad_Driveway eq 'on')  {
    set $Driveway 'on';
        MySpeak("Driveway ON");
}

if (state_now $KeyPad_Driveway eq 'off')  {
    set $Driveway 'off';
        MySpeak("Driveway OFF");
}
# =================================================================
# PIR Movement Sensor Routines

    if ((state $mode_sleeping eq "all") and (state_now $Hallway_PIR eq 'motion')){
        MySpeak("Intruder Detected, Turning Hall Light ON");
        set_with_timer $Hallway '50%', 60;
        }
   
    if ((state $mode_sleeping eq "nobody") and (state_now $Hallway_PIR eq 'motion')){
        MySpeak("Intruder Detected, Turning Hall Light ON");
        set_with_timer $Hallway '100%', 300;
        }
   

# =================================================================
# EOD Routines - Do this twice, just because it is X10 and not 100% reliable
        if (time_now '10:30 PM') {
                print_log "Turning OFF all Lights and Appliances";
                set $Lights OFF;
                set $Appliances OFF;
        }

        if (time_now '10:40 PM') {
                print_log "Turning OFF all Lights and Appliances";
                set $Lights OFF;
                set $Appliances OFF;
        }

Regards,

Neil.


> -----Original Message-----
> From: Wade Guthrie [mailto:wade@adventure101.com]
> Sent: Thursday, 31 March 2005 4:41 PM
> To: misterhouse-users@lists.sourceforge.net
> Subject: [misterhouse-users] Bare Perl X10 help
>
>
> Okay, so I'm a code monkey with a masochistic streak.  I want
> to write
> bare Perl code but I'm looking for a programming interface
> more like the
> 'mh' mainloop than, simply, ControlX10.pm.  What modules do I
> 'use' in a
> Perl program to be able to do the following:
>
>   $light = new X10_Item 'B1';
>   set $light ON;
>
> Also, why isn't the misterhouse library tree supposed to be
> installed in
> the perl lib directory (or should it)?
>
> Eventually, I'll probably just use 'mh' the way it was
> intended.  Before
> that, however, I think I just want to experiment some.  But, since I
> seem to be a bit of a doofus, I need a little help.
>
> Thanks!
>
> --
> Wade
> wade@adventure101.com
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by Demarc:
> A global provider of Threat Management Solutions.
> Download our HomeAdmin security software for free today!
> http://www.demarc.com/info/Sentarus/hamr30
> ________________________________________________________
> To unsubscribe from this list, go to:
> http://sourceforge.net/mail/?group_id=1365
>
>
>
>