Skip to content

Commit

Permalink
fix: better handle node ready event
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Dec 1, 2020
1 parent a8a984b commit 3ab18c5
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/ZwaveClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,21 @@ function onNodeReady (zwaveNode) {
const node = this.nodes[zwaveNode.id]

// node ready event has been already tiggered by this node
if (!node || node.ready) return
if (!node) return

node.ready = true
initNode.call(this, zwaveNode)
node.lastActive = Date.now()

// ignore the init when node is readt
if (!node.ready) {
initNode.call(this, zwaveNode)

const values = zwaveNode.getDefinedValueIDs()
node.ready = true

for (const zwaveValue of values) {
addValue.call(this, zwaveNode, zwaveValue)
const values = zwaveNode.getDefinedValueIDs()

for (const zwaveValue of values) {
addValue.call(this, zwaveNode, zwaveValue)
}
}

node.lastActive = Date.now()
Expand Down

0 comments on commit 3ab18c5

Please sign in to comment.