/
simulatedgaragedoorv2.groovy
137 lines (113 loc) · 4.41 KB
/
simulatedgaragedoorv2.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/**
* Z-Wave Garage Door Opener
*
* Copyright 2014 SmartThings
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
*/
metadata {
definition (name: "Simulated Garage Door Opener V2", namespace: "smartthings/testing", author: "SmartThings") {
capability "Actuator"
capability "Door Control"
capability "Garage Door Control"
capability "Contact Sensor"
capability "Refresh"
capability "Sensor"
capability "Health Check"
capability "Switch"
capability "Configuration"
}
simulator {
}
tiles {
standardTile("toggle", "device.door", width: 2, height: 2) {
state("closed", label:'${name}', action:"door control.open", icon:"st.doors.garage.garage-closed", backgroundColor:"#00A0DC", nextState:"opening")
state("open", label:'${name}', action:"door control.close", icon:"st.doors.garage.garage-open", backgroundColor:"#e86d13", nextState:"closing")
state("opening", label:'${name}', icon:"st.doors.garage.garage-closed", backgroundColor:"#e86d13")
state("closing", label:'${name}', icon:"st.doors.garage.garage-open", backgroundColor:"#00A0DC")
}
standardTile("toggle", "device.garageDoor", width: 2, height: 2) {
state("closed", label:'${name}', action:"garage door control.open", icon:"st.doors.garage.garage-closed", backgroundColor:"#00A0DC", nextState:"opening")
state("open", label:'${name}', action:"gharage door control.close", icon:"st.doors.garage.garage-open", backgroundColor:"#e86d13", nextState:"closing")
state("opening", label:'${name}', icon:"st.doors.garage.garage-closed", backgroundColor:"#e86d13")
state("closing", label:'${name}', icon:"st.doors.garage.garage-open", backgroundColor:"#00A0DC")
}
standardTile("open", "device.door", inactiveLabel: false, decoration: "flat") {
state "default", label:'open', action:"door control.open", icon:"st.doors.garage.garage-opening"
}
standardTile("close", "device.door", inactiveLabel: false, decoration: "flat") {
state "default", label:'close', action:"door control.close", icon:"st.doors.garage.garage-closing"
}
standardTile("open", "device.garageDoor", inactiveLabel: false, decoration: "flat") {
state "default", label:'open', action:"garage door control.open", icon:"st.doors.garage.garage-opening"
}
standardTile("close", "device.garageDoor", inactiveLabel: false, decoration: "flat") {
state "default", label:'close', action:"garage door control.close", icon:"st.doors.garage.garage-closing"
}
main "toggle"
details(["toggle", "open", "close"])
}
}
def parse(String description) {
log.trace "parse($description)"
}
def open() {
sendEvent(name: "door", value: "opening")
sendEvent(name: "garageDoor", value: "opening")
runIn(2, finishOpening)
}
def close() {
sendEvent(name: "door", value: "closing")
sendEvent(name: "garageDoor", value: "closing")
runIn(2, finishClosing)
}
def finishOpening() {
sendEvent(name: "door", value: "open")
sendEvent(name: "garageDoor", value: "open")
sendEvent(name: "contact", value: "open")
}
def finishClosing() {
sendEvent(name: "door", value: "closed")
sendEvent(name: "garageDoor", value: "closed")
sendEvent(name: "contact", value: "closed")
}
def configure()
{
installed()
}
def installed() {
log.debug "Executing 'installed'"
initialize()
}
def refresh() {
sendEvent(name: "DeviceWatch-DeviceStatus", value: "online")
}
def ping() {
refresh()
}
def updated() {
log.debug "Executing 'updated'"
initialize()
}
private initialize() {
log.debug "Executing 'initialize'"
sendEvent(name: "DeviceWatch-DeviceStatus", value: "online")
sendEvent(name: "healthStatus", value: "online")
//sendEvent(name: "DeviceWatch-Enroll", value: [protocol: "cloud", scheme:"untracked"].encodeAsJson(), displayed: false)
}
def on()
{
open()
}
def off()
{
close()
}