forked from DaveGut/HubitatActive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Samsung_Dryer_flex.groovy
156 lines (133 loc) · 6.21 KB
/
Samsung_Dryer_flex.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/* Samsung Dryer Flex Compartment using SmartThings Interface
Copyright Dave Gutheinz
License Information:
https://github.com/DaveGut/HubitatActive/blob/master/KasaDevices/License.md
===== Description
This is a child driver to Samsung Dryer and will not work indepenently of same.
===== Version 1.1 ==============================================================================*/
def driverVer() { return "1.1" }
def nameSpace() { return "davegut" }
metadata {
definition (name: "Samsung Dryer flex",
namespace: nameSpace(),
author: "David Gutheinz",
importUrl: "https://raw.githubusercontent.com/DaveGut/HubitatActive/master/SamsungAppliances/Samsung_Dryer_flex.groovy"
){
attribute "switch", "string"
command "start"
command "pause"
command "stop"
attribute "jobState", "string"
attribute "machineState", "string"
attribute "kidsLock", "string"
attribute "remoteControlEnabled", "string"
attribute "completionTime", "string"
attribute "timeRemaining", "number"
}
preferences {
input ("debugLog", "bool",
title: "Enable debug logging for 30 minutes", defaultValue: false)
}
}
def installed() { runIn(1, updated) }
def updated() {
def logData = [:]
if (driverVer() != parent.driverVer()) {
logWarn("updated: Child driver version does not match parent.")
}
if (!getDataValue("driverVersion") || getDataValue("driverVersion") != driverVer()) {
updateDataValue("driverVersion", driverVer())
logData << [driverVersion: driverVer()]
}
if (logData != [:]) {
logInfo("updated: ${logData}")
}
}
def start() { setMachineState("run") }
def pause() { setMachineState("pause") }
def stop() { setMachineState("stop") }
def setMachineState(machState) {
def cmdData = [
component: getDataValue("component"),
capability: "dryerOperatingState",
command: "setMachineState",
arguments: [machState]]
def cmdStatus = deviceCommand(cmdData)
logInfo("setMachineState: [cmd: ${machState}, status: ${cmdStatus}]")
}
def statusParse(respData) {
def parseData
def componentId = getDataValue("component")
try {
parseData = respData.components[componentId]
} catch (error) {
logWarn("statusParse: [parseData: ${parseData}, error: ${error}]")
}
def onOff = parseData.switch.switch.value
sendEvent(name: "switch", value: onOff)
if (parseData["samsungce.kidsLock"]) {
def kidsLock = parseData["samsungce.kidsLock"].lockState.value
sendEvent(name: "kidsLock", value: kidsLock)
}
def machineState = parseData.dryerOperatingState.machineState.value
sendEvent(name: "machineState", value: machineState)
def jobState = parseData.dryerOperatingState.dryerJobState.value
sendEvent(name: "jobState", value: jobState)
def remoteControlEnabled = parseData.remoteControlStatus.remoteControlEnabled.value
sendEvent(name: "remoteControlEnabled", value: remoteControlEnabled)
def completionTime = parseData.dryerOperatingState.completionTime.value
if (completionTime != null) {
def timeRemaining = parent.calcTimeRemaining(completionTime)
sendEvent(name: "completionTime", value: completionTime)
sendEvent(name: "timeRemaining", value: timeRemaining)
}
runIn(1, listAttributes, [data: true])
// runIn(1, listAttributes)
}
// ===== Library Integration =====
// ~~~~~ start include (1072) davegut.Logging ~~~~~
library ( // library marker davegut.Logging, line 1
name: "Logging", // library marker davegut.Logging, line 2
namespace: "davegut", // library marker davegut.Logging, line 3
author: "Dave Gutheinz", // library marker davegut.Logging, line 4
description: "Common Logging Methods", // library marker davegut.Logging, line 5
category: "utilities", // library marker davegut.Logging, line 6
documentationLink: "" // library marker davegut.Logging, line 7
) // library marker davegut.Logging, line 8
// Logging during development // library marker davegut.Logging, line 10
def listAttributes(trace = false) { // library marker davegut.Logging, line 11
def attrs = device.getSupportedAttributes() // library marker davegut.Logging, line 12
def attrList = [:] // library marker davegut.Logging, line 13
attrs.each { // library marker davegut.Logging, line 14
def val = device.currentValue("${it}") // library marker davegut.Logging, line 15
attrList << ["${it}": val] // library marker davegut.Logging, line 16
} // library marker davegut.Logging, line 17
if (trace == true) { // library marker davegut.Logging, line 18
logTrace("Attributes: ${attrList}") // library marker davegut.Logging, line 19
} else { // library marker davegut.Logging, line 20
logDebug("Attributes: ${attrList}") // library marker davegut.Logging, line 21
} // library marker davegut.Logging, line 22
} // library marker davegut.Logging, line 23
def logTrace(msg){ // library marker davegut.Logging, line 25
log.trace "${device.displayName} ${driverVer()}: ${msg}" // library marker davegut.Logging, line 26
} // library marker davegut.Logging, line 27
def logInfo(msg) { // library marker davegut.Logging, line 29
if (infoLog == true) { // library marker davegut.Logging, line 30
log.info "${device.displayName} ${driverVer()}: ${msg}" // library marker davegut.Logging, line 31
} // library marker davegut.Logging, line 32
} // library marker davegut.Logging, line 33
def debugLogOff() { // library marker davegut.Logging, line 35
if (debug == true) { // library marker davegut.Logging, line 36
device.updateSetting("debug", [type:"bool", value: false]) // library marker davegut.Logging, line 37
} else if (debugLog == true) { // library marker davegut.Logging, line 38
device.updateSetting("debugLog", [type:"bool", value: false]) // library marker davegut.Logging, line 39
} // library marker davegut.Logging, line 40
logInfo("Debug logging is false.") // library marker davegut.Logging, line 41
} // library marker davegut.Logging, line 42
def logDebug(msg) { // library marker davegut.Logging, line 44
if (debug == true || debugLog == true) { // library marker davegut.Logging, line 45
log.debug "${device.displayName} ${driverVer()}: ${msg}" // library marker davegut.Logging, line 46
} // library marker davegut.Logging, line 47
} // library marker davegut.Logging, line 48
def logWarn(msg) { log.warn "${device.displayName} ${driverVer()}: ${msg}" } // library marker davegut.Logging, line 50
// ~~~~~ end include (1072) davegut.Logging ~~~~~