Skip to content

Commit

Permalink
feat: link reliability checks (#3814)
Browse files Browse the repository at this point in the history
Co-authored-by: Dominic Griesel <dominic.griesel@nabucasa.com>
  • Loading branch information
robertsLando and AlCalzone authored Jul 17, 2024
1 parent 07404d5 commit f2fc6d6
Show file tree
Hide file tree
Showing 5 changed files with 411 additions and 0 deletions.
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

0 comments on commit f2fc6d6

Please sign in to comment.