Auto-Scheduling for Stay Arm with PHP

Information and support for EnvisaLink modules.

Moderators: EyezOnRich, GrandWizard

Post Reply
Madelinot
Posts: 13
Joined: Sun Feb 10, 2013 12:24 pm

Auto-Scheduling for Stay Arm with PHP

Post by Madelinot »

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.

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.");
  }

?>
Madelinot
Posts: 13
Joined: Sun Feb 10, 2013 12:24 pm

Re: Auto-Scheduling for Stay Arm with PHP

Post by Madelinot »

One of the potential problem and where this script will not really work is if you usually stay arm the alarm when you're in the house. For example, on a weekend, if you stay arm the alarm during the day, then it will disarm at 10pm. I don't usually do that, so it's not an issue for me. A time check could easily be added to the script to circumvent that if needed.
dvoisin
Posts: 2
Joined: Mon Dec 26, 2016 10:21 am

Re: Auto-Scheduling for Stay Arm with PHP

Post by dvoisin »

This script does exactly what I want. Unfortunately I'm getting an error when trying to use indexapi.php:

Warning: pg_connect() [function.pg-connect]: Unable to connect to PostgreSQL server: FATAL: database "eyezon" does not exist in /home/eyezon/EZMOBILE/indexapi.php on line 42
An error occured opening DB.

Am I doing something wrong or is indexapi no longer working?

TIA for your help!
GrandWizard
Posts: 2319
Joined: Tue Nov 16, 2010 4:08 pm

Re: Auto-Scheduling for Stay Arm with PHP

Post by GrandWizard »

That API was deprecated many years ago and removed.

There will be a new developer's API available in the new year. Don't ask me for more info, as I honestly don't know the details.
dvoisin
Posts: 2
Joined: Mon Dec 26, 2016 10:21 am

Re: Auto-Scheduling for Stay Arm with PHP

Post by dvoisin »

GrandWizard wrote:That API was deprecated many years ago and removed.

There will be a new developers API available in the new year. Don't ask me for more info, as I honestly don't know the details.
Okay. Thank you for the prompt response! I look forward to the new API.
Post Reply