Skip to content

Instantly share code, notes, and snippets.

@vl4ds
Created September 8, 2016 02:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vl4ds/f9b3ca56c68350c8cc6d76f14a8bf3ed to your computer and use it in GitHub Desktop.
Save vl4ds/f9b3ca56c68350c8cc6d76f14a8bf3ed to your computer and use it in GitHub Desktop.
RunIn Example
/**
* Copyright 2015 SmartThings
*
* 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.
*
* Turn It On When It Opens
*
* Author: SmartThings
*/
definition(
name: "Turn It On When It Opens",
namespace: "smartthings",
author: "SmartThings",
description: "Turn something on when an open/close sensor opens.",
category: "Convenience",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet@2x.png"
)
preferences {
section("When the door opens..."){
input "motion1", "capability.motionSensor", title: "Where?"
}
section("Turn on a light..."){
input "switches", "capability.lock", multiple: true
}
}
def installed()
{
initialize()
}
def updated()
{
initialize()
}
def initialize() {
subscribe(motion1, "motion", doStuff)
}
def doStuff(evt) {
runIn(60, runInHandler, [overwrite: true])
log.info "executed runin"
}
def runInHandler() {
log.info "I ran"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment