Still having trouble (PHP/HomeSeer)

pete

Active Member
this is probably just a syntax thing but it's killing me . . .

I'm trying to write a form page to control my hvac system (currently run by an Appdig Leopard). I have a string of buttons (form input types) and a panel that displays current temp, set point and equipment status for the 5 zones.

I can't get the button to actually set the hs->devicestatus, see the code snip below and let me know if you can figure where I'm screwing it up . . .

Thanks

Pete C

Code:
<?php 

include "header.inc";

 
$hs = new COM("HomeSeer.Application");

$hvacMode=$hs->devicevalue("$7")

$z1SetPt=$hs->devicevalue("$8");
$z1Temp=$hs->devicevalue("$46");
$z1Pump=$hs->devicestatus("_9");

$z2SetPt=$hs->devicevalue("$9");
$z2Temp=$hs->devicevalue("$48");
$z2Pump=$hs->devicestatus("_10");

$z3SetPt=$hs->devicevalue("$10");
$z3Temp=$hs->devicevalue("$50");
$z3Pump=$hs->devicestatus("_11");

$z4SetPt=$hs->devicevalue("$11");
$z4Temp=$hs->devicevalue("$49");
$z4Pump=$hs->devicestatus("_12");

$z5SetPt=$hs->devicevalue("$12");
$z5Temp=$hs->devicevalue("$47");
$z5Pump=$hs->devicestatus("_13");



++++  THIS IS WHERE I'M LOST  +++++

if (isset($_POST"modeOff")) {
  $hs->SetDeviceValue("$7","1"); 

} 
?>

<!-- 

++++  THIS IS ASP CODE THAT WAS WORKING  ++++


if Request.Form("modeOff.x") <> nil then
  hs.SetDeviceValue "$7", 1
	elseif Request.Form("modeAuto.x") <> nil then
     hs.SetDeviceValue "$7", 2
	elseif Request.Form("modeHeat.x") <> nil then
     hs.SetDeviceValue "$7", 3	
	elseif Request.Form("modeVent.x") <> nil then
     hs.SetDeviceValue "$7", 4
	elseif Request.Form("modeCool.x") <> nil then
     hs.SetDeviceValue "$7", 5
    end if
-->






<form method="post" action="hvac.php">
<table width="600" border="0" cellspacing="3" cellpadding="0" id="modeButtons">
	<tr><td width="42" valign="center" align="center"><img border="0" src="images/led1On.gif" ></td></td><td width="100"><input type="image" src="images/btnOff.gif" alt="Off" border="0" name="modeOff">

  <td width="15"><td rowspan="6" valign="top" align="center" >
 	 <h1>Heat Mode Status</h1>
 	 <table width="400" border="0" cellspacing="0" cellpadding="3" id="zoneInfo">
 	 <tr align="center"><td width="150"><u><font size="+2">Zone</font></u></td><td><u><font size="+2">Temp</font></u></td><td><u><font size="+2">Set Pt</font></u></td><td><u><font size="+2">Pump</font></u></td></tr>


 	 <tr align="center"><td width="150"><font size="+2">1st Flr Front</font></td><td><font size="+2"><?php print $z2Temp ?></font></td><td><font size="+2"><?php print $z2SetPt ?></font></td><td><font size="+2"><?php print $z2Pump ?></font></td></tr>


 	 <tr align="center"><td width="150"><font size="+2">1st Flr Rear</font></td><td><font size="+2"><?php print $z4Temp ?></font></td><td><font size="+2"><?php print $z4SetPt ?></font></td><td><font size="+2"><?php print $z4Pump ?></font></td></tr>


 	 <tr align="center"><td width="150"><font size="+2">2nd Floor</font></td><td><font size="+2"><?php print $z3Temp ?></font></td><td><font size="+2"><?php print $z3SetPt ?></font></td><td><font size="+2"><?php print $z3Pump ?></font></td></tr>


 	 <tr align="center"><td width="150"><font size="+2">Garage</font></td><td><font size="+2"><?php print $z1Temp ?></font></td><td><font size="+2"><?php print $z1SetPt ?></font></td><td><font size="+2"><?php print $z1Pump ?></font></td></tr>


 	 <tr align="center"><td width="150"><font size="+2">Garage Attic</font></td><td><font size="+2"><?php print $z5Temp ?></font></td><td><font size="+2"><?php print $z5SetPt ?></font></td><td><font size="+2"><?php print $z5Pump ?></font></td></tr>
 	 </table>
      </td>
	</tr>
 
I can't get the button to actually set the hs->devicestatus, see the code snip below and let me know if you can figure where I'm screwing it up
I assume you mean you are having trouble using SetDeviceValue, correct?

Also, there is indeed a syntax error with the POST line:
if (isset($_POST"modeOff")) {
should be
if (isset($_POST['modeOff'])) {
 
I assume you mean you are having trouble using SetDeviceValue, correct?
Yes, I cant get the syntax right . . . the asp code was working in a previous attempt w/ asp, now I need the same code in PHP . . .
 
actually I've been messing with it and can get the hs->setdevicestatus to work now, but for some reason my form isn't working right, I'm not getting anything in $_POST . . .


here's the code so far
Code:
<?php 

include "header.inc";

/*  THIS IS header.inc

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> 
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<title>PHANy - Pete's Home Automation Network</title>
</head>
<body background="images/screen.gif" bgcolor="#808080" text="#FFFF00">
<font face="Arial, Helvetica, Geneva, sans-serif" color="#FFFF00" size="+3">

*/

$hs = new COM("HomeSeer.Application");

$hvacMode=$hs->devicevalue("$7");

$z1SetPt=$hs->devicevalue("$8");
$z1Temp=$hs->devicevalue("$46");
$z1Pump=$hs->devicestatus("_9");

$z2SetPt=$hs->devicevalue("$9");
$z2Temp=$hs->devicevalue("$48");
$z2Pump=$hs->devicestatus("_10");

$z3SetPt=$hs->devicevalue("$10");
$z3Temp=$hs->devicevalue("$50");
$z3Pump=$hs->devicestatus("_11");

$z4SetPt=$hs->devicevalue("$11");
$z4Temp=$hs->devicevalue("$49");
$z4Pump=$hs->devicestatus("_12");

$z5SetPt=$hs->devicevalue("$12");
$z5Temp=$hs->devicevalue("$47");
$z5Pump=$hs->devicestatus("_13");

// THESE LINES ARE NOT WORKING 

if (isset($_POST['name'])) { $name= $_POST['name'];} 

echo "<p>name= {$_POST['name']}</p>";

?>




<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST" >
<table width="600" border="0" cellspacing="3" cellpadding="0" id="modeButtons">
<tr><td width="42" valign="center" align="center"><img border="0" src="images/led1On.gif" ></td></td><td width="100"><input type="image" src="images/btnOff.gif" alt="Off" border="0" name="modeOff">

 <td width="15"><td rowspan="6" valign="top" align="center" >
  <h1>Heat Mode Status</h1>
  <table width="400" border="0" cellspacing="0" cellpadding="3" id="zoneInfo">
  <tr align="center"><td width="150"><u><font size="+2">Zone</font></u></td><td><u><font size="+2">Temp</font></u></td><td><u><font size="+2">Set Pt</font></u></td><td><u><font size="+2">Pump</font></u></td></tr>


  <tr align="center"><td width="150"><font size="+2">1st Flr Front</font></td><td><font size="+2"><?php print $z2Temp ?></font></td><td><font size="+2"><?php print $z2SetPt ?></font></td><td><font size="+2"><?php print $z2Pump ?></font></td></tr>


  <tr align="center"><td width="150"><font size="+2">1st Flr Rear</font></td><td><font size="+2"><?php print $z4Temp ?></font></td><td><font size="+2"><?php print $z4SetPt ?></font></td><td><font size="+2"><?php print $z4Pump ?></font></td></tr>


  <tr align="center"><td width="150"><font size="+2">2nd Floor</font></td><td><font size="+2"><?php print $z3Temp ?></font></td><td><font size="+2"><?php print $z3SetPt ?></font></td><td><font size="+2"><?php print $z3Pump ?></font></td></tr>


  <tr align="center"><td width="150"><font size="+2">Garage</font></td><td><font size="+2"><?php print $z1Temp ?></font></td><td><font size="+2"><?php print $z1SetPt ?></font></td><td><font size="+2"><?php print $z1Pump ?></font></td></tr>


  <tr align="center"><td width="150"><font size="+2">Garage Attic</font></td><td><font size="+2"><?php print $z5Temp ?></font></td><td><font size="+2"><?php print $z5SetPt ?></font></td><td><font size="+2"><?php print $z5Pump ?></font></td></tr>
  </table>
     </td>
</tr>
 
 
<tr><td width="42" valign="center" align="center"><img border="0" src="images/led2Off.gif" ></td><td width="100"><input type="image" src="images/btnAuto.gif" alt="Off" border="0" name="modeAuto">
<tr><td width="42" valign="center" align="center"><img border="0" src="images/led3Off.gif" ></td><td width="100"><input type="image" src="images/btnHeat.gif" alt="Off" border="0" name="modeHeat">
<tr><td width="42" valign="center" align="center"><img border="0" src="images/led4Off.gif" ></td><td width="100"><input type="image" src="images/btnVent.gif" alt="Off" border="0" name="modeVent">
<tr><td width="42" valign="center" align="center"><img border="0" src="images/led5Off.gif" ></td><td width="100"><input type="image" src="images/btnCool.gif" alt="Off" border="0" name="modeCool">
<tr><td width="42" valign="center" align="center"><img border="0" src="images/led6Off.gif" ></td><td width="100"><input type="image" src="images/btnFan.gif" alt="Off" border="0" name="modeFan">
 </td>
</tr>
</table>

 

<?php
unset($hs);
include "footer.inc";

/*  THIS IS footer.inc

</body>
</html>

*/
?>

thanks for all your help !

Pete C
 
at the beginning of your script, add the following code:
echo "<pre>";
print_r($_POST);
echo "</pre>";

This will show anything form related whenever there is data, and should help you troubleshoot your form.
 
Back
Top