Auto-Scheduling for Stay Arm with PHP
Posted: Thu Feb 21, 2013 9:34 am
Hi,
I wanted to automatically arm my DSC Alarm every night when I go to bed and automatically disarm it in the morning when waking up. I tested the built-in functionality of the DSC panel, but it didn't exactly do what I wanted. I wanted the system to auto-arm in "stay" mode only when I'm at home and I didn't want it to auto-disarm if I'm away. So I built a small and simple PHP script that I run twice daily using a CRON job; I run it at 10pm and at 6am daily. It does exactly want I want to do and is pretty reliable so far. You get alerted with an email if the script can not do its job. I realize that I'm giving away my alarm code in the script, but it's not a script that's available on the Internet, I just run it using CRON in a hidden folder on a free server out there. I'm okay with that... Here is the script in case someone would want to replicate this functionality. Comments and suggestions are welcome.
I wanted to automatically arm my DSC Alarm every night when I go to bed and automatically disarm it in the morning when waking up. I tested the built-in functionality of the DSC panel, but it didn't exactly do what I wanted. I wanted the system to auto-arm in "stay" mode only when I'm at home and I didn't want it to auto-disarm if I'm away. So I built a small and simple PHP script that I run twice daily using a CRON job; I run it at 10pm and at 6am daily. It does exactly want I want to do and is pretty reliable so far. You get alerted with an email if the script can not do its job. I realize that I'm giving away my alarm code in the script, but it's not a script that's available on the Internet, I just run it using CRON in a hidden folder on a free server out there. I'm okay with that... Here is the script in case someone would want to replicate this functionality. Comments and suggestions are welcome.
Code: Select all
<?php
$m = "00AA11BB22CC"; // MAC Address of Envisalink
$h = "1234567890abcdefghijklmnopqrstuvwxyz"; // HASH Key
$p = "5555"; // A code that can arm and disarm the system
$URL = "https://www.eye-zon.com/EZMOBILE/indexapi.php";
$email = "youremail@somewhere.com";
$Short_Status = $URL."?mid=".$h."&action=ssi&did=".$m;
$Stay_Arm = $URL."?mid=".$h."&action=c&did=".$m."&com=arm_stay";
$Disarm = $URL."?mid=".$h."&action=c&did=".$m."&com=send_pin&pin=".$p;
$statusfile = "<?xml version='1.0'?><dsc>".trim(file_get_contents($Short_Status))."</dsc>";
$statusxml = simplexml_load_string($statusfile);
if (trim($statusxml->trouble) == "NO")
{
if (trim($statusxml->status) == "Stay Armed")
{
$execute = file_get_contents($Disarm);
}
else if (trim($statusxml->status) == "Ready")
{
$execute = file_get_contents($Stay_Arm);
}
}
else
{
mail($email, 'TROUBLE DETECTED', "TROUBLE DETECTED. CHECK STATUS OF ALARM.");
}
?>