Interfacing Disparate Systems

Sep 04, 2012 By James Litton  inHOW-TOs

When hearing the word interface, most people probably think of a Graphical UserInterface or a physical hardware interface (serial, USB). If you dabble inscripting or are a serious developer, you, no doubt, are familiar withthe concept of software interfaces as well. Occasionally, the need arisesto integrate disparate systems where an interface doesn't already exist,but with a little ingenuity, an interface can be created to bridge thedisparity and help you meet your specific needs.

I have an extensive home automation implementation I developedover the years. As I knocked out the "easy" integrations, I eventually cameto a point of wanting to integrate systems that are not homeautomation-friendly. An example of this is my alarm system. Excellent alarmpanels exist on the market that make integration a cinch, but I already had afully functional alarm system and was determined to integrate it into myhome automation setup rather than replace it.

My first inclination was to hack a keypad or build my own hardwareinterface that would allow me to capture status information. Both of those approachesare viable, but as I thought about other options, I realized I couldintegrate my proprietary alarm system into my home automation systemwithout even cracking open the alarm panel.

Before I reveal the details of how I achieved the outcome I wanted,let me first lay out my integration goals. Although it would be nice tocapture sensor data from the alarm system, in my case, it was totallyunnecessary as the only data that might be helpful was motion sensor dataor specific zone faults. Because I already have numerous motion sensorsinstalled that are native to my home automation build, and because faultdata wasn't a factor in my immediate integration requirements, I concludedthat I needed to know only if my alarm was "armed" or"unarmed". Knowing thestate of the alarm system helps me make my home automation systemsmarter. An example of this added intelligence might be to change thethermostat setting and turn off all lights if the alarm state changes toarmed. Another example might be to turn on all of the lights in the housewhen the garage door opens after dark and the alarm is armed.

As I thought through the scenarios a bit further, I quickly realized Ineeded a bit more data. Depending on how an alarm system is installed andthe practices of its users, there may or may not be multiple armed statesthat need to be considered. In my case, I have two separate armed states.One state is "armed away" (nobody home) and the other is"armed stay"(people are in the house). It wouldn't make sense to turn off all ofthe lights in the house, for example, if the system was set to armedstay, but that would make perfect sense if it were set to armed away. AsI continued to think through my needs, I concluded that knowing whether thesystem was armed away, armed stay or unarmed was all I needed to addsignificantly greater intelligence to my home automation scenes.

Once I had a firm grasp of my needs, I realized my alarm-monitoring company already was providing me with some of the data Iwas looking for in the form of e-mail messages. Every time the alarm wasarmed or disarmed,I would get ane-mail message indicating the state change. I had been using this feature for awhile, as it was helpful to know when my kids arrived home or when theyleft for school in the morning. Because I had been using this notificationmechanism for some time, I also knew it to be extremely timely and reliable.

Because I was getting most of the data I needed, I started thinking about waysI might be able to leverage my e-mail system as the basis for aninterface to my proprietary alarm panel. In days gone by I had usedprocmail to process incoming e-mail, so I knew it would be fairly easy toinject a script into the inbound mail-processing process to scan contentand take action.

Before I started down the path of writing a script and figuring out how tomake my e-mail system run inbound mail through it, I needed to deal with theshortcoming I had with status notifications. You may have noticed that Isaid my alarm monitoring company was sending me two status notifications:one for armed and one for unarmed.I was fairly certain that an additional relay could be configured so the folksat the companycould notify me with the two variations of "armed" that Ineeded to proceed, so I called them to discuss the matter, and sure enough, theywere able to make the change I requested. In fairly short order, I wasreceiving the three notifications that I wanted.

With the notifications in place, I could start the task of creating ascript to scan incoming mail.

To keep things as simple as possible, I decided to write the script inBash.

To follow this example, the first thing you need to do is capture all of the data being piped intothe script and save it for processing:#!/bin/bashwhile read ado echo "$a" >>

View the Original article

No comments:

Post a Comment

Thank You , For Immediate Assistance Plz Put Email Copy to Deviceporting@gmail.com