[juneau-lug] Re: X10 PHP script
- From: Jamie <jamie@xxxxxxxxxxxxxxxxx>
- To: juneau-lug@xxxxxxxxxxxxx
- Date: Wed, 01 Mar 2006 12:41:39 -0900
East Wind wrote:
>Hello Jamie,
>
>Wednesday, March 1, 2006, 10:01:11 AM, you wrote:
>
>J> X10 is an electrical control system for home automation. You plug your
>J> light or whatever into an x10 switch box and control it by modulating a
>J> signal on your house wiring. One linux program that interfaces to a
>J> controller is called BottleRocket (br is the executable). So from the
>J> command line you say something like: "br A10 on" or "br A16 off". Next
>J> I wanted a web page that would issue the commands, but it was too big
>J> for my web enabled cell phone. So it got shortened and the following is
>J> the tiny working version of the script that my mobile phone can use to
>J> switch electrical devices on and off in my home.
>
>What piece of hardware are you using to actually put the
>X10 commends on the wire? A serial device? Or one of
>the newer USB devices?
>May I have a copy of the long version of this web page?
>That is...if it'll work with my USC Powerlinc.
>
>
>
The BottleRocket software I use only works with the "firecracker" serial
interface.
http://www.x10.com/automation/firecracker.htm
http://www.linuxha.com/bottlerocket/
My big X10 php web pages(2) :
==originating form==============================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd";>
<HTML>
<HEAD>
<TITLE>X10 House Controls</TITLE>
</HEAD>
<BODY>
<H2>X10 House Controls</H2>
<FORM method="POST" action="xcontrol_rcv.php">
<table style="width: 700px; background-color: rgb(255, 204, 204);"
align="left" border="1" cellpadding="5" cellspacing="0" width="1">
<caption>"A" House Codes</caption>
<tbody>
<?php
$a = array (
1 => "device A01",
2 => "device A02",
3 => "device A03",
4 => "device A04",
5 => "device A05",
6 => "device A06",
7 => "device A07",
8 => "device A08",
9 => "device A09",
10 => "device A10",
11 => "device A11",
12 => "device A12",
13 => "device A13",
14 => "device A14",
15 => "device A15",
16 => "device A16"
);
for ($i = 1; $i <= 8; $i++) {
$j = $i + 8;
print " <tr>\n";
print " <td>$a[$i]</TD>\n";
print " <td><INPUT type=\"submit\" name=\"Button\" value=\"A$i
ON\"></td>\n";
print " <td><INPUT type=\"submit\" name=\"Button\" value=\"A$i
OFF\"></td>\n";
if ($i==1) {
print " <td colspan=\"1\" rowspan=\"8\"style=\"vertical-align: top;
background-color: rgb(255, 255, 255);\"><br>\n";}
print " <td>$a[$j]</TD>\n";
print " <td><INPUT type=\"submit\" name=\"Button\" value=\"A$j
ON\"></td>\n";
print " <td><INPUT type=\"submit\" name=\"Button\" value=\"A$j
OFF\"></td>\n";
print " </tr>\n";
print "\n";
};
?>
</tbody>
</TABLE>
<table style="width: 700px; background-color: rgb(204, 255, 204);"
align="left" border="1" cellpadding="5" cellspacing="0" width="1">
<caption><br><br>"B" House Codes</caption>
<tbody>
<?php
$a = array (
1 => "device B01",
2 => "device B02",
3 => "device B03",
4 => "device B04",
5 => "device B05",
6 => "device B06",
7 => "device B07",
8 => "device B08",
9 => "device B09",
10 => "device B10",
11 => "device B11",
12 => "device B12",
13 => "device B13",
14 => "device B14",
15 => "device B15",
16 => "device B16"
);
for ($i = 1; $i <= 8; $i++) {
$j = $i + 8;
print " <tr>\n";
print " <td>$a[$i]</TD>\n";
print " <td><INPUT type=\"submit\" name=\"Button\" value=\"B$i
ON\"></td>\n";
print " <td><INPUT type=\"submit\" name=\"Button\" value=\"B$i
OFF\"></td>\n";
if ($i==1) {
print " <td colspan=\"1\" rowspan=\"8\"style=\"vertical-align: top;
background-color: rgb(255, 255, 255);\"><br>\n";}
print " <td>$a[$j]</TD>\n";
print " <td><INPUT type=\"submit\" name=\"Button\" value=\"B$j
ON\"></td>\n";
print " <td><INPUT type=\"submit\" name=\"Button\" value=\"B$j
OFF\"></td>\n";
print " </tr>\n";
print "\n";
};
?>
</tbody>
</TABLE>
</FORM>
</BODY>
</HTML>
==Receiving Form (which executes br, pauses and
returns)========================
<?php
function exCode() {
$c = $_POST[Button];
echo ("<h1>$c</H1><br>\n");
$c = "/usr/bin/br ".$c;
echo("<hr>$c $_SERVER[argc]<hr><br>\n");
$res = system($c,$rc);
if ($rc <> 0 ) {
echo "<br><pre>Return Code=$rc</pre><br>";
echo "<pre>Message=$res</pre>";
};
}
function processForm() {
echo "
<HTML><HEAD>
<meta HTTP-EQUIV=\"REFRESH\" content=\"2; url=xcontrol.php\">
<TITLE>Processing Form</TITLE>
</HEAD>
<BODY>";
echo "<BR>Values received from the form:<br>";
// view_values( $_POST );
exCode();
echo "<BR></body></html>";
}
processForm();
?>
------------------------------------
The Juneau Linux Users Group -- http://www.juneau-lug.org
This is the Juneau-LUG mailing list.
To unsubscribe, send an e-mail to juneau-lug-request@xxxxxxxxxxxxx with the
word unsubscribe in the subject header.
Other related posts: