-
Notifications
You must be signed in to change notification settings - Fork 8
/
VirtualSwitch.groovy
54 lines (44 loc) · 1.63 KB
/
VirtualSwitch.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
51
52
53
54
/* virtual switch */
metadata {
definition (name: "VirtualSwitch", author: "[email protected]") {
capability "Switch"
capability "Momentary"
capability "Refresh"
}
// simulator metadata
simulator {
status "on": "command: 2003, payload: FF"
status "off": "command: 2003, payload: 00"
// reply messages
reply "2001FF,delay 100,2502": "command: 2503, payload: FF"
reply "200100,delay 100,2502": "command: 2503, payload: 00"
}
// tile definitions
tiles {
standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true) {
state "on", label: '${name}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#79b821"
state "off", label: '${name}', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff"
}
standardTile("push", "device.switch", inactiveLabel: false, decoration: "flat") {
state "default", label:'Push', action:"mementary.push", icon: "st.secondary.refresh-icon"
}
standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat") {
state "default", label:'Refresh', action:"device.refresh", icon: "st.secondary.refresh-icon"
}
main "switch"
details(["switch","push","refresh"])
}
}
// handle commands
def on() {
log.debug "On"
sendEvent (name: "switch", value: "on", isStateChange:true)
}
def off() {
log.debug "Off"
sendEvent (name: "switch", value: "off", isStateChange:true)
}
def push() {
log.debug "Push"
sendEvent(name: "momentary", value: "push", isStateChange:true)
}