Skip to content

Commit

Permalink
feat: [email protected], heal network options, endpoints labels (#2941
Browse files Browse the repository at this point in the history
* feat: [email protected] heal network options support and endpoints labels

Removed `endpointIndezes` in favor of `endpoint` property from ZUINode

* fix: better logic

* fix: review changes

* feat: bump [email protected]
  • Loading branch information
robertsLando authored Feb 6, 2023
1 parent b1dc1a4 commit 6bcf8e3
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 89 deletions.
22 changes: 18 additions & 4 deletions lib/ZwaveClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import {
ControllerFirmwareUpdateProgress,
ControllerFirmwareUpdateResult,
ControllerFirmwareUpdateStatus,
HealNetworkOptions,
} from 'zwave-js'
import { getEnumMemberName, parseQRCodeString } from 'zwave-js/Utils'
import { nvmBackupsDir, storeDir, logsDir } from '../config/app'
Expand Down Expand Up @@ -353,6 +354,11 @@ export interface FwFile {
target?: number
}

export interface ZUIEndpoint {
index: number
label?: string
}

export type ZUINode = {
id: number
deviceConfig?: DeviceConfig
Expand All @@ -371,7 +377,7 @@ export type ZUINode = {
zwavePlusRoleType?: ZWavePlusRoleType | undefined
nodeType?: NodeType
endpointsCount?: number
endpointIndizes?: number[]
endpoints?: ZUIEndpoint[]
isSecure?: boolean | 'unknown'
security?: string | undefined
supportsBeaming?: boolean
Expand Down Expand Up @@ -2531,9 +2537,9 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
}
}

beginHealingNetwork(): boolean {
beginHealingNetwork(options?: HealNetworkOptions): boolean {
if (this.driverReady) {
return this._driver.controller.beginHealingNetwork()
return this._driver.controller.beginHealingNetwork(options)
}

throw new DriverNotReadyError()
Expand Down Expand Up @@ -4366,7 +4372,15 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
node.zwavePlusRoleType = zwaveNode.zwavePlusRoleType
node.nodeType = zwaveNode.nodeType
node.endpointsCount = zwaveNode.getEndpointCount()
node.endpointIndizes = zwaveNode.getEndpointIndizes()
node.endpoints = zwaveNode.getAllEndpoints().map((e) => {
return {
index: e.index,
label:
e.index === 0 && !e.endpointLabel
? 'Root Endpoint'
: e.endpointLabel,
}
})
node.isSecure = zwaveNode.isSecure
node.security = SecurityClass[zwaveNode.getHighestSecurityClass()]
node.supportsSecurity = zwaveNode.supportsSecurity
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
"vuedraggable": "^2.24.3",
"vuetify": "^2.6.8",
"winston": "^3.3.3",
"zwave-js": "^10.5.6"
"zwave-js": "^10.7.0"
},
"devDependencies": {
"@babel/cli": "^7.18.10",
Expand Down
9 changes: 6 additions & 3 deletions src/components/dialogs/DialogAssociation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,12 @@ export default {
endpoints.unshift({ text: 'No Endpoint', value: null })
}
if (node && node.endpointIndizes) {
for (const i of node.endpointIndizes) {
endpoints.push({ text: 'Endpoint ' + i, value: i })
if (node && node.endpoints) {
for (const endpoint of node.endpoints) {
endpoints.push({
text: endpoint.label || 'Endpoint ' + endpoint.index,
value: endpoint.index,
})
}
}
Expand Down
21 changes: 19 additions & 2 deletions src/components/nodes-table/AssociationGroups.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,17 @@
{{ getNodeName(item.nodeId) }}
</template>
<template v-slot:[`item.endpoint`]="{ item }">
{{ item.endpoint >= 0 ? item.endpoint : 'None' }}
{{
item.endpoint >= 0
? getEndpointLabel(node.id, item.endpoint)
: 'None'
}}
</template>
<template v-slot:[`item.targetEndpoint`]="{ item }">
{{
item.targetEndpoint >= 0 ? item.targetEndpoint : 'None'
item.targetEndpoint >= 0
? getEndpointLabel(item.nodeId, item.targetEndpoint)
: 'None'
}}
</template>
<template v-slot:[`item.actions`]="{ item }">
Expand Down Expand Up @@ -128,6 +134,17 @@ export default {
const node = this.nodes[this.nodesMap.get(nodeId)]
return node ? node._name : 'NodeID_' + nodeId
},
getEndpointLabel(nodeId, endpoint) {
const node = this.nodes[this.nodesMap.get(nodeId)]
if (node) {
const ep = node.endpoints.find((e) => e.index === endpoint)
if (ep) {
return ep.label
}
}
return 'Endpoint ' + endpoint
},
apiRequest(apiName, args) {
if (this.socket.connected) {
const data = {
Expand Down
26 changes: 22 additions & 4 deletions src/views/ControlPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,6 @@ export default {
{
name: 'Begin',
action: 'beginHealingNetwork',
args: {
confirm:
'Healing network causes a lot of traffic, can take minutes up to hours and users have to expect degraded performance while it is going on',
},
},
{ name: 'Stop', action: 'stopHealingNetwork' },
],
Expand Down Expand Up @@ -413,6 +409,28 @@ export default {
if (!confirm || confirm !== 'yes') {
return
}
} else if (action === 'beginHealingNetwork') {
const { includeSleeping } =
await this.$listeners.showConfirm(
'Info',
'Healing network causes a lot of traffic, can take minutes up to hours and users have to expect degraded performance while it is going on',
'info',
{
confirmText: 'Heal',
inputs: [
{
type: 'checkbox',
label: 'Include sleeping nodes',
key: 'includeSleeping',
value: false,
},
],
}
)
if (includeSleeping === undefined) {
return
}
args.push({ includeSleeping })
} else if (action === 'firmwareUpdateOTW') {
const result = await this.$listeners.showConfirm(
'Firmware update OTW',
Expand Down
Loading

0 comments on commit 6bcf8e3

Please sign in to comment.