Sure thing. But it’s already a copy from what was suggested in the tutorial you put together for everyone.
metadata {
definition (name: “3 Button ZigBee Toggle (ZBWS3)”, namespace: “JohnRucker”, author: "John.Rucker@Solar-Current.com") {
capability "Sensor"
capability "Configuration"
capability “Contact Sensor”
attribute "contact2","ENUM",["open","closed"]
attribute "contact3","ENUM",["open","closed"]
fingerprint endpointId: "03", profileId: "0104", deviceId: "0000", deviceVersion: "00", inClusters: "03 0000 0003 0007", outClusters: "01 0006"
}
// simulator metadata
simulator {
}
// UI tile definitions
tiles {
standardTile("contact1", "device.contact", width: 1, height: 1) {
state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e")
state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821")
}
standardTile("contact2", "device.contact2", width: 1, height: 1) {
state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e")
state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821")
}
standardTile("contact3", "device.contact3", width: 1, height: 1) {
state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e")
state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821")
}
main (["contact3", "contact2", "contact1"])
details (["contact3", "contact2", "contact1"])
}
}
// Parse incoming device messages to generate events
def parse(String description) {
log.debug "Parse description $description"
def name = null
def value = null
if (description?.startsWith(“catchall: 0104 0006 01”)) {
name = "contact"
def currentST = device.currentState(“contact”)?.value
log.debug "Button 1 pushed, current state = $currentST"
if (currentST == “closed”){
log.debug "Changed to Open"
value = “open”
}
else {
log.debug "Changed to Closed"
value = “closed”
}
} else if (description?.startsWith("catchall: 0104 0006 02")) {
name = "contact2"
def currentST = device.currentState("contact2")?.value
log.debug "Button 2 pushed, current state = $currentST"
if (currentST == "closed"){
log.debug "Changed to Open"
value = "open"
}
else {
log.debug "Changed to Closed"
value = "closed"
}
} else if (description?.startsWith("catchall: 0104 0006 03")) {
name = "contact3"
def currentST = device.currentState("contact3")?.value
log.debug "Button 3 pushed, current state = $currentST"
if (currentST == "closed"){
log.debug "Changed to Open"
value = "open"
}
else {
log.debug "Changed to Closed"
value = "closed"
}
}
def result = createEvent(name: name, value: value)
log.debug "Parse returned ${result?.descriptionText}"
return result
}
def parseDescriptionAsMap(description) {
(description - “read attr - “).split(”,”).inject([:]) { map, param ->
def nameAndValue = param.split(":")
map += [(nameAndValue[0].trim()):nameAndValue[1].trim()]
}
}
private getFPoint(String FPointHex){ // Parsh out hex string from Value: 4089999a
Long i = Long.parseLong(FPointHex, 16) // Convert Hex String to Long
Float f = Float.intBitsToFloat(i.intValue()) // Convert IEEE 754 Single-Precison floating point
log.debug "converted floating point value: ${f}"
def result = f
return result
}
// Commands to device
def configure() {
log.debug "Binding SEP 0x01 DEP 0x01 Cluster 0x0006 On/Off cluster to hub"
def configCmds = [
"zdo bind 0x${device.deviceNetworkId} 0x01 0x01 0x0006 {${device.zigbeeId}} {}", "delay 500",
"zdo bind 0x${device.deviceNetworkId} 0x02 0x01 0x0006 {${device.zigbeeId}} {}", "delay 500",
"zdo bind 0x${device.deviceNetworkId} 0x03 0x01 0x0006 {${device.zigbeeId}} {}", "delay 1500",
]
log.info "Sending ZigBee Bind commands to 3 Button Switch"
return configCmds
}