forked from jwsf/device-type.arduino-8-way-relay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVirtualSwitch.groovy
48 lines (37 loc) · 1.3 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
/*metadata {
definition (name: "VirtualSwitch", author: "[email protected]") {
capability "Switch"
}
}*/
preferences {
input("num", "number", title: "Switch number", description: "The switch (relay) number to connect to (1 to 8)", required: true)
}
// 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("refresh", "device.switch", inactiveLabel: false, decoration: "flat") {
state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh"
}
main "switch"
details(["switch","refresh"])
}
// handle commands
def on() {
log.debug "On"
sendEvent (name: "switch", value: "on")
}
def off() {
log.debug "Off"
sendEvent (name: "switch", value: "off")
}