2 * Copyright 2015 SmartThings
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 * in compliance with the License. You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
10 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
11 * for the specific language governing permissions and limitations under the License.
13 * Turn It On For 5 Minutes
14 * Turn on a switch when a contact sensor opens and then turn it back off 5 minutes later.
19 name: "Turn It On For 5 Minutes",
20 namespace: "smartthings",
21 author: "SmartThings",
22 description: "When a SmartSense Multi is opened, a switch will be turned on, and then turned off after 5 minutes.",
23 category: "Safety & Security",
24 iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet.png",
25 iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet@2x.png"
29 section("When it opens..."){
30 input "contact1", "capability.contactSensor"
32 section("Turn on a switch for 5 minutes..."){
33 input "switch1", "capability.switch"
38 log.debug "Installed with settings: ${settings}"
39 subscribe(contact1, "contact.open", contactOpenHandler)
42 def updated(settings) {
43 log.debug "Updated with settings: ${settings}"
45 subscribe(contact1, "contact.open", contactOpenHandler)
48 def contactOpenHandler(evt) {
50 def fiveMinuteDelay = 60 * 5
51 runIn(fiveMinuteDelay, turnOffSwitch)