From b4b037c4cc60bc572edc6190f3e3120016c8f811 Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Wed, 10 Mar 2021 13:54:52 +0100 Subject: [PATCH 1/2] fix(ui): zwave graph when controller id != 1 Fixes #862. Added `isControllerNode` prop to nodes --- lib/ZwaveClient.js | 3 ++- src/components/custom/ZwaveGraph.vue | 13 +++++++------ types/index.d.ts | 3 ++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/ZwaveClient.js b/lib/ZwaveClient.js index d44c7c54bc6..0ae65973b5d 100644 --- a/lib/ZwaveClient.js +++ b/lib/ZwaveClient.js @@ -902,7 +902,8 @@ function initNode (zwaveNode) { node.endpointsCount = zwaveNode.getEndpointCount() node.isSecure = zwaveNode.isSecure node.isBeaming = zwaveNode.isBeaming - node.isListening = zwaveNode.isListening || zwaveNode.isControllerNode() // Fixes #739 + node.isControllerNode = zwaveNode.isControllerNode() + node.isListening = zwaveNode.isListening node.isFrequentListening = zwaveNode.isFrequentListening node.isRouting = zwaveNode.isRouting node.keepAwake = zwaveNode.keepAwake diff --git a/src/components/custom/ZwaveGraph.vue b/src/components/custom/ZwaveGraph.vue index 52bb8306992..c764e690d97 100644 --- a/src/components/custom/ZwaveGraph.vue +++ b/src/components/custom/ZwaveGraph.vue @@ -730,15 +730,13 @@ export default { nodes: [] } - let hubNode = 0 + let hubNode = this.nodes.find(n => n.isControllerNode) + hubNode = hubNode ? hubNode.id : 1 + const neighbors = {} for (const node of this.nodes) { const id = node.id - // TODO: check if node is primary controller - if (id === 1) { - hubNode = id - } neighbors[id] = node.neighbors @@ -779,7 +777,10 @@ export default { (batlev !== undefined ? 'battery (' + batlev + '%)' : 'mains') + '\n Neighbors: ' + node.neighbors, - forwards: node.ready && !node.failed && node.isListening + forwards: + node.ready && + !node.failed && + (node.isListening || node.isControllerNode) // leave the isController check here } if (id === hubNode) { diff --git a/types/index.d.ts b/types/index.d.ts index 6b25bfeeeb0..0005ebca3cd 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -104,7 +104,8 @@ export type Z2MNode = { endpointsCount: number isSecure: boolean isBeaming: boolean - isListening: boolean + isListening: boolean, + isControllerNode: boolean, isFrequentListening: boolean isRouting: boolean keepAwake: boolean From f7b0a6129537a0345c297b037c9b1474abc5174f Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Wed, 10 Mar 2021 15:25:45 +0100 Subject: [PATCH 2/2] fix: add missing type --- types/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index 0005ebca3cd..1867a2c4f6d 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -104,8 +104,8 @@ export type Z2MNode = { endpointsCount: number isSecure: boolean isBeaming: boolean - isListening: boolean, - isControllerNode: boolean, + isListening: boolean + isControllerNode: boolean isFrequentListening: boolean isRouting: boolean keepAwake: boolean