diff --git a/packages/zwave-js/src/lib/controller/Controller.ts b/packages/zwave-js/src/lib/controller/Controller.ts index d8d4a47dd04b..ad18a70e012e 100644 --- a/packages/zwave-js/src/lib/controller/Controller.ts +++ b/packages/zwave-js/src/lib/controller/Controller.ts @@ -4175,7 +4175,7 @@ supported CCs: ${ } // 2. re-create the SUC return route, just in case - node.hasSUCReturnRoute ||= await this.assignSUCReturnRoutes(nodeId); + node.hasSUCReturnRoute = await this.assignSUCReturnRoutes(nodeId); // 3. delete all return routes to get rid of potential priority return routes for (let attempt = 1; attempt <= maxAttempts; attempt++) { @@ -4199,7 +4199,7 @@ supported CCs: ${ } } - // 4. Assign return routes to all association destinations. + // 4. Assign return routes to all association destinations... let associatedNodes: number[] = []; try { associatedNodes = distinct( @@ -4208,14 +4208,14 @@ supported CCs: ${ (assocs: AssociationAddress[]) => assocs.map((a) => a.nodeId), ), - ).sort(); + ) + // ...except the controller itself, which was handled by step 2 + .filter((id) => id !== this._ownNodeId!) + .sort(); } catch { /* ignore */ } - // One of those should probably be the controller. Not sure if the SUC return route is enough. - if (!associatedNodes.includes(this._ownNodeId!)) { - associatedNodes.unshift(this._ownNodeId!); - } + this.driver.controllerLog.logNode(nodeId, { message: `assigning return routes to the following nodes: ${associatedNodes.join(", ")}`, @@ -5244,7 +5244,11 @@ ${associatedNodes.join(", ")}`, // Except to the controller itself - this route is already known ).filter((id) => id !== this.ownNodeId); for (const id of destinationNodeIDs) { - await this.assignReturnRoutes(source.nodeId, id); + if (id === this._ownNodeId) { + await this.assignSUCReturnRoutes(source.nodeId); + } else { + await this.assignReturnRoutes(source.nodeId, id); + } } }