forked from ekimmagrann/hubitat-elkm1
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Elk-M1-Driver-Output.groovy
121 lines (109 loc) · 3.71 KB
/
Elk-M1-Driver-Output.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
/***********************************************************************************************************************
*
* A Hubitat Child Driver supporting Elk M1 Outputs.
*
* License:
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* Name: Elk M1 Driver Outputs
*
* I am not a programmer so alot of this work is through trial and error. I also spent a good amount of time looking
* at other integrations on various platforms.
*
*** See Release Notes at the bottom***
***********************************************************************************************************************/
public static String version() { return "v0.1.9" }
metadata {
definition(name: "Elk M1 Driver Outputs", namespace: "belk", author: "Mike Magrann") {
capability "Actuator"
capability "Switch"
command "push", [[name: "duration", type: "NUMBER"]]
command "refresh"
}
preferences {
input name: "txtEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: true
}
}
void updated() {
log.warn "${device.label} Updated..."
log.warn "${device.label} description logging is: ${txtEnable}"
}
hubitat.device.HubAction installed() {
log.warn "${device.label} Installed..."
device.updateSetting("txtEnable", [type: "bool", value: true])
refresh()
}
void uninstalled() {
}
void parse(String description) {
if (device.currentState("switch")?.value == null || device.currentState("switch").value != description) {
String descriptionText = "${device.label} is ${description}"
if (txtEnable)
log.info descriptionText
sendEvent(name: "switch", value: description, descriptionText: descriptionText)
}
}
void parse(List description) {
log.warn "${device.label} parse(List description) received ${description}"
}
hubitat.device.HubAction push(String duration = "1") {
on(duration)
}
hubitat.device.HubAction on(String duration = "0") {
String output = device.deviceNetworkId
output = output.substring(output.length() - 3).take(3)
parent.sendMsg(parent.ControlOutputOn(output.toInteger(), duration))
}
hubitat.device.HubAction off() {
String output = device.deviceNetworkId
output = output.substring(output.length() - 3).take(3)
parent.sendMsg(parent.ControlOutputOff(output.toInteger()))
}
hubitat.device.HubAction refresh() {
parent.refreshOutputStatus()
}
/***********************************************************************************************************************
*
* Release Notes (see Known Issues Below)
*
* 0.1.9
* Strongly typed commands
*
* 0.1.8
* Added descriptionText to switch events
*
* 0.1.7
* Changed logging and events to only occur when state changes
*
* 0.1.6
* Added Refresh Command
* Simplified logging and event code
*
* 0.1.5
* Strongly typed variables for performance
*
* 0.1.4
* Added info logging
*
* 0.1.3
* Added Momentary capability
*
* 0.1.2
* Cleaned up code
*
* 0.1.1
* New child driver to Elk M1 Outputs
*
***********************************************************************************************************************/
/***********************************************************************************************************************
*
* Feature Request & Known Issues
*
*
***********************************************************************************************************************/