From f4f2b1a4f55a4a285edbe32305f077987f3e4d22 Mon Sep 17 00:00:00 2001 From: Robin Bolscher Date: Tue, 27 Oct 2026 14:39:50 +0100 Subject: [PATCH] fix(endpoint): Remove the binding on unbind unbind replaced the binding with a new client Cluster instead of deleting it. Incoming commands for that cluster then reached a client handler, which answered UNSUP_CLUSTER_COMMAND, where an endpoint without a binding answers UNSUPPORTED_CLUSTER. Delete the binding, and turn the harness's known-bug test for this into a real one. --- lib/Endpoint.js | 2 +- test/virtualDevice.js | 26 +++++++++++--------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/lib/Endpoint.js b/lib/Endpoint.js index fa273ba..ddb2dc8 100644 --- a/lib/Endpoint.js +++ b/lib/Endpoint.js @@ -81,7 +81,7 @@ class Endpoint extends EventEmitter { */ unbind(clusterName) { const OutputCluster = Cluster.getCluster(clusterName); - this.bindings[OutputCluster.NAME] = new OutputCluster(this, OutputCluster); + delete this.bindings[OutputCluster.NAME]; } /** diff --git a/test/virtualDevice.js b/test/virtualDevice.js index b66e7c4..b8c0d34 100644 --- a/test/virtualDevice.js +++ b/test/virtualDevice.js @@ -145,22 +145,18 @@ describe('Virtual device: known bugs on master', function () { ); }); - it( - 'Endpoint.unbind removes the binding, so the cluster is unsupported', - { todo: 'unbind leaves a Cluster in bindings' }, - async function () { - const { zclNode, virtualDevice } = createVirtualDevice({ - endpoints: [{ endpointId: 1, outputClusters: [OnOffCluster.ID] }], - }); - zclNode.endpoints[1].bind('onOff', new BoundCluster()); - zclNode.endpoints[1].unbind('onOff'); + it('Endpoint.unbind removes the binding, so the cluster is unsupported', async function () { + const { zclNode, virtualDevice } = createVirtualDevice({ + endpoints: [{ endpointId: 1, outputClusters: [OnOffCluster.ID] }], + }); + zclNode.endpoints[1].bind('onOff', new BoundCluster()); + zclNode.endpoints[1].unbind('onOff'); - await assert.rejects( - virtualDevice.endpoints[1].clusters.onOff.toggle(), - /^Error: UNSUPPORTED_CLUSTER$/, - ); - }, - ); + await assert.rejects( + virtualDevice.endpoints[1].clusters.onOff.toggle(), + /^Error: UNSUPPORTED_CLUSTER$/, + ); + }); it( 'a report with an unknown attribute id does not emit attr.undefined',