Greetings SmartThings community! I just started my first project creating a device handler for a 8 output/4 input Zigbee device. So far I’ve been able to handle the endpoints separately for all the relay switches by handling them as separate child devices. However, when it came to handling the input functionality, I’ve been having trouble receiving the device message through the parser. I have set up the attribute report bindings in the configuration method and confirmed the messages were transmitting through a Zigbee packet sniffer. I can see activity occurring through the sniffer whenever an input changes state, but I’m not seeing the message propagated to my parser method. I’ve been stuck on this issue for a while and I was hoping someone might have some insight as to why this is happening.
/*
* Copyright 2021 SmartThings
*
* 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: "IOT8Z", namespace: "monthpublic25501", author: "Luis Contreras", mnmn: "SmartThingsCommunity", vid: "6d510b74-469c-3fa0-be7a-ec0894d38dcb") {
capability "Configuration"
capability "Refresh"
capability "Health Check"
capability "Sensor"
capability "Contact Sensor"
capability "Switch"
capability "monthpublic25501.analogSensor"
command "childOn", ["string"]
command "childOff", ["string"]
fingerprint manufacturer: "Smartenit, Inc", model: "IOT8-Z", deviceJoinName: "SMRT-IOT ", profileId: "0104", inClusters: "0000, 0003, 0006, 000C, 000F", outClusters: "0019"
}
}
def installed() {
log.debug "Installed"
updateDataValue("onOff", "catchall")
createChildDevices()
}
def updated() {
log.debug "Updated"
updateDataValue("onOff", "catchall")
refresh()
}
def parse(String description) {
//log.debug "Received event ${description}"
Map eventMap = zigbee.getEvent(description)
Map eventDescMap = zigbee.parseDescriptionAsMap(description)
if (eventMap) {
if (eventDescMap?.sourceEndpoint == "01" || eventDescMap?.endpoint == "01") {
log.debug "This is the Desc Map: ${eventDescMap}"
// clusterId:0006
if (eventDescMap?.clusterId == "000C") {
return createEvent(name: "inputValue", value: eventDescMap?.value)
}
else
sendEvent(eventMap)
} else {
def childDevice = childDevices.find {
it.deviceNetworkId == "$device.deviceNetworkId:${eventDescMap.sourceEndpoint}" || it.deviceNetworkId == "$device.deviceNetworkId:${eventDescMap.endpoint}"
}
if (childDevice) {
childDevice.sendEvent(eventMap)
} else {
log.debug "Child device: $device.deviceNetworkId:${eventDescMap.sourceEndpoint} was not found"
}
}
}
}
private void createChildDevices() {
def numberOfChildDevices = 8
log.debug("createChildDevices(), numberOfChildDevices: ${numberOfChildDevices}")
log.debug("device HubID: ")
log.debug(device.hubId)
for(def endpoint : 2..numberOfChildDevices) {
try {
log.debug "creating endpoint: ${endpoint}"
if (endpoint == 2) {
}
else if (endpoint >= 3 && endpoint <= 4) {
addChildDevice("lecontr1", "IOT8-Z_DI", "${device.deviceNetworkId}:0${endpoint}", device.hubId,
[completedSetup: true,
label: "${device.displayName[0..-2]}${endpoint}",
isComponent: false
])
}
else if (endpoint >= 5 && endpoint <= 8) {
addChildDevice("smartthings", "ZigBee Switch", "${device.deviceNetworkId}:0${endpoint}", device.hubId,
[completedSetup: true,
label: "${device.displayName[0..-2]}${endpoint}",
isComponent: false
])
}
} catch(Exception e) {
log.debug "Exception creating child device: ${e}"
}
}
}
def on() {
log.debug "Turning parent On"
zigbee.on()
}
def off() {
log.debug "Turning parent Off"
zigbee.off()
}
def childOn(String dni) {
log.debug "Turning child On"
def childEndpoint = getChildEndpoint(dni)
zigbee.command(zigbee.ONOFF_CLUSTER, 0x01, "", [destEndpoint: childEndpoint])
}
def childOff(String dni) {
log.debug "Turning child off"
def childEndpoint = getChildEndpoint(dni)
zigbee.command(zigbee.ONOFF_CLUSTER, 0x00, "", [destEndpoint: childEndpoint])
}
/**
* PING is used by Device-Watch in attempt to reach the Device
* */
def ping() {
refresh()
}
def refresh() {
def refreshCommands = zigbee.onOffRefresh()
def numberOfChildDevices = 8
refreshCommands += zigbee.readAttribute(0x000F, 0x0055)
for(def endpoint : 2..numberOfChildDevices) {
refreshCommands += zigbee.readAttribute(zigbee.ONOFF_CLUSTER, 0x0000, [destEndpoint: endpoint])
refreshCommands += zigbee.readAttribute(0x000F, 0x0055, [destEndpoint: endpoint])
}
log.debug "refreshCommands: $refreshCommands"
return refreshCommands
}
def configure() {
log.debug "configure"
configureHealthCheck()
def numberOfChildDevices = 8
def configurationCommands = zigbee.onOffConfig(0, 120)
for(def endpoint : 2..numberOfChildDevices) {
configurationCommands += zigbee.configureReporting(zigbee.ONOFF_CLUSTER, 0x0000, 0x10, 0, 120, null, [destEndpoint: endpoint])
}
for (def endpoint : 1..4) {
configurationCommands += zigbee.configureReporting(0x000F, 0x0055, 0x10, 0, 600, null)
}
configurationCommands << refresh()
log.debug "configurationCommands: $configurationCommands"
return configurationCommands
}
def configureHealthCheck() {
log.debug "configureHealthCheck"
Integer hcIntervalMinutes = 12
def healthEvent = [name: "checkInterval", value: hcIntervalMinutes * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
sendEvent(healthEvent)
childDevices.each {
it.sendEvent(healthEvent)
}
}
private getChildEndpoint(String dni) {
dni.split(":")[-1] as Integer
}
private getModelNumberOfChildDevices() {
[
"DoubleSocket50AU" : 2
]
}