Error trying to send message to Zigbee device

2.2.5.131 [C7]

I'm getting system errors trying to send a simple message to a Zigbee device. I thought it worked in the past but now thinking back I'm not 100% sure. However I do know I wasn't originally getting this error message.

the error seems to be the command:

 sendHubCommand(new HubAction(sendtodevice(msg), Protocol.ZIGBEE))

The device is a Haas TI CC2530 board. has worked in the past but now either something changed or I damaged the code.
In troubleshooting I replaced the msg to be sent to a simple string.

Anybody have suggestions.

/**
 *  Furnace Lockout Monitor
 *      This is version two.  The version one used the iharyadi board.  It worked fine but was too chatty.
 *      Version two is a CC2530 board with the Haas firmware.
 *      The lockout switch (open when OK) connects the D1 input (P0.6) to ground when there is a lockout
 *          at the same time the switch turns monitor mounted LED on.  The LED is controlled only by
 *          the switch and does not need a Hubitat connection to illuminate.
 *   Code is largely based on the Dan Ogorchock code for the Haas board
 *
 *      Log entries from manually switching inputs:
 *
 *              dev:28932021-01-16 17:12:34.173 infocontact set to open
 *              dev:28922021-01-16 17:12:34.164 info parsing 'Button1 not.    '
 *
 *              dev:28932021-01-16 17:12:25.702 infocontact set to closed
 *              dev:28922021-01-16 17:12:25.682 info parsing 'Button1 yes.    '
 *
 *
 * 2021-01-16 - v01 -
 * 2021-01-20 - v02 - restructured Parse
 * 2021-01-21 - v05 - moved "ping" under the  if(read Attr) statement structure.
 *              v05c  Full function validated, at ping_360 the ping would occur once an hour.
 *                    Config doesn't do much.
 *
 *
 */


import hubitat.device.HubAction
import hubitat.device.HubMultiAction
import hubitat.device.Protocol

metadata {
    definition (name: "Furnace Lockout Monitor", namespace: "johnrob", author: "various") {
        capability "Actuator"       // our device has commands...
        capability "Sensor"         // our device has attributes...
        capability "Configuration"  // capability "Configuration"  commands: configure()

        command "sendCommand", ["string"] //allows arbitrary comm
        attribute "lastActivity", "String"
        attribute "FurnaceStatus", "string"
    }

    preferences {
        input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: true
        input name: "txtEnable", type: "bool", title: "Enable description logging", defaultValue: true
    }
}

// Parse incoming device messages to generate events
def parse(String description) {
    if (logEnable) log.debug " description is $description"
    state.lastRan = now()
    Map map = [:]
    def event = zigbee.getEvent(description)

    if (event) {
        sendEvent(event)
    }
    else if (description?.startsWith("catchall:")) {
        if (logEnable) log.debug "catchall is $description"
    }
    else if (description?.startsWith("read attr -")) {
        def descMap = zigbee.parseDescriptionAsMap(description)
        log.info "$descMap"
        if (descMap.clusterInt == 0) {
            def text = descMap.value
            if(text.startsWith("ping")) return

            if (text?.startsWith("Button1 yes")) {
                sendEvent(name: "FurnaceStatus", value: "LockedOut", isStateChange: true)
            }
            if (text?.startsWith("Button1 not")) {
                sendEvent(name: "FurnaceStatus", value: "running", isStateChange: true)
            }
        }
        else {
            log.warn "Not an attribute we can decode"
        }
    }
    else {
        log.warn "DID NOT PARSE MESSAGE for description : $description"
        if (logEnable) log.debug zigbee.parseDescriptionAsMap(description)
    }
}  //  --- parse ---

//  However, once a condition is satisfied, the appropriate statements are executed and the remaining conditions are not evaluated.


def sendtodevice(String mystr){
    if (txtEnable) log.info "sending '${mystr}'"
    mystr=mystr.padRight(16,".") // mystr should be 16 bytes!
    def packed = hubitat.helper.HexUtils.byteArrayToHexString(mystr.getBytes())
    if (logEnable) log.info "sending '${mystr}', packed is ${packed}"

    def commandtosend = "HE w/attr 0x${device.deviceNetworkId} 8 0x000 0x010 0x42 {10"+packed+"}" // SAMPLELIGHT_ENDPOINT is defined as 8 in device code // the 10 on the end means 16 bytes length
    if (logEnable) log.debug "$commandtosend"
    return commandtosend
}

def sendCommand(String msg) {
    msg = "hello"
    //if (txtEnable) 
    log.info "sendCommand - ${msg}"
    sendHubCommand(new HubAction(sendtodevice(msg), Protocol.ZIGBEE))  // "new" Creates a new HubAction object
}

def configure() {
    if (txtEnable) log.info "Configuring Reporting and Bindings."
    
    zigbee.onOffRefresh() + zigbee.onOffConfig()
}

def installed() {
    if (txtEnable) log.info "Executing 'installed()'"
    updated()
}

def initialize() {
    if (txtEnable) log.info "Executing 'initialize()'"
}

def updated() {
    if (txtEnable) log.info "Executing 'updated()'"

    if (logEnable) {
        log.info "Enabling Debug Logging for 30 minutes"
        runIn(1800,logsOff)
    } else {
        unschedule(logsoff)
    }
}

def now() {
    if(location.timeZone)
    now = new Date().format("yyyy MMM dd EEE h:mm:ss a", location.timeZone)
    else
    now = new Date().format("yyyy MMM dd EEE h:mm:ss a")
    sendEvent(name: "lastActivity", value: now, displayed:false)
    result
}


//  --- eof ---

It should be "he wattr".

Where possible IMO you should always try to use the built in zigbee Object commands:

https://docs.hubitat.com/index.php?title=Zigbee_Object

zigbee.writeAttribute(Integer cluster, Integer attributeId, Integer dataType, Integer value, Map additionalParams = [:], int delay = STANDARD_DELAY_INT)

The destination endpoint might be able to be supplied in the additionalParams map like:

additionalParams = [destEndpoint: 0x08]

I say "might" because it may not yet be supported (I've not checked recently) as it was something that @mike.maxwell was going to look at when he had time.

For this type of thing you can also always do something like:

def cmds = zigbee.writeAttribute( ..... )
log.debug("sending: ${cmds}")

This will log the exact data being sent so that you can check you have the correct syntax, for example:

def cmds = zigbee.enrollResponse()
log.debug("sending: ${cmds}")

--- sending: [he wattr 0xD198 0x01 0x0500 0x0010 0xF0 {A25F4216006F0D00}, delay 2000, he raw 0xD198 1 0x01 0x0500 {01 23 00 00 00}, delay 2000]

1 Like