-
Notifications
You must be signed in to change notification settings - Fork 6
/
Momentary-to-Trigger-OnOff-Scenes.groovy
43 lines (37 loc) · 1.16 KB
/
Momentary-to-Trigger-OnOff-Scenes.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
definition(
name: "Momentary To Trigger On/Off Scenes",
namespace: "sticks18/echo",
author: "[email protected]",
parent: "sticks18/parent:Stateless Scene via Echo",
description: "Use a stateless momentary to allow voice commands to avoid sync issues",
category: "My Apps",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png"
)
preferences {
section("Select master momentary switch to monitor"){
input "theSwitch", "capability.momentary", multiple: false, required: true
}
section("Trigger this scene tile if master momentary is turned On"){
input "switchesOn", "capability.momentary", multiple: true, required: false
}
section("Trigger this scene tile if master momentary is turned Off"){
input "switchesOff", "capability.momentary", multiple: true, required: false
}
}
def installed()
{
initialize()
}
def updated()
{
unsubscribe()
initialize()
}
def toggleHandler(evt) {
log.info "Triggering ${evt.value} command"
(evt.value == "on" ? switchesOn?.on() : switchesOff?.on())
}
def initialize() {
subscribe(theSwitch, "pushtype", toggleHandler)
}