Integration with AT&T digital life

Ok everyone time to get creative. I am working on a project that takes emails generated from AT&T digital life events, parses the body of the email, and writes it to a database. For instance, I have all of these sensors installed by AT&T that send me email notifications when ever they are opened or closed. I want to use those emails to trigger other events on smartThings. I looked at IFTTT, but google does not let you search in the body. The body of the email is where are the real info is.

So… I thought it may be possible to setup a mail client and database on audrino and use the shield to interface with smartThings. How would I relay the sensor information to smartThings? Any ideas or suggestions?

Have a look here for a possible example.

You could look into something like Setup an incoming email route and have the message posted directly to a SmartApp.

If I post directly to a smart app, I wouldn’t have any way to track the state of the sensors would I? What I was thinking was I could track the changes in a database and use a smart app to Query the database. I want to make an app that says if any of the sensors for AT&T digital life are opened, turn off the thermostat. Then if all the windows are shut, turn on the thermostat.

One way to handle it would be to have a SmartApp Service Manager (like the Cloud Connected one in the docs) that creates ST devices for all of your sensors and also handles the email notifications. The child devices would contain the state of each device. This way is cleaner like the Hue and Sonos standard ST setups but it can be a decent amount of work depending on how many device types you need to support.

I like this idea. Which docs are you referring to?

These are the Cloud Connected docs I was referring to:

The Hue (Connect) and Sonos (Connect) SmartApp examples would give you a good idea how to handle child devices although they are LAN based instead of cloud. Although in this case, it probably doesn’t matter for you if the main interface is email.

The big thing would be converting the emails to a SmartThings url. The link @scottinpollock gave above would help with receiving the communication. Sounds like the advice from @Dianoga may get you from email to a url callback.

@Dianoga @swanny

So I don’t see a way to create a rule in mandrill to send only the pertinent information to smartthings. It appears as though the rules can only be set by subject, sender, and one other, but not body. Am I misunderstanding how this all goes together? I assumed I would need to create a custom URL to send to smartthings based on the email sent to mandrill. Am I missing something?

I’m not sure on the email thing. I haven’t really tried doing that myself. I was able to use a text message system to send a message to a URL. Does AT&T allow any other kind of notifications or just email?

Yes it does, but how do I send an SMS to smartThings?

In the Synology Diskstation, it allowed configuration of SMS using any SMS provider through a URL configuration. Is the AT&T option only a phone number directly? Any other notification options that you think you could turn into a URL?

This also seems like something IFTTT should be able to help with. It can convert emails to other actions even direct ST actions, but I’m not sure enough actions are supported yet. It might be worth looking at depending on what devices you want to support.

Sorry I don’t have a silver bullet. :smile:

I’ve already been working with IFTTT. I can trigger certain things but what I really need to do is track the state of the sensors. So I was thinking I could use python on my PC to filter on the body and then trigger something. What does the URL configuration look like?

To set up the SmartApp callbacks, enable OAuth in the SmartApp config screen and add some code like below:

mappings {
  path("/Notify") {
    action: [
      GET: "webNotifyCallback"

def webNotifyCallback() {
    log.trace "get: " + params
    if (params?.msg?.contains("message text to match")) {
          // ...

def setupWebNotify() {
    if (!state.accessToken) {
    // url to call from your web service
    log.trace "${state.accessToken}/smartapps/installations/${}/Notify"

My SmartApp / DeviceType for the Synology Diskstation handles callbacks and creates child devices. You can refer back to that if you want for more details on both subjects: Diskstation Thread

Thanks for this information. So let me make sure I understand this correctly. Once I have a way to process the emails, I will send a URL message to the hub?

I feel horrible asking all of these questions, I am such a newb at this. I work as a system admin, and I am really good at scripting and hacking code. I am sure I’ll be able to do this once I get a full understanding.

No worries. Yes, you would send a URL to${state.accessToken}/smartapps/installations/${}/Notify

with the two variables there having been filled out by your SmartApp. In the sample code, I logged that URL out so you can just copy it from the logs and into your script.

The Notify part at the end of the url matches the “mapping” section earlier in the snippet. You can have more than one url there if you need. Just define multiple in the mapping section. Here are the docs related to this part:

So I am getting closer to having a working model on this. I am going to setup a raspberri pi as a mail client that filters my gmail account looking for specific messages in the body using python. a python script will then trigger the http call you’ve supplied me.

So this will interact with my SmartApp, but how can I track the state of each of the AT&T devices? Will I have to track it on the raspberri pi and just send notifications to my SmartApp? If so, I guess my smartApp would have to query the raspberri pi every time to make sure all sensors are opened or closed.

I’d say the best integration with the ST universe is to have your SmartApp create child devices for each of the real world devices connected to your AT&T system. The child devices then appear like any other devices connected to your hub and can be used to trigger other actions. If you store the state in a SmartApp or on your server, you don’t have the same flexibility.

One option for doing that would be…

  • Add additional data to your URL being called including device name and type plus the status.
  • When you get the callback from the URL, check your child devices for the incoming device
  • If it does not exist, create it
  • If it does exist, call the child functions to update the device

Sample code:

def d = getChildDevice(yourDeviceDNI)
if(!d) {
    def STDeviceType = "ATTSwitch"  // figure out the device type from your parameters
    d = addChildDevice("yournamespace", STDeviceType, yourDeviceDNI, null, [label:"AT&T ${yourDeviceDNI}"])
    log.trace "created ${d.displayName} with id $yourDeviceDNI"
} else {
    log.trace "found ${d.displayName} with id $yourDeviceDNI already exists"
// set child state here based on device type

To do this, you will need very simple device types that mimic the physical device capabilities. The On/Off Button tile is a good simple device. I haven’t had luck creating child devices from the Standard ST devices, so you may have to copy the code and make your own.

@swanny - Thank you so much for this. I have a lot to learn hear, so it may take me some time to get the bugs worked out. This will be pretty cool if I can get this to work, I have seen other people want to interface ATTDL with SmartThings, and even though there will be a bit of a delay if the email is delayed, I think it is a good start. Hopefully AT&T opens their API to everyone in the future.

I’ll try not to bother you unless I am really in a bind.

@Keo It’s no bother. I find it interesting. Let me know if you want me to look anything over.

LOL. Looks like I am in a bind already. So in the following code, we’re defining variable “d” to the value of getChildDevice(yourDeviceDNI) correct?

When I try to save the sample code I get this message:

java.lang.NullPointerException: Cannot get property ‘deviceChildren’ on null object @ line 72