Cannot send a Zigbee command from a child device (even calling the parent)

I've tried to send a Zigbee command from a child device but the message was not reaching its destination, without error messages in the HE logs.
The parent messages were working normally.

Then I thought I should call the parent to send the message, but that is not working either. Again, no error messages in the logs.

Code on child:

def configure() {
    log.info "Configure..."
    getParent().sendConfigZigbeeCommandFromParent(getCluster(), OUT_CMD_CONFIG, payload)
}

Code on Parent:

def sendConfigZigbeeCommandFromParent(cluster, command, payload) {
    log.info "---> PARENT: Sending zigbee message - cluster:${cluster}, command:${command}, payload:${payload}"
    zigbee.command(cluster, command, toHex(payload))
}

Logs:

dev:534 2022-09-23 20:22:16.920 info ---> PARENT: Sending zigbee message - cluster:2, command:2, payload:{"open_state":1}
dev:566 2022-09-23 20:22:16.832 info Configure...

The device 566 is the child and 534 its parent.

Even if I do the following on the child it doesn't work:

def configure() {
    getParent().sendRebootCommand()
}

Even though sendRebootCommand() when called directly from a parent's command works ok.

It looks like a bug, I cannot send any Zigbee command from an action triggered on a child.
Am I missing something?

Does your driver implement capability "Configuration" or at least implement configure as a custom command? One of the two should make the return value (of a Hubitat command) be sent as a Zigbee command, otherwise you'll have to use a HubAction to do it manually.

Yes, the child driver has capability "Configuration"

Is this defined as a custom command in your parent device? (I didn't see this the first time.) I don't see anything that actually sends the command if not. You'll need a HubAction to actually send the command if it isn't. Z-Wave or Zigbee commands are only sent if you do so manually or if they are the return value of a Hubitat command.

http://docs2.hubitat.com/developer/hubaction-object

1 Like

Using HubAction I got the message to the destination, but now I have to learn how to code the message. It would be so easy with "zigbee.command" if it just worked as it should.

It is very frustrating to have to go at such a low level just to send a simple Zigbee message. Spent 4 hours already on this, and counting...

You may wish to see how sendHubCommand() was used in one of Hubitat's example drivers:

I don't know Zigbee well enough to help with getting the command you want, though. Maybe someone else if that's the only issue remaining! :slight_smile:

1 Like

Thanks for the help @bertabcd1234!

I could solve it for my case using the following:

actualSender = isChildDevice() ? getParent() : device
def zigbeeCommand = "he cmd 0x${actualSender.deviceNetworkId} 0x1 0x${cluster} 0x${command} {${hexPayload}}"
sendHubCommand(new hubitat.device.HubAction(zigbeeCommand, hubitat.device.Protocol.ZIGBEE))

Still it seems to me that the initial post in this topic is describing a bug.
This is the second issue I've encountered where HE fails silently, the other one being a Zigbee command with an HEX payload more than 144 characters long.

It's hard to say more without seeing the full context, but in general, Hubitat should send the Zigbee (or Z-Wave) command if it's the return value of a Groovy method that corresponds to a Hubitat command on the device (and you have an appropriate return type, including simply def, specified for the method). Some developers avoid this automatic approach and just make all these methods void and use sendHubCommand() with a HubAction or HubMultiAction themselves so they always know what happens when. I haven't seen any bugs related to this behavior described elsewhere, though I suppose it's possible. Not sure about the hex payload length, either. But glad you got this figured out!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.