-
Notifications
You must be signed in to change notification settings - Fork 8
/
Turn-on-Police-Light-When-Switch-Is-On.groovy
39 lines (39 loc) · 1.21 KB
/
Turn-on-Police-Light-When-Switch-Is-On.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
/**
* Turn on Police Light When Switch Is On
*
* Author: Todd Wackford
*/
definition(
name: "Turn on Police Light When Switch Is On",
namespace: "smartthings",
author: "twack",
description: "Turn Fibaro Controller to Police lights program when a switch, real or virtual, is turned on.",
category: "My Apps",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/[email protected]"
)
preferences {
section("When a Switch is turned on..."){
input "switchMaster", "capability.switch", title: "Which?"
}
section("Turn on this/these Fibaro Police Light(s)..."){
input "fibaros", "capability.color control", multiple: true
}
}
def installed() {
subscribe(switchMaster, "switch.on", switchOnHandler)
subscribe(switchMaster, "switch.off", switchOffHandler)
}
def updated() {
unsubscribe()
subscribe(switchMaster, "switch.on", switchOnHandler)
subscribe(switchMaster, "switch.off", switchOffHandler)
}
def switchOnHandler(evt) {
log.trace "Turning on Fibaro RGBW: $fibaros"
fibaros.police()
}
def switchOffHandler(evt) {
log.trace "Turning off Fibaro RGBW: $fibaros"
fibaros.off()
}