Skip to content

Commit

Permalink
feat: add dump node action (#3768)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando authored Jun 13, 2024
1 parent c12448c commit f07a854
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 2 deletions.
15 changes: 15 additions & 0 deletions api/lib/ZwaveClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ export const allowedApis = validateMethods([
'updateFirmware',
'firmwareUpdateOTW',
'abortFirmwareUpdate',
'dumpNode',
'getAvailableFirmwareUpdates',
'firmwareUpdateOTA',
'sendCommand',
Expand Down Expand Up @@ -3898,6 +3899,20 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
}
}

dumpNode(nodeId: number) {
if (this.driverReady) {
const zwaveNode = this.getNode(nodeId)

if (!zwaveNode) {
throw Error(`Node ${nodeId} not found`)
}

return zwaveNode.createDump()
}

throw new DriverNotReadyError()
}

beginRebuildingRoutes(options?: RebuildRoutesOptions): boolean {
if (this.driverReady) {
return this._driver.controller.beginRebuildingRoutes(options)
Expand Down
23 changes: 23 additions & 0 deletions docs/guide/mqtt.md
Original file line number Diff line number Diff line change
Expand Up @@ -1913,6 +1913,29 @@ Payload:

</details>

#### `dumpNode`

```ts
dumpNode(nodeId: number): import("/home/daniel/GitProjects/zwave-js-ui/node_modules/zwave-js/build/lib/node/Dump").NodeDump;
```

<details>
<summary>Mqtt usage</summary>

Topic: `zwave/_CLIENTS/ZWAVE_GATEWAY-<mqtt_name>/api/dumpNode/set`

Payload:

```json
{
"args": [
nodeId
]
}
```

</details>

#### `beginRebuildingRoutes`

```ts
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"dev": "vite",
"dev-https": "SERVER_SSL='true' npm run dev",
"dev:server": "nodemon",
"server": "ts-node -r esbuild-register api/bin/www.ts",
"server": "node -r ./esbuild-register.js api/bin/www.ts",
"fake-stick": "npx mock-server -- -c server_config.js",
"start": "node --preserve-symlinks server/bin/www.js",
"bundle": "node esbuild.js",
Expand Down
5 changes: 4 additions & 1 deletion src/components/nodes-table/ExpandedNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,10 @@ export default {
return [
{
text: 'Export json',
options: [{ name: 'Export', action: 'exportNode' }],
options: [
{ name: 'Export', action: 'exportNode' },
{ name: 'Dump', action: 'dumpNode' },
],
icon: 'get_app',
desc: 'Export this node in a json file',
},
Expand Down
8 changes: 8 additions & 0 deletions src/mixins/InstancesMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,14 @@ export default {
this.app.handleFwUpdateResponse(response)
break

case 'dumpNode':
this.app.exportConfiguration(
response.result,
'node_' + response.result.id + '_dump',
'json',
)
break

default:
this.showSnackbar(
`API ${response.api} ended successfully`,
Expand Down

0 comments on commit f07a854

Please sign in to comment.