-
Notifications
You must be signed in to change notification settings - Fork 50
/
av-button-on.groovy
49 lines (42 loc) · 1.34 KB
/
av-button-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
40
41
42
43
44
45
46
47
48
49
/**
* AV Input - Automatically set an AV input based on a mode or a switch
*
*/
definition(
name: "AV Button On",
namespace: "KristopherKubicki",
author: "[email protected]",
description: "Set an AV input based on a mode, motion or a switch",
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 switch is activated") {
input "switches", "capability.switch", title: "Which switches?", multiple:true, required: false
}
section("With this input...") {
input(name: "inputChan", type: "text", title: "Which channel?", required: false)
input(name: "level", type: "text", 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)
}
def receiverHandler(evt) {
receivers?.inputSelect(inputChan)
receivers?.setLevel(level)
receivers?.refresh()
}