-
Notifications
You must be signed in to change notification settings - Fork 0
/
Garage.groovy
90 lines (71 loc) · 3.35 KB
/
Garage.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**
* Arduino Garage
*
* Author: Marius Piedallu van Wyk
* Date: 2014-07-27
*/
metadata {
// Automatically generated. Make future change here.
definition (name: "Garage", author: "Marius Piedallu van Wyk") {
capability "Switch"
capability "Sensor"
capability "Contact Sensor"
attribute "contact", "string"
attribute "leftDoor", "string"
attribute "rightDoor", "string"
attribute "backDoor", "string"
command "pushLeft"
command "pushRight"
}
simulator {
}
// Preferences
// tile definitions
tiles {
standardTile("contact", "device.contact", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) {
state "closed", label: 'Closed', icon: "st.doors.garage.garage-closed", backgroundColor: "#79b821"
state "open", label: 'Open', icon: "st.doors.garage.garage-open", backgroundColor: "#ffa81e"
}
standardTile("leftDoor", "device.leftDoor", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) {
state "closed", label: "Closed", icon: "st.doors.garage.garage-closed", backgroundColor: "#79b821", action: "pushLeft", nextState: "open"
state "open", label: "Open", icon: "st.doors.garage.garage-open", backgroundColor: "#ffa81e", action: "pushLeft", nextState: "toggle"
state "toggle", label: "Toggle", icon: "st.doors.garage.garage-opening", backgroundColor: "#89C2E8", action: "pushLeft", nextState: "toggle"
}
standardTile("rightDoor", "device.rightDoor", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) {
state "closed", label: "Closed", icon: "st.doors.garage.garage-closed", backgroundColor: "#79b821", action: "pushRight", nextState: "open"
state "open", label: "Open", icon: "st.doors.garage.garage-open", backgroundColor: "#ffa81e", action: "pushRight", nextState: "toggle"
state "toggle", label: "Toggle", icon: "st.doors.garage.garage-opening", backgroundColor: "#89C2E8", action: "pushRight", nextState: "toggle"
}
standardTile("backDoor", "device.backDoor", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) {
state "closed", label: "Closed", icon: "st.contact.contact.closed", backgroundColor: "#79b821"
state "open", label: "Open", icon: "st.contact.contact.open", backgroundColor: "#ffa81e"
}
main "contact"
details(["leftDoor", "rightDoor", "backDoor"])
}
}
def parse(String description) {
def msg = zigbee.parse(description)?.text
log.debug "Parse got '${msg}'"
def parts = msg.split(" ")
def name = parts.length>0?parts[0].trim():null
def value = parts.length>1?parts[1].trim():null
name = value != "ping" ? name : null
def result
if(name == "anyDoor") {
// Use anyDoor as the virtual contact sensor for whole space:
result = createEvent(name: "contact", value: value)
} else {
result = createEvent(name: name, value: value)
}
log.debug result
return result
}
def pushLeft() {
log.debug "Left Button pressed"
zigbee.smartShield(text: "pushLeft").format()
}
def pushRight() {
log.debug "Right Button pressed"
zigbee.smartShield(text: "pushRight").format()
}