From ed87d3641b7bfa519a48228f7d09cf3016a817f9 Mon Sep 17 00:00:00 2001 From: Marcus Davies <55892693+marcus-j-davies@users.noreply.github.com> Date: Tue, 25 Jul 2023 18:25:51 +0100 Subject: [PATCH] 8.2.0 (#278) * Migrate methods / args * Fix Firmware method arg * Small fix (use array in FWU) --- package.json | 12 ++++++------ resources/UITab/client.js | 15 +++++++-------- zwave-js/ui/server.js | 15 ++++++++++----- zwave-js/zwave-js.js | 19 ++++++++++++------- 4 files changed, 35 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index d227f762..6b7f98fa 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,18 @@ { "name": "node-red-contrib-zwave-js", - "version": "8.1.0", + "version": "8.2.0", "license": "MIT", "description": "The most powerful, high performing and highly polished Z-Wave node for Node-RED based on Z-Wave JS. If you want a fully featured Z-Wave framework in your Node-RED instance, you have found it.", "dependencies": { "limiter": "^2.1.0", "lodash": "^4.17.21", - "winston": "^3.8.2", + "winston": "^3.10.0", "winston-transport": "^4.5.0", - "zwave-js": "^10.16.0" + "zwave-js": "^11.6.0" }, "devDependencies": { - "eslint": "^8.39.0", - "prettier": "^2.8.8" + "eslint": "^8.45.0", + "prettier": "^3.0.0" }, "scripts": { "validate": "node-red-dev validate -o validation_result.json" @@ -61,4 +61,4 @@ "url": "https://github.com/zwave-js/node-red-contrib-zwave-js/issues" }, "homepage": "https://github.com/zwave-js/node-red-contrib-zwave-js#readme" -} +} \ No newline at end of file diff --git a/resources/UITab/client.js b/resources/UITab/client.js index 68a468c6..2bebe1a4 100644 --- a/resources/UITab/client.js +++ b/resources/UITab/client.js @@ -217,9 +217,9 @@ const DCs = { name: 'getAvailableFirmwareUpdates', noWait: false }, - beginOTAFirmwareUpdate: { + firmwareUpdateOTA: { API: 'ControllerAPI', - name: 'beginOTAFirmwareUpdate', + name: 'firmwareUpdateOTA', noWait: false } }; @@ -522,11 +522,11 @@ const ZwaveJsUI = (function () { } ControllerCMD( - DCs.beginOTAFirmwareUpdate.API, - DCs.beginOTAFirmwareUpdate.name, + DCs.firmwareUpdateOTA.API, + DCs.firmwareUpdateOTA.name, undefined, [Node, File], - DCs.beginOTAFirmwareUpdate.noWait + DCs.firmwareUpdateOTA.noWait ) .then(() => { FWRunning = true; @@ -1126,7 +1126,7 @@ const ZwaveJsUI = (function () { const RestrictedModes = ['IEAPI']; const RestrictedMethods = [ 'setPowerlevel', - 'beginFirmwareUpdate', + 'updateFirmware', 'abortFirmwareUpdate', 'setRFRegion', 'hardReset', @@ -3570,8 +3570,7 @@ const ZwaveJsUI = (function () { const Child = renderPropertyElement(Prop); propertyList - .treeList('data') - [Index].treeList.addChild({ element: Child }); + .treeList('data')[Index].treeList.addChild({ element: Child }); if (Writeable && Type !== 'any') { const icon = Child.prev(); diff --git a/zwave-js/ui/server.js b/zwave-js/ui/server.js index 5f5e6368..09ab3190 100644 --- a/zwave-js/ui/server.js +++ b/zwave-js/ui/server.js @@ -280,7 +280,7 @@ class UIServer { const PL = { mode: 'ControllerAPI', - method: 'beginFirmwareUpdate', + method: 'updateFirmware', params: [NodeID, Target, FileName, _Buffer] }; @@ -525,11 +525,16 @@ class UIServer { node.on('notification', (node, value) => { this._SendNodeEvent('node-value', node, value); }); - node.on('firmware update progress', (node, S, R) => { - this._SendNodeEvent('node-fwu-progress', node, { sent: S, remain: R }); + node.on('firmware update progress', (node, Progress) => { + this._SendNodeEvent('node-fwu-progress', node, { + sent: Progress.sentFragments, + remain: Progress.totalFragments - Progress.sentFragments + }); }); - node.on('firmware update finished', (node, Status) => { - this._SendNodeEvent('node-fwu-completed', node, { status: Status }); + node.on('firmware update finished', (node, Result) => { + this._SendNodeEvent('node-fwu-completed', node, { + status: Result.status + }); }); // Meta diff --git a/zwave-js/zwave-js.js b/zwave-js/zwave-js.js index 617c1113..25ceec04 100644 --- a/zwave-js/zwave-js.js +++ b/zwave-js/zwave-js.js @@ -915,10 +915,10 @@ module.exports = function (RED) { Send(ReturnNode, 'FIRMWARE_UPDATE_CHECK_RESULT', FWU, send); break; - case 'beginOTAFirmwareUpdate': + case 'firmwareUpdateOTA': NodeCheck(Params[0]); ReturnNode.id = Params[0]; - await Driver.controller.beginOTAFirmwareUpdate(Params[0], Params[1]); + await Driver.controller.firmwareUpdateOTA(Params[0], Params[1]); Send(ReturnNode, 'FIRMWARE_UPDATE_STARTED', Params[1], send); break; @@ -943,14 +943,19 @@ module.exports = function (RED) { Send(ReturnNode, 'FIRMWARE_UPDATE_ABORTED', undefined, send); break; - case 'beginFirmwareUpdate': + case 'updateFirmware': NodeCheck(Params[0]); ReturnNode.id = Params[0]; const Format = ZWaveJS.guessFirmwareFileFormat(Params[2], Params[3]); const Firmware = ZWaveJS.extractFirmware(Params[3], Format); + const Package = { + data: Firmware.data, + firmwareTarget: Params[1] + }; + await Driver.controller.nodes .get(Params[0]) - .beginFirmwareUpdate(Firmware.data, Params[1]); + .updateFirmware([Package]); Send(ReturnNode, 'FIRMWARE_UPDATE_STARTED', Params[1], send); break; @@ -1406,7 +1411,7 @@ module.exports = function (RED) { case 'getLastEvents': const PL = []; Driver.controller.nodes.forEach((N) => { - if(N.isControllerNode){ + if (N.isControllerNode) { return; } const I = { @@ -2136,8 +2141,8 @@ module.exports = function (RED) { } Node.once(event_Ready.zwaveName, () => { - Node.on(event_FirmwareUpdateFinished.zwaveName, (N, S) => { - Send(N, event_FirmwareUpdateFinished.redName, S); + Node.on(event_FirmwareUpdateFinished.zwaveName, (N, R) => { + Send(N, event_FirmwareUpdateFinished.redName, R); }); Node.on(event_ValueNotification.zwaveName, (N, VL) => {