forked from KristopherKubicki/device-yamaha-rx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
av-button-off.groovy
49 lines (41 loc) · 1.31 KB
/
av-button-off.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 Off",
namespace: "KristopherKubicki",
author: "kristopher@acm.org",
description: "Set an AV input when a switch is set to off",
category: "Convenience",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/MiscHacking/remote.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/MiscHacking/remote@2x.png"
)
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 turned off") {
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.off", receiverHandler)
}
def receiverHandler(evt) {
receivers?.inputSelect(inputChan)
receivers?.refresh()
}