[How-To] Interfacing PHP and Homeseer


Staff member
<span style='font-size:14pt;line-height:100%'>How to interface Homeseer using PHP</span>
by electron

1) Configure DCOM: http://www.cocoontech.com/index.php?showtopic=294

2) Install Apache & PHP: http://www.cocoontech.com/index.php?showtopic=305

3) Create a new file in your webroot directory using notepad, name it index.php.

4) 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.

   $hs = new COM("HomeSeer.Application");
   print "<table>";
   for($i=1; $i < $List->Count() + 1; $i++) { 
	  $device.="<td width=50>$i</td>";
	  print $device;
   print "</table>";

5) 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.

6) Here are some other examples on how to control HS using PHP:

Turn on a device named A4:

Write to the HS log file:
$hs->WriteLog("PHP","This is a test");

To check the status of a device named A4:
Just tried this How-To and wanted to let you know it worked with no errors.

Can you expand on this topic a little. How would i send an off, on, and dim commands. I am using Z-wave devices. Does it make any differnece what type of device it is or are all the commands the same?

Maybe you could provid us with an example similar to the status control page that comes with homeseer
I added some examples to the how-to, as you can see it just uses the command syntax shown in the HS help files.
Heres another example whic was written by a newb (me) if i can do it than anyone here can do it.

<head> </head>
$hs = new COM("HomeSeer.Application");

$click = $_GET['click'];
$address = $_GET['address'];

if ($click==on) {
} else {

echo '<a href="' . $_SERVER['PHP_SELF'] . '?address=q20&click=on">Q20 On</a><p>';
echo '<a href="' . $_SERVER['PHP_SELF'] . '?address=q20&click=off">Q20 Off</a>';


Change out q20 for the address code of the device you want to control
Hello all. My name is Dale Higgs. I was just posting to let you know that I have made a plugin for HomeSeer that allows you to easily interface PHP and HomeSeer without the use of an extra webserver, just HomeSeer's built in one. The forum topic is located on HomeSeer's message board. Here is a direct link to the topic: http://ubb.homeseer.com/eve/ubb.x?a=tpc&s=...3515#1776003515 Hope you guys find this useful! If you need to contact me for ideas, questions, or concerns, please email me at [email protected]. Please note that you do have to remove "_NO_SPAM" from the email address.
When i use this code i get a return of all 17's (Unknown) but i know for a fact that the status is known.


I have come up with a temporary work around but it doesnt support Dim and I had to add some extra code in. Basically what I did was called $hs->DeviceCount and then used $hs->GetDevice(i) to create the Device Object. Then I called the function isOn and isOff and place them in an If Statement to determine if the device is on or off. $hs->isON("A1") Looks Something like this...

Code Not Tested:(WIll Test Later)
$hs = new COM("HomeSeer.Application");


for i=1,$DeviceCount+1, i < 1{
   set $Devices = $hs->GetDevice(i);

   if ($hs->isOn($Device)) {
      ***Do Stuff***
  elseif ($hs->idOff($Device)){
      ***Do Something Else***

So im happy that i figured out the work around and I can live with it but I would love to be able to read an actual status and determin the actual dim level that the light is set to. Does anyone here have an idea of what i need to do in order to get that information?
Squintz, according to the HS scripting docs (in the HS help file), dim level as a numeric value (%) is held on the X10 devices (A-P,1-16) in the devicevalue. You can access this using the built-in scirpting DeviceValue(), SetDeviceValue(), and DeviceValueByName() functions.

I'm not sure if the Z-Wave value is held here as well. Supposedly, for non-X10 devices, you can use this value for whatever you want.

So, your code will probably have to figure out if the device type is dimmable (which is a flag in the device object - dv.can_dim), then determine where the dim value would be found, and finally display it on your page.

There is also a series of flags in the dv.misc portion of the device object that tells what type of dim the device supports, but you'd probably only need that info if you were trying to dim the device under program control.
I'm trying to set this up with apache (+php) on my FreeBSD box, how do I tell it to find 'HomeSeer.Aplication' on the Windows box ?


Pete C
Unfortunately that isn't going to work, apache/php has to be installed on the same machine as HS.
not to be a PITA, but I thought DCOM could do this ? ?

(the newbie status is correct, looking for the 'why not")

Pete C
Pete, you are right about DCOM, it's just that I have never gotten it to work, and I have never heard of anyone else who has gotten it to work either.