-
Notifications
You must be signed in to change notification settings - Fork 5
/
Fortrezz-Mimo2-Child.groovy
110 lines (104 loc) · 3.53 KB
/
Fortrezz-Mimo2-Child.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
/**
* FortrezZ MIMO2+ Child
*
* Copyright 2016 FortrezZ, LLC
*
* 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.1 - 5/3/19
* Basic Port from SmartThings
* Can you port a driver that it just a glorified TODO list?
*
* Version 1.2 - 5/6/19 - peng1can
* Very basic but working b-side child driver.
*
* Version 2.0 - 5/9/19 - peng1can
* Overhaul to parent/child device
*
*/
metadata {
definition (name: "FortrezZ MIMO2+ Child Relay", namespace: "peng1can", author: "D Canfield") {
capability "Contact Sensor"
capability "Relay Switch"
capability "Switch"
capability "Voltage Measurement"
capability "Refresh"
}
tiles {
standardTile("switch", "device.switch", width: 2, height: 2) {
state "on", label: "Relay On", action: "off", backgroundColor: "#53a7c0"
state "off", label: "Relay Off", action: "on", backgroundColor: "#ffffff"
}
standardTile("anaDig", "device.anaDig", inactiveLabel: false) {
state "open", label: '${name}', backgroundColor: "#ffa81e"
state "closed", label: '${name}', backgroundColor: "#79b821"
state "val", label:'${currentValue}v', unit:"", defaultState: true
}
standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat") {
state "default", label:'', action:"refresh.refresh"
}
standardTile("powered", "device.powered", inactiveLabel: false) {
state "powerOn", label: "Power On", backgroundColor: "#79b821"
state "powerOff", label: "Power Off", backgroundColor: "#ffa81e"
}
standardTile("configure", "device.configure", inactiveLabel: false, decoration: "flat") {
state "configure", label:'', action:"configuration.configure"
}
standardTile("blank", "device.blank", inactiveLabel: true, decoration: "flat") {
state("blank", label: '')
}
main (["switch"])
details(["switch", "anaDig", "blank", "blank", "refresh", "powered"])
}
}
// parse events into attributes
def parse(String description) {
log.debug "Parsing '${description}'"
// TODO: handle 'contact' attribute
// TODO: handle 'switch' attribute
// TODO: handle 'switch' attribute
// TODO: handle 'voltage' attribute
}
def eventParse(evt) {
log.debug("Event: ${evt.name}=${evt.value}")
switch(evt.name) {
case "powered":
sendEvent(name: evt.name, value: evt.value)
break
case "switch":
sendEvent(name: "switch", value: evt.value)
break
case "contact":
sendEvent(name: "contact", value: evt.value)
break
case "voltage":
sendEvent(name: "voltage", value: evt.value)
break
case "relay":
sendEvent(name: evt.name, value: evt.value)
break
// case "anaDig":
// sendEvent(name: "anaDig1", value: evt.value)
// break
}
}
// handle commands
def on() {
parent.on(device.deviceNetworkId)
log.debug("Executing 'on'")
}
def off() {
parent.off(device.deviceNetworkId)
log.debug("Executing 'off'")
}
def refresh() {
parent.refresh()
log.debug("Executing 'refresh'")
}