Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
ademco_alarm_system [2011/12/20 23:39]
berkinet
ademco_alarm_system [2020/12/28 21:59] (current)
Line 1: Line 1:
 +====== How to interface to an Ademco 128BP alarm panel and control it from Indigo ======
 +
 +Note: this How-To assumes you have an Alpha keypad, such as a 6160. If not, you will have a really hard time setting up your system, because you need to go into programming mode to assign an new keypad address. Also, if anyone finds errors or additions, please PM me on the Indigo forum and it will be fixed. ​
 +
 +{{http://​aws.indigodomo.com/​wiki/​ademco_6160_keypad.png}}
 +
 +**1. About this How-To**
 +
 +This How-To is a condensation of my experience in trying to set up and integrate my Ademco 128BP alarm system into Indigo. It was successfully done but took months to understand how it works and get the Serial Bridge Parser to properly function. Hopefully this document will make it faster for you. Be aware that much of the information here is specific to the 128BP and your alarm’s codes and programming may differ. In particular, //note that panel programming on the 50P and higher models differs significantly way from the panel series 10P to 40P.//
 +
 +Credits for this implementation go to Sean Mathews and company for developing the AD2USB and the NuTech forum, Sean, Berkinet and Guinness on the NuTech Forum (Berkinet is also on Indigo), Matt and Jay for Serial bridge, and the folks who developed the DSC alarm parser posted on the forum, on which this parser is based.
 +
 +So, for starters, read the thread “does the AD2USB currently work for OSX” on the Nutech.com Ademco forum:
 +
 +[[http://​www.nutech.com/​index.php?​option=com_fireboard&​Itemid=74&​func=view&​catid=4&​id=266]]
 +
 +and the thread: [[https://​forums.indigodomo.com/​viewtopic.php?​f=6&​t=5884&​start=0&​hilit=ademco]]
 +
 +Most of the details are in these threads, and you can post to them or start new threads as new questions come up. 
 +
 +**2. Get the manuals for your particular alarm** ​
 +
 +Try these sites: ​
 +
 +[[http://​panelguides.com/​panel-guides?​task=viewcategory&​catid=504]]  ​
 +
 +[[http://​www.devicemanuals.com/​downloadguide.php]]
 +
 +Note that you need both the user manual and the programming/​install manual as you will need to be able to access the programming of the unit.
 +
 +**3. Establish communication with your Alarm Panel**
 +
 +Once you have the manual, make sure you can access the alarm’s programming mode. This requires knowing the “installer code”. Typical default installer codes of 4110, 4111, 4112, 4140, 5140. Otherwise you will need to get the installer code from your installer or use something called “panelcrack” which is a search program sold by Nutech to uncover the installer code. 
 +
 +
 +Practice entering programming mode from your panel. To do this, enter the installer code, xxxx and 8000 (I think it is 800 for 10-series panels such as 10, 15, 20, 50 etc, and 8000 for 100-series panels such as 128)
 +
 +{{http://​aws.indigodomo.com/​wiki/​ademco_manual_pic_enter_progr.png}}
 +
 +{{http://​aws.indigodomo.com/​wiki/​ademco_programming_pic.png}}
 +
 +
 +
 +Here are some VERY IMPORTANT POINTS:
 +
 +--Don’t reverse the wiring on the AD2USB as noted below.
 +
 +--If you are futzing with your alarm system, you may wish to call the alarm company so the police are not dispatched. You will rack up false alarm charges if they make multiple trips. ​
 +
 +--When exiting the Ademco programming mode, NEVER enter *98, as this will LOCK OUT the installer code. Although you can re-enter installer mode, it is a pain to do so. 
 +
 +
 +
 +**4. Buy an AD2USB**
 +
 +Once you are certain you can access the programming on your unit, go to the Nutech.com site and purchase an AD2USB Ademco alarm adapter. It costs about $90.00.
 +
 +{{http://​aws.indigodomo.com/​wiki/​nutech_AD2USB_device.png}}
 +
 +
 +This thread describes the output from the AD2USB: http://​www.nutech.com/​forums/​30.html ​ Read it. The parsing in the script below depend on the locations of the data in the stream the AD2USB puts out. 
 +
 +**5. Hook up the AD2USB**
 +
 +Install the AD2USB according to the instructions. Be aware that there is no reverse polarity protection, so don’t hook up the power until you are certain that the wires are correct. It is a lot easier to run a long length of 4-conductor alarm wire than trying to extend the USB connection. Although any 4 conductor wire will work, it might be easier to use standard 4-conductor alarm wire so the colors are consistent. ​
 +
 +In this regard, you can hook up the AD2USB directly from the panel or just piggybacked off a keypad. I piggybacked mine off a keypad, and it is fine.
 +
 +Note for MacOS systems: Depending on the MacOS version you are running, you may or may not need a driver. You can tell quite easily. In a terminal window list the contents of the /dev directory. Then, plug in the ad2usb and recheck the /dev directory. if you see a new device in "/​dev"​ (like /​dev/​tty.usbserial-A9008ABC) you do not need the drivers. If not, you will need to download a driver from www.ftdichip.com/​Drivers/​VCP.htm
 +
 +
 +
 +**Note: If you are on Indigo 5 or later you may wish to install the ad2usb plugin. If you decide to use the plugin, you can skip the remainder of these instructions. See this forum thread for more information. ​ https://​forums.indigodomo.com/​viewtopic.php?​f=22&​t=7584.**
 +
 +
 +
 +**6. Add a KeyPad Address in your Alarm Panel for the AD2USB**
 +
 +Go into your alarm system programming and add a new keypad. I had not realized I had to assign an new keypad IN THE PANEL thru programming and THEN assign a panel number to the AD2USB via Terminal. As such I got a “timeout” (sending……) back when trying to send a command from the terminal (see below). So don’t worry about addressing the AD2USB in Terminal, except perhaps to see if it is working, until you have freed up a Keypad location for it. Note that 00 and 01 are pre-assigned to the first two keypads. If you have only one keypad, use 01, and if you have two keypads use 02, etc. So enter 01, or 02, or 03... 
 +
 +As described on Page 13 and 14 (or 4-2 depending on your version) of the Vista 128BP Programming Guide (of course find the appropriate section in the correct manual for your system, and your actual process may differ), enter programming mode via the installer code and 8000, e.g. xxxx8000. Then enter #93 to enter Menu Mode. You will move through several screens which offer prompts to program (yes =1, no =0, default is 0) by pressing * which serves as the enter key. Don’t make any changes. When you come to the Keypad screen, enter 1. When prompted, enter a new keypad address only, e.g. 01, 02 or 03. Then use *99 to exit repeatedly until you have exited Program Mode.  Again, DO NOT use *98 to exit as this will lock out your installer code.
 +
 +Following my post describing the timeout, Mathewss (Sean on NuTech) describes the procedure as: 
 +
 +<​code>​
 +(the !Sending……) indicates the alarm panel did not accept your command.
 +If it had said !Sending.done or maybe two periods then that is ok. If it sends 6 periods then it timed out.
 +
 +You need to either use another keypad to get into programming and assign a new keypad address for the AD2USB or take another keypad that already works get its current address then disconnect it and assign that address to the AD2USB.
 +
 +To get a keypads assigned address press hold down the keypads 1 and 3 button for several seconds. It should show you its address. ​
 +
 +**(Note: The following is applicable to a 10-series panel, I believe… and is not correct for the 128.)**
 +
 +Once you have an Alpha display up and running you can then more easily using programming locations 190-196
 +
 +To do this enter programming mode INSTALLCODE+800 ex "​4112800"​
 +then enter #190 it will report back the values. When you find one that is not assigned and reports back 0,0 then you can enable that location by entering *196 and entering 1 two times.
 +
 +It is a good idea to document your system so you know what keypads are at what address go over every one and check them.
 +
 +By default address 16 is enabled and can not be disabled.
 +</​code>​
 +
 +
 +**7. Establish communication with the AD2USB from the Terminal**
 +
 +Open the Terminal app and follow Berkinet’s instructions below:
 +
 +<​code>​
 +Before you even get to Serial Bridge, I suggest you just try to connect to your ad2usb from the Terminal. To do this open Terminal and then look for your ad2usb. Use this command:
 +
 +ls -l /​dev/​cu.usbserial-*
 +
 +You will get back something like:
 +
 +crw-rw-rw- 1 root wheel 11, 1 Jun 16 20:44 /​dev/​cu.usbserial-A60089Rb
 +
 +
 +That is the device name for your ad2usb that you will use to connect to it in a live session.
 +
 +Next, enter:
 +
 +sudo cu -l cu.usbserial-A60089Rb
 +
 +Of course, **substitute the address of your ad2usb**
 +</​code>​
 +
 +
 +
 +**8. Assign a Keypad Address to the AD2USB**
 +
 +Once you have successfully entered a keypad location and can open Terminal and address the AD2USB using the command strings above, press ! to open the programming for the AD2USB. Don’t do anything EXCEPT when it asks for the keypad location.
 +
 +Use the following section when assigning your keypad address. ​
 +<​code>​
 +When you are connected, press ! and answer the questions, you will probably want to accept all the defaults EXCEPT for the address, there you will enter the address you have enabled for the ad2usb. This step is important, if the ad2usb is not configured for an enabled address you will be able to receive, but not send commands.
 +
 +Once you have configured the ad2usb you will start to see a stream of messages. You can send commands from your keyboard by just pressing the appropriate keys on your keyboard. For example to disarm the system send xxxx1, where xxxx is your code. You do not need to press return.
 +Press ~. (tilde period) to exit cu.
 +
 +Now that you are sure you can send and receive commands, you can start to try using Serial Bridge. (Connection settings are 19200, 1, none, none.) You should be able to get help on the Indigo Serial Bridge forum, just post some good examples of the input you get in Serial Bridge.
 +
 +By the way, you were sending "​+3"​ to arm the system, you need to send xxxx3 as in the cu example above.
 +</​code>​
 +
 +
 +When the ad2usb prompts you for the Keypad address enter the address you want. Note that 00 and 01 are pre-assigned to the first two keypads. If you have only one keypad, use 01, and if you have two keypads use 02, etc. So enter 01, or 02, or 03... instead of pressing return and accepting the default. Then press return and accept the succeeding defaults.
 +
 +<​code>​
 +Pressing "​!"​ brings up this:
 +
 +Code:
 +
 +!>Keypad Address ​      (18) : 
 +!>​Code ​              ​(0000) : 
 +!>Zone Expanders Y/N Max allowed: 01
 +!>module #01 ZN 09-16 (N) : 
 +!>module #02 ZN 17-24 (N) : 
 +!>module #03 ZN 25-32 (N) : 
 +!>module #04 ZN 33-
 +!>module #05 ZN 41-48 (N) : 
 +!Reading configuration.
 +!UART init.
 +</​code>​
 +
 +
 +
 +**9. Sending commands from the Terminal**
 +
 +Once you have the keypad address assigned correctly, you should be able to send commands from the Terminal. The sequence is your code (not installer code), xxxx and the command you wish to send, e.g. 1 for off, 2 for armed away and 3 for armed stay. Look on your keypad for the other codes such as 7 for instant. ​
 +
 +I have not tested these, but the “instant” keys on the right of the keypad might be able to be sent as well. Below are Berkinet’s suggestions on how to integrate the F keys into Serial Bridge. Be sure to call the alarm company if you are testing these….
 +
 +<​code>​
 +-- First we set up some variables to use
 +-- later in the script
 +set F1 to ascii character 01
 +set F2 to ascii character 02
 +set F3 to ascii character 03
 +set F4 to ascii character 04
 +set connectionName to "​AD2USB"​
 +
 +-- Now we can use the F key variables in a 
 +-- message sent to the ad2usb
 +tell application "​Serial Bridge"​
 +    send to source connectionName string F3   
 +end tell 
 +</​code>​
 +
 +
 +**10. Serial Bridge and AppleScript**
 +
 +Unless you can write code like some of the others can, Serial Bridge is the basic communication with the AD2USB if you want to easily integrate it into Indigo. Although there is a MonoGui available for the AD2USB, I haven’t been able to get it to work on my box. It would require something like Ser2Sock, which is a little beyond my capabilities. ​
 +
 +SB is a paid program, about $25.00, and worth the download. Matt and Jay state it will no longer be supported, but I’ve had no problems with it. One thing to note is that if you get a power outage, unplug or otherwise somehow lose communication with a Serial Bridge device, SB will go nuts and drive the CPU to 100%. You will either need to re-boot or stop your SB connection and re-start it. Luckily this very rarely happens. Nonetheless,​ it is worthwhile to have any SB connected device on a UPS for stability. It is likely that your alarm already has battery backup. ​
 +
 +Following this section is the Serial Bridge code to receive and parse a typical feed from the AD2USB. There are two sets of code, one for a single panel installation (most common) and the second for a two panel installation,​ such as for a house and outbuilding. ​
 +
 +For the single panel script, first create the variables "​AlarmState"​ and "​AlarmDisplay",​ and it will parse the basic alarm messages, Disarmed, Armed Away, and Armed Stay. It will also read the alarm display text that would go to the keypad alpha display.  ​
 +
 +The picture below shows the variables for the two panel script. They differ from the one panel script in that they are distinguished as AlarmHouseState and AlarmGarageState. If you are using only one panel, again use the simpler variables.
 +
 +{{http://​aws.indigodomo.com/​wiki/​alarm_variable_list.png}}
 +
 +Here’s an example of the AD2USB output: ​
 +
 +<​code>​
 +[001000011000--------],​018,​[f71300000018008c28021f00000000]," ​ ARMED STAY 1   ZONE BYPASSED ​ "
 +</​code>​
 +
 +**Single Panel Script:**
 +
 +This script is set up for one panel. It should put the parser output into the variables "​AlarmState"​ and "​AlarmDisplay"​.
 +
 +The actual parser output is right up top in the script under "​commandCodes"​ and is in this format: "001 Armed Stay"
 +
 +Char 2,3 and 4 in the AD2USB output are the alarm state, 001, or Armed Stay, and are the first three characters in the parser output. The parsing output will appear in the variable "​AlarmState"​. The alpha display, " ​ ARMED STAY 1   ZONE BYPASSED ​ ", is what is seen on the keypad and will appear in the variable "​AlarmDisplay"​.
 +
 +
 +<​code>​
 +-- Sample connection attachment script for Serial Bridge.
 +--
 +-- This script, if it is in the same folder as the Serial Bridge database settings
 +-- file (it is by default), will automatically be loaded and launched when Serial
 +-- Bridge is launched. It will be terminated and reloaded whenever any serial
 +-- port settings change for this connection, or if the Reload button is pressed.
 +--
 +-- MyProcessSerialData() below contains sample code you can modify to
 +-- wait for serial data, read serial data, send serial data, and log information
 +-- to the Serial Bridge log window.
 +--
 +-- The entry point into this file is startCommunication(). Although
 +-- documentation is provided below for both functions; you will probably
 +-- only need to modify MyProcessSerialData().
 +--
 +-- 2005-03-29 Original. (Matt Bendiksen)
 +-- 2005-04-01 Fixed event timeout bugs. (Matt Bendiksen)
 +
 +-----------
 +-- 
 +
 +(*
 +    --Serial process script for Serial Bridge
 +    --by M. Bendikson
 +    --mods by dtich
 +    --mods by HFTobeason
 +  --mods by hamw for Ademco ​
 +
 +    --This script reads Hex message data broadcast from an Ademco Vista 128 and logs the parsed value to IndigoServer,​ repeating until fatal error. The script was initially used to parse the DTC serial board.
 +    *)
 +property commandString : ""​
 +property commandCodes : {"100 Disarmed",​ "010 Armed Away", "001 Armed Stay", "​RFX ​  ​Command"​}
 +
 +on MyProcessSerialData(connectionName)
 +   tell application "​Serial Bridge"​
 +      -- this will block until at least 1 byte is available
 +      wait for data from source connectionName
 +      set byteRead to read byte from source connectionName
 +      if byteRead is 13 or byteRead is 10 then -- CR=Hex 0D=ASCII 13 / LF=Hex 0A=ASCII 10
 +         if commandString is not ""​ then
 +            log "​trying to parse commandString:​ " & commandString
 +            if length of commandString < 5 then
 +               log "​commandString length too short to parse"
 +            else
 +               set nameofstate to (characters 2 through 4 of commandString as string)
 +               set commandData to (characters 63 through -1 of commandString as string) ​           ​
 +               set commandDescription to my MyParse(nameofstate)
 +               if commandDescription is not ""​ then
 +                  log "​commandString found matching code; setting Indigo variable value"
 +                  tell application "​IndigoServer"​
 +                     set value of variable "​alarmstate"​ to commandDescription
 +                     set value of variable "​alarmdisplay"​ to commandData
 +                  end tell
 +               else
 +                  log "​commandString no matching code found"
 +               end if
 +            end if
 +            set commandString to ""​
 +         end if
 +      else
 +         set charRead to ASCII character byteRead
 +         set commandString to commandString & charRead
 +      end if
 +   end tell
 +end MyProcessSerialData
 +
 +on startCommunication(connectionName)
 +   tell application "​Serial Bridge"​
 +      try
 +         set bufferDumpStr to (read string from source connectionName)
 +         log "​dumping rs232 buffer: " & bufferDumpStr
 +      end try
 +      -- Loop forever: wait for data, read it, process it, and optionally send
 +      -- out serial data.
 +      --
 +      -- We do not want our script to return or exit since Serial Bridge
 +      -- only calls our script on launch (or when the Reload Script button
 +      -- is pressed).
 +      repeat while true
 +         try
 +            set maxTimeoutDelay to 8947848 -- 103.56 days (hex 0x00888888)
 +            with timeout of maxTimeoutDelay seconds
 +               my MyProcessSerialData(connectionName)
 +            end timeout
 +         on error number errNum
 +            if errNum is -1712 then
 +               log "​timeout waiting for serial data" using type "​Error"​
 +            else if errNum is -1708 then
 +               log "​AppleEvent not handled"​ using type "​Error"​
 +               ​--return -- fatal error; exit script processing
 +            else if errNum is -128 then
 +               log "​connection script aborted"​ using type "​Error"​
 +               ​return -- fatal error; exit script processing
 +            else
 +               log "error " & errNum & " inside MyProcessSerialData()"​ using type "​Error"​
 +               ​--return -- maybe fatal error; exit script processing
 +            end if
 +         end try
 +      end repeat
 +   end tell
 +end startCommunication
 +
 +on MyParse(commandString)
 +   ​repeat with x from 1 to count of commandCodes
 +      if word 1 of item x of commandCodes is commandString then
 +         ​return (characters 7 through -1 of item x of commandCodes as string)
 +      end if
 +   end repeat
 +   ​return ""​
 +end MyParse
 +(* The above read verbs all have an optional argument, "​timeout after",​
 +                     * to specify how long to wait in milliseconds for the data if it is not
 +                     * currently available. If no timeout argument is present, then a
 +                     * timeout error will be immediately thrown if there is not enough
 +                     * data present to fulfill the request.
 +                     *)
 + 
 +-----------------------------------------------------------------------------
 +(* To send data use the "send to source"​ verb. You can either send
 +                     * a single byte, multiple bytes as a list, or a string. To send a single byte:
 +                     *)
 +
 +-----------
 +-- Serial Bridge will call the startCommunication() subroutine after it has opened
 +-- the serial port connection for this connection. It is only called after the serial
 +-- port connection has been opened, shortly after Serial Bridge launches or if
 +-- the user presses the Reload Script button.
 +--
 +-- The argument, connectionName,​ is a string used to identify this serial port
 +-- connection, and will always be the folder name in which this script (and
 +-- database settings file) resides. This value should be passed to all read, write,
 +-- and wait serial functions to identify which serial port connection the script is
 +-- using.
 +--
 +
 +
 +</​code>​
 +
 +
 +**Two Panel Script**
 +
 +The following script is set up for two panels. The actual parser output is right up top in the script under "​commandCodes"​ and is in this format: "00171 House Armed Stay"
 +
 +Char 2,3 and 4 in the AD2USB output are the alarm state, 001, or Armed Stay, and are the first three characters in the parser output. Char 30 and 31 are the panel ID, 71, char 4 and 5 in the parser output, representing my home panel. The parsing output will appear in the variables "​AlarmHouseState"​ and "​AlarmGarageState"​.  ​
 +
 +The alpha display, " ​ ARMED STAY 1   ZONE BYPASSED ​ ", is what is seen on the keypad and will appear in the variable "​AlarmHouseDisplay"​ and "​AlarmGarageDisplay"​. ​ In order to distinguish the panels, this parser concatenates characters 2-4 and 30-31:
 +
 +<​code>​
 +set commandDescription to my MyParse(nameofstate & nameofpartition)
 +</​code>​
 +
 +and sets the output to a five character identifier, "​00171"​ versus the single panel "​001"​.
 +
 +You don't need to use the panel descriptors if you have only one panel--see above script. For changing the parser output in the commandCodes at the top of either script, just keep the numeric first three (single partition) or five (two partitions) characters intact and rename the succeeding text to what you want and it should parse correctly. ​
 +
 +
 +To reiterate, in either script the first three numbers are the alarm state, and correspond to char 2-4 in the readout. The last two, 70 or 71, correspond to separate panels (garage and house) and can be used if you have two panels. These are characters 30 and 31 in the AD2USB output. If for some reason SB is not parsing the data in the two panel script, check to be sure these characters are correct. If you have only one panel, you will have only one set of the panel codes, 70 or 71, or a similar code in the same position. Use the first script which disregards these variables. Just don't break the parser by fiddling with it too much!8-O
 +
 +If you want to see what’s going with your RF devices, also add (from the two panel script) AlarmSensor (you will need to read the device serial names and enter them into the parser commandCodes) and/​or ​ AlarmSensorRawData. This one will just grab all the !RFX codes and put them in a variable. You will need to “de-comment out” the AlarmSensorRawData in Serial Bridge to activate it. In my neighborhood there are a jillion !RFX devices. I tried listening for them and got terrifically confused until I looked at all my devices and realized I had only 4 !RFX devices. All the rest were hard wired. When you buy a new RF device, such as a motion detector, the panel will pass along the !RFX code without requiring any programming. So just note the serial number, add it to the parser, write a trigger for that value and you can trigger events when it is detected. ​
 +
 +
 +
 +<​code>​
 +-- Sample connection attachment script for Serial Bridge.
 +--
 +-- This script, if it is in the same folder as the Serial Bridge database settings
 +-- file (it is by default), will automatically be loaded and launched when Serial
 +-- Bridge is launched. It will be terminated and reloaded whenever any serial
 +-- port settings change for this connection, or if the Reload button is pressed.
 +--
 +-- MyProcessSerialData() below contains sample code you can modify to
 +-- wait for serial data, read serial data, send serial data, and log information
 +-- to the Serial Bridge log window.
 +--
 +-- The entry point into this file is startCommunication(). Although
 +-- documentation is provided below for both functions; you will probably
 +-- only need to modify MyProcessSerialData().
 +--
 +-- 2005-03-29 Original. (Matt Bendiksen)
 +-- 2005-04-01 Fixed event timeout bugs. (Matt Bendiksen)
 +
 +-----------
 +-- 
 +
 +(*
 +    --Serial process script for Serial Bridge
 +    --by M. Bendikson
 +    --mods by dtich
 +    --mods by HFTobeason
 +  --mods by hamw for Ademco ​
 +
 +    --This script reads Hex message data broadcast from an Ademco Vista 128 and logs the parsed value to IndigoServer,​ repeating until fatal error. The script was initially used to parse the DTC serial board.
 +    *)
 +property commandString : ""​
 +property commandCodes : {"​10071 House Disarmed",​ "01071 House Armed Away", "00171 House Armed Stay", "10070 Garage Disarmed",​ "01070 Garage Armed Away", "​0207233 Window MBR Front",​ "​0760965 Window MBR Back", "​0781073 Office Window Game Rm", "​0612867 Window Game Rm"}
 +
 +on MyProcessSerialData(connectionName)
 + tell application "​Serial Bridge"​
 + -- this will block until at least 1 byte is available
 + wait for data from source connectionName
 + set byteRead to read byte from source connectionName
 + if byteRead is 13 or byteRead is 10 then -- CR=Hex 0D=ASCII 13 / LF=Hex 0A=ASCII 10
 + if commandString is not ""​ then
 + log "​trying to parse commandString:​ " & commandString
 + if length of commandString < 5 then
 + log "​commandString length too short to parse"
 + else
 + if length of commandString is 94 then
 + set nameofstate to (characters 2 through 4 of commandString as string)
 + set nameofpartition to (characters 30 through 31 of commandString as string)
 + set commandData to (characters 62 through -1 of commandString as string)
 +
 + set commandDescription to my MyParse(nameofstate & nameofpartition)
 + if commandDescription is not ""​ then
 + log "​commandString found matching code; setting Indigo variable value"
 + tell application "​IndigoServer"​
 + if commandDescription contains "​House"​ then
 + set value of variable "​AlarmHouseState"​ to commandDescription
 + set value of variable "​AlarmHouseDisplay"​ to commandData
 + else
 + set value of variable "​AlarmGarageState"​ to commandDescription
 + set value of variable "​AlarmGarageDisplay"​ to commandData
 + end if
 + end tell
 + end if
 + else
 + if length of commandString is 15 then
 + set nameofsensor to (characters 6 through 12 of commandString as string)
 + set AlarmSensorRawData to (characters 1 through 15 of commandString as string)
 + --tell application "​IndigoServer"​
 + --set value of variable "​AlarmSensorRawData"​ to AlarmSensorRawData
 + --log AlarmSensorRawData
 + --end tell    (enable if you want to see the RFX traffic in AlarmSensorRawData)
 + set commandDescription to my MyParse(nameofsensor)
 + if commandDescription is not ""​ then
 + log "​commandString found matching code; setting Indigo variable value"
 + tell application "​IndigoServer"​
 + set value of variable "​AlarmSensor"​ to commandDescription
 + --log AlarmSensor ​ (enable if you want to see the RFX traffic in Indigo Event Log)
 + end tell
 + end if
 + end if
 +
 + log "​commandString no matching code found"
 + end if
 + end if
 + set commandString to ""​
 + end if
 + else
 + set charRead to ASCII character byteRead
 + set commandString to commandString & charRead
 + end if
 + end tell
 +end MyProcessSerialData
 +
 +on startCommunication(connectionName)
 + tell application "​Serial Bridge"​
 + try
 + set bufferDumpStr to (read string from source connectionName)
 + log "​dumping rs232 buffer: " & bufferDumpStr
 + end try
 + -- Loop forever: wait for data, read it, process it, and optionally send
 + -- out serial data.
 + --
 + -- We do not want our script to return or exit since Serial Bridge
 + -- only calls our script on launch (or when the Reload Script button
 + -- is pressed).
 + repeat while true
 + try
 + set maxTimeoutDelay to 8947848 -- 103.56 days (hex 0x00888888)
 + with timeout of maxTimeoutDelay seconds
 + my MyProcessSerialData(connectionName)
 + end timeout
 + on error number errNum
 + if errNum is -1712 then
 + log "​timeout waiting for serial data" using type "​Error"​
 + else if errNum is -1708 then
 + log "​AppleEvent not handled"​ using type "​Error"​
 + --return -- fatal error; exit script processing
 + else if errNum is -128 then
 + log "​connection script aborted"​ using type "​Error"​
 + return -- fatal error; exit script processing
 + else
 + log "error " & errNum & " inside MyProcessSerialData()"​ using type "​Error"​
 + --return -- maybe fatal error; exit script processing
 + end if
 + end try
 + end repeat
 + end tell
 +end startCommunication
 +
 +on MyParse(commandString)
 + repeat with x from 1 to count of commandCodes
 + if word 1 of item x of commandCodes is commandString then
 + return (characters 7 through -1 of item x of commandCodes as string)
 + end if
 + end repeat
 + return ""​
 +end MyParse
 +(* The above read verbs all have an optional argument, "​timeout after",​
 +                     * to specify how long to wait in milliseconds for the data if it is not
 +                     * currently available. If no timeout argument is present, then a
 +                     * timeout error will be immediately thrown if there is not enough
 +                     * data present to fulfill the request.
 +                     *)
 +
 +-----------------------------------------------------------------------------
 +(* To send data use the "send to source"​ verb. You can either send
 +                     * a single byte, multiple bytes as a list, or a string. To send a single byte:
 +                     *)
 +
 +-----------
 +-- Serial Bridge will call the startCommunication() subroutine after it has opened
 +-- the serial port connection for this connection. It is only called after the serial
 +-- port connection has been opened, shortly after Serial Bridge launches or if
 +-- the user presses the Reload Script button.
 +--
 +-- The argument, connectionName,​ is a string used to identify this serial port
 +-- connection, and will always be the folder name in which this script (and
 +-- database settings file) resides. This value should be passed to all read, write,
 +-- and wait serial functions to identify which serial port connection the script is
 +-- using.
 +--
 +
 +</​code>​
 +
 +
 +Once this is working, you can send commands to the Ademco via serial bridge using this basic command structure, where xxxx is your user code and 1 corresponds to “Alarm Off”. xxxx2 is Alarm Away, xxxx3 is Alarm Stay, xxxx7 is Alarm Stay Instant
 +<​code>​
 +tell application "​Serial Bridge"​
 +    set connectionName to "​AD2USB" ​  
 +    send to source connectionName string "​xxxx1"​
 +end tell
 +</​code>​
 +
 +
 +**11. Control Pages**
 +
 +To control your alarm from your iPhone you need Indigo Touch and need to construct a control page. You can set up a page like this, where your button sends xxxx1 as a command to set off, stay, away as a single press, or as a keypad. A major criticism of the single button approach is that if someone gets hold of your iPhone they can come in your house at will. The answer is to password protect your iPhone as well as your Indigo Server. If you iPhone is lost or stole, wipe it remotely and change your Indigo Server password. ​
 +
 +The variable fields correspond to the variables “AlarmHouseState” (top) and AlarmHouseDisplay (second). AlarmHouseState is a parsed value that has an assigned text at the top of the SB AppleScript;​ you can change it how you wish. AlarmHouseDisplay is the actual alphanumeric output you see on your keypad. Text is a toggle which, when set, will send a text to your cell phone when the alarm state changes, if so desired. The bottom value is the most recently received !RFX code. Not too useful yet. 
 +
 +{{http://​aws.indigodomo.com/​wiki/​alarm_control_page_ex.png}}
 +
 +
 +To send text messages, first make a variable "​AlarmSendTextOnChange",​ which will change the color of the button as well, if the button is set up to report a variable. Here’s the script to execute the Text Message toggle: ​
 +
 +<​code>​
 +if (value of variable "​AlarmSendTextOnChange"​ is "​true"​) then
 +    set value of variable "​AlarmSendTextOnChange"​ to "​false"​
 +else
 +    set value of variable "​AlarmSendTextOnChange"​ to "​true"​
 +end if
 +</​code>​
 +Then create a Trigger that will fire when the AlarmHouseState variable changes, with the conditions:
 +
 +Trigger: Variable changed: ​  ​AlarmHouseState
 +
 +Condition: If Variable AlarmSendTextOnChange is True
 +
 +Action: Send Email   Enter your email address to send a text to your phone, and a message if you want. 
 +
 +
 +This is not too good for every day use, but if on vacation and you want to see if someone is coming in your house with your code, it can be useful. ​
 +
 +Finally, here’s a work-in-progress Keypad example, and how my home page is set up.  Each key just sends a SB command with the value of the corresponding integer. ​
 +
 +{{http://​aws.indigodomo.com/​wiki/​alarm_keypad_ex.png}}
 +
 +
 +<​code>​
 +tell application "​Serial Bridge"​
 +    set connectionName to "​AD2USB"​
 +    ​
 +    send to source connectionName string "​1"​
 +end tell
 +</​code>​
 +
 +{{http://​aws.indigodomo.com/​wiki/​alarm_home_page_ex.png}}
 +
 +
 +
 +Hope this is helpful. ​
 +
 +Ham Williams
  
 

© Perceptive Automation, LLC. · Privacy