forked from sidjohn1/smartthings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MIMOliteWithTruthSentury
162 lines (146 loc) · 5.49 KB
/
MIMOliteWithTruthSentury
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/**
* Copyright 2015 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.
*
* Version: 1.0 - Initial Version
*/
metadata {
definition (name: "MIMOlite with Truth Sentury", namespace: "smartthings", author: "SmartThings") {
capability "Actuator"
capability "Contact Sensor"
capability "Switch"
capability "Polling"
capability "Refresh"
capability "Sensor"
fingerprint deviceId: "0x1000", inClusters: "0x72,0x86,0x71,0x30,0x31,0x35,0x70,0x85,0x25,0x03"
}
// tile definitions
tiles(scale: 2) {
multiAttributeTile(name:"switch", type: "lighting", width: 6, height: 4, canChangeIcon: true){
tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
attributeState "on", label: "opened", action: "switch.off", icon: "st.contact.contact.open", backgroundColor: "#79b821", nextState:"closing"
attributeState "off", label: "closed", action: "switch.on", icon: "st.contact.contact.closed", backgroundColor: "#ffffff", nextState:"opening"
attributeState "opening", label: "opening", action: "switch.off", icon: "st.contact.contact.open", backgroundColor: "#FFC125"
attributeState "closing", label: "closing", action: "switch.on", icon: "st.contact.contact.closed", backgroundColor: "#FFC125"
}
}
standardTile("refresh", "device.switch", width: 2, height: 2, inactiveLabel: false, decoration: "flat") {
state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh"
}
main "switch"
details(["switch","refresh"])
}
}
def parse(String description) {
def result = null
def cmd = zwave.parse(description, [0x20: 1, 0x70: 1])
if (cmd) {
result = createEvent(zwaveEvent(cmd))
}
if (result?.name == 'hail' && hubFirmwareLessThan("000.011.00602")) {
result = [result, response(zwave.basicV1.basicGet())]
log.debug "Was hailed: requesting state update"
} else {
log.debug "Parse returned ${result?.descriptionText}"
}
return result
}
def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {
[name: "switch", value: cmd.value ? "on" : "off", type: "physical"]
if (cmd.value == 0) {
sendEvent(name: 'contact', value: "closed" as String)
sendEvent(name: 'switch', value: "off" as String)
}
else {
sendEvent(name: 'contact', value: "open" as String)
sendEvent(name: 'switch', value: "on" as String)
}
}
def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {
[name: "switch", value: cmd.value ? "on" : "off", type: "physical"]
if (cmd.value == 0) {
sendEvent(name: 'contact', value: "closed" as String)
sendEvent(name: 'switch', value: "off" as String)
}
else {
sendEvent(name: 'contact', value: "open" as String)
sendEvent(name: 'switch', value: "on" as String)
}
}
def zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) {
[name: "switch", value: cmd.value ? "on" : "off", type: "digital"]
if (cmd.value == 0) {
sendEvent(name: 'contact', value: "closed" as String)
sendEvent(name: 'switch', value: "off" as String)
}
else {
sendEvent(name: 'contact', value: "open" as String)
sendEvent(name: 'switch', value: "on" as String)
}
}
def zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {
def value = "when off"
if (cmd.configurationValue[0] == 1) {value = "when on"}
if (cmd.configurationValue[0] == 2) {value = "never"}
[name: "indicatorStatus", value: value, display: false]
}
def zwaveEvent(physicalgraph.zwave.commands.hailv1.Hail cmd) {
[name: "hail", value: "hail", descriptionText: "Switch button was pressed", displayed: false]
}
def zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport cmd) {
if (state.manufacturer != cmd.manufacturerName) {
updateDataValue("manufacturer", cmd.manufacturerName)
}
}
def zwaveEvent(physicalgraph.zwave.Command cmd) {
// Handles all Z-Wave commands we aren't interested in
[:]
}
def on() {
delayBetween([
zwave.basicV1.basicSet(value: 0xFF).format(),
zwave.switchBinaryV1.switchBinaryGet().format()
], 15000)
// sendEvent(name: 'contact', value: "open" as String)
}
def off() {
delayBetween([
zwave.basicV1.basicSet(value: 0x00).format(),
zwave.switchBinaryV1.switchBinaryGet().format()
], 15000)
// sendEvent(name: 'contact', value: "closed" as String)
}
def poll() {
delayBetween([
zwave.switchBinaryV1.switchBinaryGet().format(),
zwave.manufacturerSpecificV1.manufacturerSpecificGet().format(),
zwave.sensorBinaryV1.sensorBinaryGet().format(),
zwave.basicV1.basicGet().format(),
zwave.alarmV1.alarmGet().format()
],100)
}
def refresh() {
delayBetween([
zwave.switchBinaryV1.switchBinaryGet().format(),
zwave.manufacturerSpecificV1.manufacturerSpecificGet().format(),
zwave.sensorBinaryV1.sensorBinaryGet().format(),
zwave.basicV1.basicGet().format(),
zwave.alarmV1.alarmGet().format()
],100)
}
def invertSwitch(invert=true) {
if (invert) {
zwave.configurationV1.configurationSet(configurationValue: [1], parameterNumber: 4, size: 1).format()
}
else {
zwave.configurationV1.configurationSet(configurationValue: [0], parameterNumber: 4, size: 1).format()
}
}