AlarmThing app


#1

Hey guys, I happened to have found this AlarmThing app. I wanted to test it out on my phone, but it is plain weird to me.
Does anybody know how this app could subscribe to “contact” and “motion” events, while it’s using the alarm capability?
Is it that this app might have its own specialized device handler that can generate contact and motion events from a device that integrates alarm, contact, and motion capabilities? Or, is it that we need some other app/device that can send the events to this app? Thanks everyone!

/**

  • AlarmThing AlertAll
  • Copyright 2014 ObyCode
  • Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except
  • in compliance with the License. You may obtain a copy of the License at:
  •  http://www.apache.org/licenses/LICENSE-2.0
    
  • Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
  • on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
  • for the specific language governing permissions and limitations under the License.

*/
definition(
name: “AlarmThing AlertAll”,
namespace: “com.obycode”,
author: “ObyCode”,
description: “Send a message whenever any sensor changes on the alarm.”,
category: “Safety & Security”,
iconUrl: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png”,
iconX2Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png
)

preferences {
section(“Notify me when there is any activity on this alarm:”) {
input “theAlarm”, “capability.alarm”, multiple: false, required: true
}
}

def installed() {
log.debug “Installed with settings: ${settings}”

initialize()

}

def updated() {
log.debug “Updated with settings: ${settings}”

unsubscribe()
initialize()

}

def initialize() {
log.debug “in initialize”
subscribe(theAlarm, “contact”, contactTriggered)
subscribe(theAlarm, “motion”, motionTriggered)
}

def contactTriggered(evt) {
if (evt.value == “open”) {
sendPush(“A door was opened”)
} else {
sendPush(“A door was closed”)
}
}

def motionTriggered(evt) {
if (evt.value == “active”) {
sendPush(“Alarm motion detected”)
}// else {
//sendPush(“Motion stopped”)
//}
}


#2

Tagging @obycode . :wink:


#3

Thank you @JDRoberts. I happened to visit the Obycode Github and I’ve found out that they are using the groovy code here for the AlarmThing-AlertAll.groovy: https://github.com/obycode/DSCAlarmSmartThings

I think what’s happening is that it uses the AlarmThing.groovy as a device handler that talks to a DSC alarm. We need to install AlarmThingManager.groovy that would generate child devices in the form of Virtual Motion Sensor, Virtual Contact Sensor, etc. Then these virtual device handlers would generate events when there are zone changes.

Here, I have another confusion. The above app (AlarmThing-AlertAll), would wait for motion and contact events right, and they should come from the virtual device handlers created as the children of the AlarmThingManager.groovy. But, how is this even possible, because the events are generated by the children of the AlarmThingManager app and they are not generated by the AlarmThing device handler directly. The AlarmThing-AlertAll and AlarmThingManager both subscribe to the AlarmThing device handler. How does this event/subscription model in SmartThings really work?


(Brice; SmartRulesApp.com) #4

You’re right. That app was designed to be used for that DSC alarm device type. To be honest, I don’t remember exactly how that was working, and I don’t have this alarm in place anymore to test it. Looking at the code now, it does seem that it should not work. My apologies for apparently outdated code. It looks like you could subscribe to the “zoneChanged” event if you wanted to trigger something on all changes in state of your alarm zones.