Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: statistics and new node interview events #997

Merged
merged 5 commits into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 39 additions & 5 deletions lib/ZwaveClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,37 @@ function onNodeReady (zwaveNode) {
)
}

/**
* Triggered when a node interview starts for the first time or when the node is manually re-interviewed
*
* @param {import('zwave-js').ZWaveNode} zwaveNode
*/
function onNodeInterviewStarted (zwaveNode) {
const node = this.nodes.get(zwaveNode.id)

logger.info(`Node ${zwaveNode.id}: interview started`)

this.emit('event', eventEmitter.node, 'node interview started', node)
}

/**
* Triggered when an interview stage complete
*
* @param {import('zwave-js').ZWaveNode} zwaveNode
* @param {string} stageName completed stage name
*/
function onNodeInterviewStageCompleted (zwaveNode, stageName) {
const node = this.nodes.get(zwaveNode.id)

logger.info(
`Node ${zwaveNode.id}: interview stage ${stageName.toUpperCase()} completed`
)

onNodeStatus.call(this, zwaveNode)

this.emit('event', eventEmitter.node, 'node interview stage completed', node)
}

/**
* Triggered when a node finish its interview. When this event is triggered all node values and metadata are updated
* Starting from zwave-js v7 this event is only triggered when the node is added the first time or manually re-interviewed
Expand All @@ -431,7 +462,7 @@ function onNodeInterviewCompleted (zwaveNode) {
}

logger.info(
`Node ${zwaveNode.id}: interview completed, all values are updated`
`Node ${zwaveNode.id}: interview COMPLETED, all values are updated`
)

onNodeStatus.call(this, zwaveNode)
Expand Down Expand Up @@ -782,6 +813,8 @@ function bindNodeEvents (zwaveNode) {
// https://zwave-js.github.io/node-zwave-js/#/api/node?id=zwavenode-events
zwaveNode
.on('ready', onNodeReady.bind(this))
.on('interview started', onNodeInterviewStarted.bind(this))
.on('interview stage completed', onNodeInterviewStageCompleted.bind(this))
.on('interview completed', onNodeInterviewCompleted.bind(this))
.on('interview failed', onNodeInterviewFailed.bind(this))
.on('wake up', onNodeWakeUp.bind(this))
Expand Down Expand Up @@ -1787,10 +1820,11 @@ ZwaveClient.prototype.connect = async function () {
}

if (!this.cfg.disableStatistics) {
this.driver.enableStatistics(
pkgjson.name + (this.cfg.serverEnabled ? '/ zwave-js-server' : ''),
pkgjson.version
)
this.driver.enableStatistics({
applicationName:
pkgjson.name + (this.cfg.serverEnabled ? '/ zwave-js-server' : ''),
applicationVersion: pkgjson.version
})
}

this.status = ZWAVE_STATUS.connected
Expand Down
1 change: 0 additions & 1 deletion src/components/dialogs/DialogAdvanced.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,5 @@ export default {
font-size: 0.7rem;
color: #999;
line-height: 0.9rem;
margin-top: -0.2rem;
}
</style>
12 changes: 12 additions & 0 deletions src/components/nodes-table/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@
<template v-slot:[`item.failed`]="{ item }">
{{ item.failed ? 'Yes' : 'No' }}
</template>
<template v-slot:[`item.interviewStage`]="{ item }">
<v-row>
<div>{{ item.interviewStage }}</div>
<v-progress-circular
class="ml-3"
v-if="item.interviewStage !== 'Complete'"
indeterminate
size="20"
color="primary"
></v-progress-circular>
</v-row>
</template>
<template v-slot:[`item.lastActive`]="{ item }">
{{
item.lastActive ? new Date(item.lastActive).toLocaleString() : 'Never'
Expand Down
2 changes: 1 addition & 1 deletion src/components/nodes-table/nodes-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default {
supportsBeaming: { type: 'boolean', label: 'Beaming' },
failed: { type: 'boolean', label: 'Failed' },
status: { type: 'string', label: 'Status' },
interviewStage: { type: 'string', label: 'Interview stage' },
interviewStage: { type: 'string', label: 'Interview' },
lastActive: { type: 'date', label: 'Last Active', groupable: false }
},
expanded: [],
Expand Down