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

feat: link reliability checks #3814

Merged
merged 9 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions api/lib/SocketEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export enum socketEvents {
inclusionAborted = 'INCLUSION_ABORTED',
znifferFrame = 'ZNIFFER_FRAME',
znifferState = 'ZNIFFER_STATE',
linkReliability = 'LINK_RELIABILITY',
}

// events from client ---> server
Expand Down
41 changes: 41 additions & 0 deletions api/lib/ZwaveClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ import {
InclusionUserCallbacks,
InclusionState,
ProvisioningEntryStatus,
LinkReliabilityCheckResult,
} from 'zwave-js'
import { getEnumMemberName, parseQRCodeString } from 'zwave-js/Utils'
import { logsDir, nvmBackupsDir, storeDir } from '../config/app'
Expand Down Expand Up @@ -229,6 +230,8 @@ export const allowedApis = validateMethods([
'checkLifelineHealth',
'abortHealthCheck',
'checkRouteHealth',
'checkLinkReliability',
'abortLinkReliabilityCheck',
'syncNodeDateAndTime',
'manuallyIdleNotificationValue',
'getSchedules',
Expand Down Expand Up @@ -3682,6 +3685,32 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
throw new DriverNotReadyError()
}

async checkLinkReliability(
nodeId: number,
options: any,
): Promise<LinkReliabilityCheckResult> {
if (this.driverReady) {
const result = await this.getNode(nodeId).checkLinkReliability({
...options,
onProgress: (progress) =>
this._onLinkReliabilityCheckProgress({ nodeId }, progress),
})

return result
}

throw new DriverNotReadyError()
}

abortLinkReliabilityCheck(nodeId: number): void {
if (this.driverReady) {
this.getNode(nodeId).abortLinkReliabilityCheck()
return
}

throw new DriverNotReadyError()
}

/**
* Check node routes health
*/
Expand Down Expand Up @@ -4781,6 +4810,18 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
})
}

private _onLinkReliabilityCheckProgress(
request: { nodeId: number },
...args: any[]
) {
// const message = `Link statistics ${request.nodeId}: ${args.join(', ')}`
// this._updateControllerStatus(message)
this.sendToSocket(socketEvents.linkReliability, {
request,
args,
})
}

private _onRebuildRoutesDone(result) {
const message = `Rebuild Routes process COMPLETED. Healed ${result.size} nodes`
this._updateControllerStatus(message)
Expand Down
22 changes: 22 additions & 0 deletions src/components/custom/NodePanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,16 @@
<v-icon>monitor_heart</v-icon>
</v-btn>
</v-col>
<v-col class="pa-1">
<v-btn
color="purple"
small
rounded
@click="dialogLinkReliability = true"
>Link Statistics
<v-icon>leak_add</v-icon>
</v-btn>
</v-col>
<v-col v-if="!isLongRange" class="pa-1">
<v-btn
color="error"
Expand Down Expand Up @@ -341,6 +351,15 @@
:socket="socket"
:node="node"
/>

<dialog-link-reliability
v-if="node && !node.isControllerNode"
v-model="dialogLinkReliability"
@close="dialogLinkReliability = false"
:socket="socket"
:node="node"
/>

<v-dialog
fullscreen
persistent
Expand Down Expand Up @@ -398,6 +417,8 @@ export default {
BgRssiChart: () => import('@/components/custom/BgRssiChart.vue'),
DialogHealthCheck: () =>
import('@/components/dialogs/DialogHealthCheck.vue'),
DialogLinkReliability: () =>
import('@/components/dialogs/DialogLinkReliability.vue'),
draggable,
},
props: {
Expand All @@ -416,6 +437,7 @@ export default {
data: () => ({
showFullscreen: false,
dialogHealth: false,
dialogLinkReliability: false,
discoverLoading: false,
routesChanged: false,
returnRoutes: [],
Expand Down
Loading
Loading