[ale] BottleRocket

Mike Fletcher fletch at phydeaux.org
Fri Jul 16 10:49:00 EDT 1999


--Multipart_Fri_Jul_16_10:48:59_1999-1
Content-Type: text/plain; charset=US-ASCII

>>>>> "Eric" == S Eric Asberry <eric at sedonna.com> writes:

[...]

    Eric> I guess my only complaint is that I wish the handheld remote
    Eric> had more range.  My computer is upstairs ... since I can
    Eric> control everything from the computer, I'd like to keep the
    Eric> remote downstairs.  Unfortunately, it only works from
    Eric> downstairs if I'm right at the bottom of the stairway.  :(

	Check your batteries and where you've got the receiver
positioned.  I've used my remote from a good ways away (~10 yards
outside my house :) and it still worked.

	And to be somewhat on topic, here's a web page (using
HTML::Embperl under Apache w/mod_perl on Linux) that'll use
bottlerocket to toggle a light and remember what state it's in
(assuming you don't use the above mentioned remote :).  Currently
kinda hard coded to one light, but then if all you've got is the
starter kit that's not a problem.  Of course, if you do this on a
machine accessable from the outside world you'd definately want to
password protect it. :)


--Multipart_Fri_Jul_16_10:48:59_1999-1
Content-Type: text/plain; charset=US-ASCII
Content-Disposition: attachment; filename="x10.epl"
Content-Transfer-Encoding: 7bit

</pre>
<html>

<head>
<title>X10 Control</title>
</head>

[! 
use CGI::Carp;

sub light_on {
  local( *STATE );
  my $light = uc(shift);
  open( STATE, "> /tmp/.x10_$light" ) 
    or do { carp "Error on open: $!\n"; return };
  print STATE "ON\n";
  close( STATE );
  return 1;
}

sub light_off {
  local( *STATE );
  my $light = uc(shift);
  open( STATE, "> /tmp/.x10_$light" ) 
    or do { carp "Error on open: $!\n"; return };
  print STATE "OFF\n";
  close( STATE );
  return 1;
}

sub light_state {
  local *STATE;
  my $light = uc(shift);

  unless( open( STATE, "/tmp/.x10_$light" ) ) {
    carp "Error on open: $!\n"; 
    return "UNKNOWN";
  }

  $retval = \<STATE>;
  chomp $retval;

  close( STATE );

  return $retval;
}

!]

<body bgcolor="#ffffff">

<h1>X10</h1>

[$ if scalar keys %fdat $]
[+
   if( $fdat{ ON } ) {
     system q{/home/fletch/bin/br B1 on};
     light_on 'B1';
     "Lights on."
   } elsif( $fdat{ OFF } ) {
     system q{/home/fletch/bin/br B1 off};
     light_off 'B1';
     "Lights off."
   } else {
     "Unknown action."
   }
+]
[$ endif $]

<p>
B1 is currently [+ light_state( 'B1' ) +].
</p>

<form method="POST">

<input type="submit" name="ON" value="ON" />
<input type="submit" name="OFF" value="OFF" />

</form>
<br />

</body>
</html>
<pre>

--Multipart_Fri_Jul_16_10:48:59_1999-1
Content-Type: text/plain; charset=US-ASCII



-- 
Fletch                |                                            __`'/|
fletch at phydeaux.org   |       "I drank what?" -- Socrates          \ o.O'
678 443-6239(w)       |                                            =(___)=
                      |                                               U

--Multipart_Fri_Jul_16_10:48:59_1999-1--






More information about the Ale mailing list