|
How to interface Homeseer with PHP |
|
|
|
Written by Dan
|
|
Wednesday, 17 March 2004 13:52 |
|
This tutorial will show you how easy it is to control your Homeseer devices with a PHP script. - Configure DCOM (Check the 'Related Articles' section).
- Install & configure Apache + PHP (Check the 'Related Articles' section).
- Create a new file in your webroot directory using notepad, name it index.php.
- Paste the following code into the index.php file (make sure you change Homeseer.Application to whatever the object is named in your DCOM configuration screen, usually the other name is Homeseer.ClsString.
<?php $hs = new COM("HomeSeer.Application"); $List=$hs->GetDeviceList(); print "<table>"; for($i=1; $i < $List->Count() + 1; $i++) { $What=$List->item($i); $device="<tr>"; $device.="<td width=50>$i</td>"; $device.="<td>$What->Name</td>"; $device.="<td>$What->Location</td>"; $device.="<td>$What->Status</td>"; $device.="<td>$What->hc</td>"; $device.="<td>$What->dc</td>"; $device.="<td>$What->misc</td>"; $device.="<td>$What->interface</td>"; $device.="<td>$What->dev_type_string</td>"; $device.="<td>$What->buttons</td>"; $device.="</tr>\n"; print $device; } print "</table>"; unset($hs); ?> - Go to http://localhost (or the ip address of your machine), and you should see a listing of all the Homeseer devices you have, including all details.
- Here are some other examples on how to control HS using PHP:
- Turn on a device named "A4":
$hs->ExecX10("a4","off","0","0"); - Write to the Homeseer log file:
$hs->WriteLog("PHP","This is a test"); - To check the status of a device named "A4":
$hs->devicestatus("A4");
That's it! Forum Thread |