-
Notifications
You must be signed in to change notification settings - Fork 190
/
Aeon Motor Controller
145 lines (129 loc) · 4.6 KB
/
Aeon Motor Controller
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
/**
* Aeon Motor Controller
*
* Copyright 2015 Bruce Ravenel
*
* 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: "Aeon Motor Controller", namespace: "bravenel", author: "Bruce Ravenel") {
capability "Refresh"
capability "Actuator"
capability "doorControl"
capability "Switch"
command "up"
command "down"
command "stop"
// fingerprint inClusters: "0x26,0x32"
}
simulator {
status "up": "command: 2604, payload: FF"
status "down": "command: 2604, payload: 00"
status "stop": "command: 2605, payload: FE"
["FF", "FE", "00"].each { val ->
reply "2001$val,delay 100,2602": "command: 2603, payload: $val"
}
}
tiles {
standardTile("motor", "device.motor", width: 2, height: 2) {
state("stopUp", label:'stop', icon:"st.doors.garage.garage-open", action: 'down', backgroundColor:"#79b821")
state("stopDn", label:'stop', icon:"st.doors.garage.garage-closed", action: 'up', backgroundColor:"#79b821")
state("up", label:'up', icon:"st.doors.garage.garage-opening", action:'stop', backgroundColor:"#ffe71e")
state("down", label:'down', icon:"st.doors.garage.garage-closing", action:'stop', backgroundColor:"#ffe71e")
}
valueTile("energy", "device.energy", decoration: "flat") {
state "default", label:' '
}
standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat") {
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
}
standardTile("stop", "device.switch") {
state "default", label:"", action: "stop", icon:"http://cdn.device-icons.smartthings.com/sonos/[email protected]"
}
standardTile("up", "device.switch") {
state "default", label: "Up", action: "up", icon:"http://cdn.device-icons.smartthings.com/thermostat/[email protected]"
}
standardTile("down", "device.switch") {
state "default", label: "Down", action: "down", icon:"http://cdn.device-icons.smartthings.com/thermostat/[email protected]"
}
}
main(["motor"])
details(["motor", "refresh", "energy", "up", "down", "stop",])
}
// parse events into attributes
def parse(String description) {
def result = []
def cmd = zwave.parse(description, [0x20: 1, 0x26: 3])
if (cmd) {
result = zwaveEvent(cmd)
log.debug("'$description' parsed to $result")
} else {
log.debug("Couldn't zwave.parse '$description'")
}
result
}
def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {
motorEvents(cmd)
}
def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {
motorEvents(cmd)
}
def zwaveEvent(physicalgraph.zwave.commands.switchmultilevelv3.SwitchMultilevelReport cmd) {
motorEvents(cmd)
}
def motorEvents(physicalgraph.zwave.Command cmd) {
def result = []
def switchEvent = []
if(cmd.value == 0) {switchEvent = createEvent(name: "motor", value: "down", descriptionText: text)}
else if(cmd.value == 254) {
def stopVal = state.up ? "stopUp" : "stopDn"
switchEvent = createEvent(name: "motor", value: stopVal, descriptionText: text)
}
else if(cmd.value == 255) {switchEvent = createEvent(name: "motor", value: "up", descriptionText: text)}
result << switchEvent
}
def refresh() {
zwave.switchMultilevelV1.switchMultilevelGet().format()
}
def up() {
state.up = true
delayBetween([
zwave.basicV1.basicSet(value: 0xFF).format(),
zwave.switchMultilevelV1.switchMultilevelGet().format()
], 1000)
}
def down() {
state.up = false
delayBetween([
zwave.basicV1.basicSet(value: 0x00).format(),
zwave.switchMultilevelV1.switchMultilevelGet().format()
], 1000)
}
def stop() {
delayBetween([
zwave.switchMultilevelV1.switchMultilevelStopLevelChange().format(),
zwave.switchMultilevelV1.switchMultilevelGet().format()
], 1000)
}
def on() {
state.up = true
delayBetween([
zwave.basicV1.basicSet(value: 0xFF).format(),
zwave.switchMultilevelV1.switchMultilevelGet().format()
], 1000)
}
def off() {
state.up = false
delayBetween([
zwave.basicV1.basicSet(value: 0x00).format(),
zwave.switchMultilevelV1.switchMultilevelGet().format()
], 1000)
}