2 * Door Jammed Notification
4 * Copyright 2015 John Rucker
6 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
7 * in compliance with the License. You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
12 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
13 * for the specific language governing permissions and limitations under the License.
18 name: "Door Jammed Notification",
19 namespace: "JohnRucker",
20 author: "John.Rucker@Solar-current.com",
21 description: "Sends a SmartThings notification and text messages when your CoopBoss detects a door jam.",
23 iconUrl: "http://coopboss.com/images/SmartThingsIcons/coopbossLogo.png",
24 iconX2Url: "http://coopboss.com/images/SmartThingsIcons/coopbossLogo2x.png",
25 iconX3Url: "http://coopboss.com/images/SmartThingsIcons/coopbossLogo3x.png")
28 section("When the door state changes") {
29 paragraph "Send a SmartThings notification when the coop's door jammed and did not close."
30 input "doorSensor", "capability.doorControl", title: "Select CoopBoss", required: true, multiple: false
31 input("recipients", "contact", title: "Recipients", description: "Send notifications to") {
32 input "phone", "phone", title: "Phone number?", required: true}
37 log.debug "Installed with settings: ${settings}"
42 log.debug "Updated with settings: ${settings}"
48 subscribe(doorSensor, "doorState", coopDoorStateHandler)
51 def coopDoorStateHandler(evt) {
52 if (evt.value == "jammed"){
53 def msg = "WARNING ${doorSensor.displayName} door is jammed and did not close!"
54 log.debug "WARNING ${doorSensor.displayName} door is jammed and did not close, texting $phone"
56 if (location.contactBookEnabled) {
57 sendNotificationToContacts(msg, recipients)