Tag Archive for M1

Talking to a Ness / Elk M1 Panel via PHP

This is an example of one way to communicate with an Elk / Ness panel via PHP.

If you are looking for a much better way to go about it however – have a look at Remote Panel Access.

<?php
$ness = “192.168.100.1″;        # IP address or FQDN of your panel
$nessport = “2601″;             # Port you wish to connect to (generally 2601)
$usesecure = true;              # Connect with SSL (non zero) or Plain Text

$function = “ua004608″;         # Example “ct” to toggle a zone
$zone = “”;                     # Zone number / input number / output number

if ( $zone <> ” ) {            # Add leading zeros to the zone number if it is specified
$zone = sprintf(“%03d”,$zone);
}

$command = $function.$zone.’00′;        # Add the “future” 00 string
$commandlen = 2 + strlen($command);     # Calculate the length of the command
$commandlen = strtoupper(dechex($commandlen));
if ( strlen($commandlen) == 1) {
$commandlen = ’0′.$commandlen;  # Add a leading zero if required
}
$command = $commandlen.$command;        # Compile the whole command

$chksumasc = 0;

# Add all the Ascii values together
$array = str_split($command);
foreach($array as $char) {
$chksumasc = $chksumasc + ord($char);
}

# Calculate the Mod-256 of the total values
$chksum = bcmod($chksumasc,256);

# Subtract that from 256 to generate the checksum
$chksum = strtoupper(dechex(256-$chksum));

if ($usesecure) {               # If we are securly connecting to the panel prepend the address
$ness = “ssl://$ness”;
}

echo “Connecting to $ness:$nessportnSending: $command$chksumn”;

$fp = fsockopen($ness, $nessport, $errno, $errstr, 30); # Open the TCP connection to the panel
if (!$fp) {
echo “$errstr ($errno)<br />n”;
} else {
$out = $command.$chksum.”rn”;
fwrite($fp, $out);
if (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}

?>

Ness M1

Panel sitting in testing

If there is one thing that I would like to strongly recommend to anybody interested in Home Automation it would be to run away from anything related to the ThinkBoxx offering. It has been one of the most expensive and problematic lessons I could have ever hoped to have endured.

We are currently ripping out the ThinkBoxx from my parents house and upgrading it to a Ness M1 panel. Thus far the Ness panel has mopped the floor with the ThinkBoxx. It offers true ethernet/internet support (even on Mac OSX) and so far has been a real pleasure to build and program.

I will endeavour to provide more information as time progresses about the install of the panel for those who care, and those who don’t – just skip the posts :P

Posted by ShoZu

Switch to our mobile site