From bfd1a086038fae2d36bccc5680ac86892ed34ae3 Mon Sep 17 00:00:00 2001 From: Dave Hylands Date: Wed, 10 Apr 2019 12:30:46 -0700 Subject: [PATCH 1/2] Improved the defaultRsp to include proper cmdId --- zb-node.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/zb-node.js b/zb-node.js index c2540fe..a89ec31 100644 --- a/zb-node.js +++ b/zb-node.js @@ -1774,6 +1774,22 @@ class ZigbeeNode extends Device { const sourceEndpoint = parseInt(frame.sourceEndpoint, 16); const destinationEndpoint = parseInt(frame.destinationEndpoint, 16); + // The zcl-packet library expects the cmdId in the payload to be a number, + // but when it delivered the original frame to us, frame.zcl.cmdId is + // a string. So we need to convert it back to a number. + + let zclCmd; + if (frame.zcl.frameCntl.frameType == 0) { + zclCmd = zclId.foundation(frame.zcl.cmdId); + } else if (frame.zcl.frameCntl.frameType == 1) { + const clusterId = parseInt(frame.clusterId, 16); + zclCmd = zclId.functional(clusterId, frame.zcl.cmdId); + } + let cmdId = 0; + if (zclCmd) { + cmdId = zclCmd.value; + } + this.zclSeqNum = frame.zcl.seqNum; const rspFrame = this.makeZclFrame( sourceEndpoint, @@ -1787,7 +1803,7 @@ class ZigbeeNode extends Device { disDefaultRsp: 1, }, payload: { - cmdId: frame.zcl.cmdId, + cmdId: cmdId, statusCode: statusCode, }, } From 19242b7b5c049e5b9c09a45e43bb58a22754d4db Mon Sep 17 00:00:00 2001 From: Dave Hylands Date: Thu, 9 May 2019 08:35:57 -0700 Subject: [PATCH 2/2] Added a comment - need to address --- zb-node.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/zb-node.js b/zb-node.js index a89ec31..65e70d5 100644 --- a/zb-node.js +++ b/zb-node.js @@ -1271,7 +1271,12 @@ class ZigbeeNode extends Device { return; } - // Generate a defaultRsp + // Generate a defaultRsp. Note that the deConz dongle may send us + // group casts, which are indicated by a dstAddrMode of 1. This happens + // when using the IKEA motion sensor. + + // TODO: Don't send defaultRsp to group broadcasts + if (frame.zcl.frameCntl.disDefaultRsp == 0 && this.isZclStatusSuccess(frame)) { const defaultRspFrame =