From 8c03d5dcd4ea7613fb91746cc392ebc4d423a5dc Mon Sep 17 00:00:00 2001 From: Marcus Davies <55892693+marcus-j-davies@users.noreply.github.com> Date: Sun, 15 Oct 2023 08:43:06 +0100 Subject: [PATCH] V9 (#283) * Docs and Package * First Draft * Update APIChange-v9.md * Update APIChange-v9.md * Update APIChange-v9.md * Update APIChange-v9.md * Update APIChange-v9.md * Update APIChange-v9.md * Update APIChange-v9.md * Update APIChange-v9.md * Update APIChange-v9.md * Update APIChange-v9.md * Update APIChange-v9.md * Update APIChange-v9.md * Update APIChange-v9.md * Guide * Clean up * extras * Woah! * Fix CMDF * Fix scan issues * Few fixes * Update zwave-js.js * Wrong API * Update APIChange-v9.md * Update APIChange-v9.md * Update APIChange-v9.md * Update APIChange-v9.md * Update APIChange-v9.md * Update APIChange-v9.md * getValueTimestamp * Update CHANGELOG.md * Update CHANGELOG.md * date format * Update CHANGELOG.md * Update package.json --- APIChange.md => APIChange-v4.md | 0 APIChange-v9.md | 117 ++++++++++++++++++++++++++++++++ CHANGELOG.md | 26 ++++++- package.json | 14 ++-- resources/UITab/client.js | 39 +++++------ zwave-js/cmd-factory.js | 64 +++++++---------- zwave-js/zwave-device.js | 46 +++++++++++++ zwave-js/zwave-js.js | 111 ++++++++++++++++++++++++++---- 8 files changed, 337 insertions(+), 80 deletions(-) rename APIChange.md => APIChange-v4.md (100%) create mode 100644 APIChange-v9.md diff --git a/APIChange.md b/APIChange-v4.md similarity index 100% rename from APIChange.md rename to APIChange-v4.md diff --git a/APIChange-v9.md b/APIChange-v9.md new file mode 100644 index 00000000..4aa5c7be --- /dev/null +++ b/APIChange-v9.md @@ -0,0 +1,117 @@ +# New API (9.0.0) Migration Guide + +V9 begins the take down of the old API introduced in v4. + +The old APIs are now set for removal and will be removed in V10. +Below, I set out the changes that you will need to make - and I suggest you make these changes after updating to V9. + +without further ado. + +Every command is now designed to be a consistant format, and the `payload` below will be the new format. +The reason for this change, is to make it easier for you (and me), to identify parts of the payload. + +Previously, setting a value using the Value API for instance, will involve sending an array of objects without any clue as to what they really are, this new format will address that. + + + +## Notes + +During this transition, the following APIs will be available using the new format : `DRIVER`, `ASSOCIATIONS` +However, these will form part of the combined `CONTROLLER` API when V10 lands. + +The properties `responseThroughEvent` and `forceUpdate` will be supported in the new message format (at the root of `payload`) +but support for them will be removed in V10 (please see change log) + +The `Node` API will be available in V10 and will house the `setName`, `setLocation` methods as well as a few new one 😃 + + + +```javascript +cmd:{ + api: 'CONTROLLER' | 'VALUE' | 'CC' | 'NODE', /* The API you want to use */ + method: string /* The method you are executing on this API */ +}, +cmdProperties:{ + + nodeId: number, /* The target Node ID */ + + /* CC API */ + commandClass: number, /* The Command class ID (CC) */ + method: string, /* The CC's method you want to execute (CC) */ + endpoint: number, /* The endpoint you wish to target (CC) */ + + /* CC, CONTROLLER API */ + args: any[], /* The args for the command you are calling (CC, CONTROLLER) */ + + /* VALUE API */ + valueId: object, /* The ValueID you are targeting (VALUE) */ + setValueOptions: object, /* Set Value Options (VALUE) */ + + /* VALUE, NODE API */ + value: any, /* The Value you are providing (VALUE, NODE) */ + +} +``` + +## Right!! so what do i do (we'll use the Wake Up CC for demonstration) +```javascript +/* This */ +let Message = { + payload: { + node: 37, + mode: "CCAPI", + class: "Wake Up", + method: "setInterval", + params: [3600] + } +} +return Message; + +/* Is now this */ +let Message = { + payload: { + cmd: { + api: 'CC', + method: 'invokeCCAPI' + }, + cmdProperties: { + nodeId: 37, + commandClass: 0x84, + method: 'setInterval', + args: [3600] + } + } +} +return Message; +``` + +```javascript +/* And this */ +let Message = { + payload: { + node: 5, + mode: "ValueAPI", + method: "setValue", + params: [,3600] + } +} +return Message; + +/* Is now this */ +let Message = { + payload: { + cmd: { + api: 'VALUE', + method: 'setValue' + }, + cmdProperties: { + nodeId: 5, + valueId: , + value: 3600 + } + } +} +return Message; +``` + + diff --git a/CHANGELOG.md b/CHANGELOG.md index 5495d5db..ded93721 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,29 @@ # node-red-contrib-zwave-js Change Log + - 9.0.0 + + **Breaking Changes** + - The min node version is now 18 + - If you execute certain methods your self, the following have been renamed + - `beginHealingNetwork` -> `beginRebuildingRoutes` + - `stopHealingNetwork` -> `stopRebuildingRoutes` + - `healNode` -> `rebuildNodeRoutes` + + **New Features** + - Added `getValueTimestamp` to the `Value API` - args will be the single Value ID + The event will be `VALUE_TIMESTAMP` + + **Changes** + - Bump ZWave JS to v12 + - The `lastSeen` property will now use the Drivers internal value, which is persistant between reboots + + **Deprecations** + - The old message format has now been deprecated, and support will be removed in V10. + [PLEASE SEE MIGRATION GUIDE](/APIChange-v9.md) + - Support for `responseThroughEvent` will be removed in V10 (all methods will return in v10) + - Support for `forceUpdate` will be removed in V10 (you will be requied to manage this your self if using the CC API) + - Support for `getLastEvents` will be removed in V10 (the introdcution of the persistant `lastSeen` value and `getValueTimestamp` has made this somewhat bloatware) + - 8.2.1 **Changes** @@ -418,7 +442,7 @@ - Bump Z-Wave JS to 7.12.1 - 4.0.0 **Possible Breaking Changes**, **Deprecation Warnings** - - MAJOR API Transition : [PLEASE SEE MIGRATION GUIDE](/APIChange.md) + - MAJOR API Transition : [PLEASE SEE MIGRATION GUIDE](/APIChange-v4.md) - Added Node Firmware Update UI - Added Network Map UI - Added Association Group Managment UI diff --git a/package.json b/package.json index 1ef34ec8..ff96b70a 100644 --- a/package.json +++ b/package.json @@ -1,24 +1,24 @@ { "name": "node-red-contrib-zwave-js", - "version": "8.2.1", + "version": "9.0.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.10.0", - "winston-transport": "^4.5.0", - "zwave-js": "^11.14.1" + "winston": "^3.11.0", + "winston-transport": "^4.6.0", + "zwave-js": "^12.1.1" }, "devDependencies": { - "eslint": "^8.49.0", + "eslint": "^8.51.0", "prettier": "^3.0.3" }, "scripts": { "validate": "node-red-dev validate -o validation_result.json" }, "engines": { - "node": ">=14.13.0" + "node": ">=18.0.0" }, "keywords": [ "node-red", @@ -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 2bebe1a4..1572e8e8 100644 --- a/resources/UITab/client.js +++ b/resources/UITab/client.js @@ -147,19 +147,19 @@ const DCs = { name: 'unprovisionAllSmartStart', noWait: false }, - healNode: { + rebuildNodeRoutes: { API: 'ControllerAPI', - name: 'healNode', + name: 'rebuildNodeRoutes', noWait: true }, - beginHealingNetwork: { + beginRebuildingRoutes: { API: 'ControllerAPI', - name: 'beginHealingNetwork', + name: 'beginRebuildingRoutes', noWait: false }, - stopHealingNetwork: { + stopRebuildingRoutes: { API: 'ControllerAPI', - name: 'stopHealingNetwork', + name: 'stopRebuildingRoutes', noWait: false }, hardReset: { @@ -1889,11 +1889,11 @@ const ZwaveJsUI = (function () { function StartNodeHeal() { ControllerCMD( - DCs.healNode.API, - DCs.healNode.name, + DCs.rebuildNodeRoutes.API, + DCs.rebuildNodeRoutes.name, undefined, [HoveredNode.nodeId], - DCs.healNode.noWait + DCs.rebuildNodeRoutes.noWait ).catch((err) => { modalAlert(err.responseText || err.message, 'Could not start Node heal.'); throw new Error(err.responseText || err.message); @@ -1902,11 +1902,11 @@ const ZwaveJsUI = (function () { function StartHeal() { ControllerCMD( - DCs.beginHealingNetwork.API, - DCs.beginHealingNetwork.name, + DCs.beginRebuildingRoutes.API, + DCs.beginRebuildingRoutes.name, undefined, undefined, - DCs.beginHealingNetwork.noWait + DCs.beginRebuildingRoutes.noWait ).catch((err) => { modalAlert( err.responseText || err.message, @@ -1918,11 +1918,11 @@ const ZwaveJsUI = (function () { function StopHeal() { ControllerCMD( - DCs.stopHealingNetwork.API, - DCs.stopHealingNetwork.name, + DCs.stopRebuildingRoutes.API, + DCs.stopRebuildingRoutes.name, undefined, undefined, - DCs.stopHealingNetwork.noWait + DCs.stopRebuildingRoutes.noWait ).catch((err) => { console.error(err); }); @@ -2230,7 +2230,7 @@ const ZwaveJsUI = (function () { }, { id: 'controller-option-menu-start-heal', - label: 'Begin Network Heal', + label: 'Begin Rebuilding Routes', onselect: function () { IsDriverReady(); StartHeal(); @@ -2238,7 +2238,7 @@ const ZwaveJsUI = (function () { }, { id: 'controller-option-menu-stop-heal', - label: 'Stop Network Heal', + label: 'Stop Rebuilding Routes', onselect: function () { IsDriverReady(); StopHeal(); @@ -3179,7 +3179,7 @@ const ZwaveJsUI = (function () { marginRight: '1px' }); Heal.append(''); - RED.popover.tooltip(Heal, 'Heal Node'); + RED.popover.tooltip(Heal, 'Rebuild Node Routes'); BA.append(Heal); const Associations = $('