4 * Author: Mitch Pond, SmartThings
8 name: "Device Tamper Alarm",
9 namespace: "mitchpond",
11 description: "Receive notification when a device is tampered with. Currently supports Quirky Tripper.",
12 category: "Safety & Security",
13 iconUrl: "https://s3.amazonaws.com/smartapp-icons/Solution/tampering@2x.png",
14 iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Solution/tampering@2x.png",
15 iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Solution/tampering@2x.png"
19 section("Choose devices..."){
20 input "contact", "capability.contactSensor", title: "Devices supporting tamper", required: false, multiple: true
22 section("Via a push notification and/or an SMS message"){
23 input "phone", "phone", title: "Phone Number (for SMS, optional)", required: false
24 input "pushAndPhone", "enum", title: "Both Push and SMS?", required: false, options: ["Yes","No"]
26 section("Sound these alarms..."){
27 input "alarms", "capability.alarm", title: "Alarm Devices", required: false, multiple: true
32 log.debug "Installed with settings: ${settings}"
37 log.debug "Updated with settings: ${settings}"
42 def subscribeToEvents() {
43 subscribe(contact, "tamper.tampered", eventHandler)
46 def eventHandler(evt) {
47 String msg = "${evt.displayName} has been tampered with!"
51 //alarms ?: soundAlarms(alarms)
55 private sendMessage(msg) {
56 if (!phone || pushAndPhone != "No") {
57 log.debug "sending push"
61 log.debug "sending SMS"
66 private soundAlarms(alarms){