forked from KristopherKubicki/device-denon-avr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmartapp-button-to-av.groovy
50 lines (43 loc) · 1.35 KB
/
smartapp-button-to-av.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
/**
* Button to AV Mode
*
*/
definition(
name: "Button to AV Mode",
namespace: "KristopherKubicki",
author: "[email protected]",
description: "When a momentary tile is pushed, send inputSelect() to a receiver",
category: "Convenience",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/MiscHacking/remote.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/MiscHacking/[email protected]"
)
preferences {
section("Control these AV Receivers...") {
// Ideally, I would specify capability.avTuner instead
input "receivers", "capability.musicPlayer", title: "Which Receivers?", multiple:true, required: true
}
section("Whenever this button is turned on") {
input "switches", "capability.momentary", title: "Which button?", multiple:false, required: true
}
section("With this input...") {
input(name: "inputChan", type: "text", title: "Which channel?", required: false)
input(name: "level", type: "number", title: "What volume level?", required: false)
}
}
def installed() {
initialize()
}
def updated() {
unsubscribe()
initialize()
}
private def initialize() {
log.debug("initialize() with settings: ${settings}")
subscribe(switches, "switch.on", receiverHandler)
subscribe(app, receiverHandler)
}
def receiverHandler(evt) {
receivers?.inputSelect(inputChan)
receivers?.setLevel(level)
receivers?.refresh()
}