Skip to content

Commit

Permalink
fix(ui): zwave graph when controller id != 1 (#863)
Browse files Browse the repository at this point in the history
* fix(ui): zwave graph when controller id != 1

Fixes #862. Added `isControllerNode` prop to nodes

* fix: add missing type
  • Loading branch information
robertsLando authored Mar 10, 2021
1 parent 199c558 commit 74fb920
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lib/ZwaveClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions src/components/custom/ZwaveGraph.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export type Z2MNode = {
isSecure: boolean
isBeaming: boolean
isListening: boolean
isControllerNode: boolean
isFrequentListening: boolean
isRouting: boolean
keepAwake: boolean
Expand Down

0 comments on commit 74fb920

Please sign in to comment.