Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deconz adapter does not properly surface errors when sending commands to an unsupported cluster #1286

Open
deviantintegral opened this issue Jan 5, 2025 · 0 comments

Comments

@deviantintegral
Copy link
Contributor

I was debugging adding a device to a group (a zbminil2 that needs a firmware update), and I had a thought: from what I remembered, groups worked fine with the device back when I used a RaspBee II, and no longer worked when I changed my network to a zstack adapter.

I had a ConBee II handy, along with a zzh! stick, so I figured let's compare and see.

  • The group add command appears to succeed. But, if you look at the response frame, the zbminil2 is sending 0xc3 (unsupported cluster).
  • With zstack, a timeout error is surfaced and the device is not added to the group.
  • With the conbee II, no timeout error is surfaced and the device is added to the group (even though it's not actually functional).

Here is the block where zstack throws the error:

try {
const result = await this.sendRequest(frame, optionsWithDefaults);
if (result) {
const resultFrame = Zcl.Frame.fromBuffer(result.clusterID, result.header, result.data, device.customClusters);
if (result && checkStatus && !optionsWithDefaults.disableResponse) {
this.checkStatus(resultFrame.payload);
}
return resultFrame;
}
} catch (error) {
const err = error as Error;
err.message = `${createLogMessage()} failed (${err.message})`;
logger.debug(err.stack!, NS);
throw error;
}

My best guess is that the deconzAdapter.ts file should handle this case. However, at this point the frame hasn't been decoded yet and it feels odd to look deeply into the payload:

if (data !== null) {
const response: Events.ZclPayload = {
address: data.srcAddr16 ?? `0x${data.srcAddr64!}`,
data: data.asduPayload,
clusterID: zclFrame.cluster.ID,
header: Zcl.Header.fromBuffer(data.asduPayload),
endpoint: data.srcEndpoint,
linkquality: data.lqi,
groupID: data.srcAddrMode === 0x01 ? data.srcAddr16! : 0,
wasBroadcast: data.srcAddrMode === 0x01 || data.srcAddrMode === 0xf,
destinationEndpoint: data.destEndpoint,
};
logger.debug(`response received (${zclFrame.header.transactionSequenceNumber})`, NS);
return response;
} else {
logger.debug(`no response expected (${zclFrame.header.transactionSequenceNumber})`, NS);
}
} catch (error) {
throw new Error(`no response received (${zclFrame.header.transactionSequenceNumber}) ${error}`);
}

The total hack solution would be to put something like this in, and it totally works preventing the device from being added to the group database. Of course, I'm sure this breaks other cases where the payload doesn't line up:

                if (response.data.at(4) == 0xc3) {
                    throw new Error("UNSUPPORTED_CLUSTER");
                }

Anyways, I'm not going to work on this more because I only use the deconz adapter for testing and sniffing. But hopefully this helps someone else fix this, or at least answers why a device appears to be added to a group but is not working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant