-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathLightsOn,OnVibration.groovy
71 lines (66 loc) · 2.44 KB
/
LightsOn,OnVibration.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* Lights On,On Vibration
*
* Copyright 2014 Sidney Johnson
* If you like this app, please support the developer via PayPal: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XKDRYZ3RUNR9Y
*
* 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.
*
* Version: 1.0 - Initial Version
*
*/
definition(
name: "Lights On, On Vibration",
namespace: "sidjohn1",
author: "Sidney Johnson",
description: "Turns on a light when a sensor is vibrated",
category: "Convenience",
iconUrl: "http://cdn.device-icons.smartthings.com/Home/home30-icn.png",
iconX2Url: "http://cdn.device-icons.smartthings.com/Home/home30-icn@2x.png")
preferences {
section("About") {
paragraph "Lights On, On Vibration, Turns on and back off a light when a sensor is vibrated. This app works well with a Smartsence Multi attached to your doorbell to detect when it has rung. The vibration of the ring will trigger the selected light to turn on."
paragraph "${textVersion()}\n${textCopyright()}"
}
section ("When this sensor vibrates...") {
input "contact1", "capability.accelerationSensor", title: "Where?", required: true, multiple: false
}
section ("Turn on a light...") {
input "switch1", "capability.switch", required: true, multiple: false
}
section("For how long?") {
input "time1", "number", title: "Number of minutes", required: true, multiple: false
}
}
def installed() {
log.debug "Installed with settings: ${settings}"
subscribe(contact1, "acceleration.active", initialize)
}
def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
subscribe(contact1, "acceleration.active", initialize)
}
def initialize(evt) {
log.debug "Turning switch ON"
switch1.on()
def delay = time1 * 60
runIn(delay, "turnOff")
}
def turnOff() {
log.debug "Turning switch OFF"
switch1.off()
}
private def textVersion() {
def text = "Version 1.0"
}
private def textCopyright() {
def text = "Copyright © 2014 Sidjohn1"
}