Skip to content

Commit 8c03d5d

Browse files
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
1 parent c6bf1d5 commit 8c03d5d

File tree

8 files changed

+337
-80
lines changed

8 files changed

+337
-80
lines changed
File renamed without changes.

APIChange-v9.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# New API (9.0.0) Migration Guide
2+
3+
V9 begins the take down of the old API introduced in v4.
4+
5+
The old APIs are now set for removal and will be removed in V10.
6+
Below, I set out the changes that you will need to make - and I suggest you make these changes after updating to V9.
7+
8+
without further ado.
9+
10+
Every command is now designed to be a consistant format, and the `payload` below will be the new format.
11+
The reason for this change, is to make it easier for you (and me), to identify parts of the payload.
12+
13+
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.
14+
15+
16+
17+
## Notes
18+
19+
During this transition, the following APIs will be available using the new format : `DRIVER`, `ASSOCIATIONS`
20+
However, these will form part of the combined `CONTROLLER` API when V10 lands.
21+
22+
The properties `responseThroughEvent` and `forceUpdate` will be supported in the new message format (at the root of `payload`)
23+
but support for them will be removed in V10 (please see change log)
24+
25+
The `Node` API will be available in V10 and will house the `setName`, `setLocation` methods as well as a few new one 😃
26+
27+
28+
29+
```javascript
30+
cmd:{
31+
api: 'CONTROLLER' | 'VALUE' | 'CC' | 'NODE', /* The API you want to use */
32+
method: string /* The method you are executing on this API */
33+
},
34+
cmdProperties:{
35+
36+
nodeId: number, /* The target Node ID */
37+
38+
/* CC API */
39+
commandClass: number, /* The Command class ID (CC) */
40+
method: string, /* The CC's method you want to execute (CC) */
41+
endpoint: number, /* The endpoint you wish to target (CC) */
42+
43+
/* CC, CONTROLLER API */
44+
args: any[], /* The args for the command you are calling (CC, CONTROLLER) */
45+
46+
/* VALUE API */
47+
valueId: object, /* The ValueID you are targeting (VALUE) */
48+
setValueOptions: object, /* Set Value Options (VALUE) */
49+
50+
/* VALUE, NODE API */
51+
value: any, /* The Value you are providing (VALUE, NODE) */
52+
53+
}
54+
```
55+
56+
## Right!! so what do i do (we'll use the Wake Up CC for demonstration)
57+
```javascript
58+
/* This */
59+
let Message = {
60+
payload: {
61+
node: 37,
62+
mode: "CCAPI",
63+
class: "Wake Up",
64+
method: "setInterval",
65+
params: [3600]
66+
}
67+
}
68+
return Message;
69+
70+
/* Is now this */
71+
let Message = {
72+
payload: {
73+
cmd: {
74+
api: 'CC',
75+
method: 'invokeCCAPI'
76+
},
77+
cmdProperties: {
78+
nodeId: 37,
79+
commandClass: 0x84,
80+
method: 'setInterval',
81+
args: [3600]
82+
}
83+
}
84+
}
85+
return Message;
86+
```
87+
88+
```javascript
89+
/* And this */
90+
let Message = {
91+
payload: {
92+
node: 5,
93+
mode: "ValueAPI",
94+
method: "setValue",
95+
params: [<ValueID>,3600]
96+
}
97+
}
98+
return Message;
99+
100+
/* Is now this */
101+
let Message = {
102+
payload: {
103+
cmd: {
104+
api: 'VALUE',
105+
method: 'setValue'
106+
},
107+
cmdProperties: {
108+
nodeId: 5,
109+
valueId: <ValueID>,
110+
value: 3600
111+
}
112+
}
113+
}
114+
return Message;
115+
```
116+
117+

CHANGELOG.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
# node-red-contrib-zwave-js Change Log
22

3+
- 9.0.0
4+
5+
**Breaking Changes**
6+
- The min node version is now 18
7+
- If you execute certain methods your self, the following have been renamed
8+
- `beginHealingNetwork` -> `beginRebuildingRoutes`
9+
- `stopHealingNetwork` -> `stopRebuildingRoutes`
10+
- `healNode` -> `rebuildNodeRoutes`
11+
12+
**New Features**
13+
- Added `getValueTimestamp` to the `Value API` - args will be the single Value ID
14+
The event will be `VALUE_TIMESTAMP`
15+
16+
**Changes**
17+
- Bump ZWave JS to v12
18+
- The `lastSeen` property will now use the Drivers internal value, which is persistant between reboots
19+
20+
**Deprecations**
21+
- The old message format has now been deprecated, and support will be removed in V10.
22+
[PLEASE SEE MIGRATION GUIDE](/APIChange-v9.md)
23+
- Support for `responseThroughEvent` will be removed in V10 (all methods will return in v10)
24+
- Support for `forceUpdate` will be removed in V10 (you will be requied to manage this your self if using the CC API)
25+
- Support for `getLastEvents` will be removed in V10 (the introdcution of the persistant `lastSeen` value and `getValueTimestamp` has made this somewhat bloatware)
26+
327
- 8.2.1
428

529
**Changes**
@@ -418,7 +442,7 @@
418442
- Bump Z-Wave JS to 7.12.1
419443

420444
- 4.0.0 **Possible Breaking Changes**, **Deprecation Warnings**
421-
- MAJOR API Transition : [PLEASE SEE MIGRATION GUIDE](/APIChange.md)
445+
- MAJOR API Transition : [PLEASE SEE MIGRATION GUIDE](/APIChange-v4.md)
422446
- Added Node Firmware Update UI
423447
- Added Network Map UI
424448
- Added Association Group Managment UI

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
{
22
"name": "node-red-contrib-zwave-js",
3-
"version": "8.2.1",
3+
"version": "9.0.0",
44
"license": "MIT",
55
"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.",
66
"dependencies": {
77
"limiter": "^2.1.0",
88
"lodash": "^4.17.21",
9-
"winston": "^3.10.0",
10-
"winston-transport": "^4.5.0",
11-
"zwave-js": "^11.14.1"
9+
"winston": "^3.11.0",
10+
"winston-transport": "^4.6.0",
11+
"zwave-js": "^12.1.1"
1212
},
1313
"devDependencies": {
14-
"eslint": "^8.49.0",
14+
"eslint": "^8.51.0",
1515
"prettier": "^3.0.3"
1616
},
1717
"scripts": {
1818
"validate": "node-red-dev validate -o validation_result.json"
1919
},
2020
"engines": {
21-
"node": ">=14.13.0"
21+
"node": ">=18.0.0"
2222
},
2323
"keywords": [
2424
"node-red",
@@ -61,4 +61,4 @@
6161
"url": "https://github.com/zwave-js/node-red-contrib-zwave-js/issues"
6262
},
6363
"homepage": "https://github.com/zwave-js/node-red-contrib-zwave-js#readme"
64-
}
64+
}

resources/UITab/client.js

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -147,19 +147,19 @@ const DCs = {
147147
name: 'unprovisionAllSmartStart',
148148
noWait: false
149149
},
150-
healNode: {
150+
rebuildNodeRoutes: {
151151
API: 'ControllerAPI',
152-
name: 'healNode',
152+
name: 'rebuildNodeRoutes',
153153
noWait: true
154154
},
155-
beginHealingNetwork: {
155+
beginRebuildingRoutes: {
156156
API: 'ControllerAPI',
157-
name: 'beginHealingNetwork',
157+
name: 'beginRebuildingRoutes',
158158
noWait: false
159159
},
160-
stopHealingNetwork: {
160+
stopRebuildingRoutes: {
161161
API: 'ControllerAPI',
162-
name: 'stopHealingNetwork',
162+
name: 'stopRebuildingRoutes',
163163
noWait: false
164164
},
165165
hardReset: {
@@ -1889,11 +1889,11 @@ const ZwaveJsUI = (function () {
18891889

18901890
function StartNodeHeal() {
18911891
ControllerCMD(
1892-
DCs.healNode.API,
1893-
DCs.healNode.name,
1892+
DCs.rebuildNodeRoutes.API,
1893+
DCs.rebuildNodeRoutes.name,
18941894
undefined,
18951895
[HoveredNode.nodeId],
1896-
DCs.healNode.noWait
1896+
DCs.rebuildNodeRoutes.noWait
18971897
).catch((err) => {
18981898
modalAlert(err.responseText || err.message, 'Could not start Node heal.');
18991899
throw new Error(err.responseText || err.message);
@@ -1902,11 +1902,11 @@ const ZwaveJsUI = (function () {
19021902

19031903
function StartHeal() {
19041904
ControllerCMD(
1905-
DCs.beginHealingNetwork.API,
1906-
DCs.beginHealingNetwork.name,
1905+
DCs.beginRebuildingRoutes.API,
1906+
DCs.beginRebuildingRoutes.name,
19071907
undefined,
19081908
undefined,
1909-
DCs.beginHealingNetwork.noWait
1909+
DCs.beginRebuildingRoutes.noWait
19101910
).catch((err) => {
19111911
modalAlert(
19121912
err.responseText || err.message,
@@ -1918,11 +1918,11 @@ const ZwaveJsUI = (function () {
19181918

19191919
function StopHeal() {
19201920
ControllerCMD(
1921-
DCs.stopHealingNetwork.API,
1922-
DCs.stopHealingNetwork.name,
1921+
DCs.stopRebuildingRoutes.API,
1922+
DCs.stopRebuildingRoutes.name,
19231923
undefined,
19241924
undefined,
1925-
DCs.stopHealingNetwork.noWait
1925+
DCs.stopRebuildingRoutes.noWait
19261926
).catch((err) => {
19271927
console.error(err);
19281928
});
@@ -2230,15 +2230,15 @@ const ZwaveJsUI = (function () {
22302230
},
22312231
{
22322232
id: 'controller-option-menu-start-heal',
2233-
label: 'Begin Network Heal',
2233+
label: 'Begin Rebuilding Routes',
22342234
onselect: function () {
22352235
IsDriverReady();
22362236
StartHeal();
22372237
}
22382238
},
22392239
{
22402240
id: 'controller-option-menu-stop-heal',
2241-
label: 'Stop Network Heal',
2241+
label: 'Stop Rebuilding Routes',
22422242
onselect: function () {
22432243
IsDriverReady();
22442244
StopHeal();
@@ -3179,7 +3179,7 @@ const ZwaveJsUI = (function () {
31793179
marginRight: '1px'
31803180
});
31813181
Heal.append('<i class="fa fa-medkit fa-lg"></i>');
3182-
RED.popover.tooltip(Heal, 'Heal Node');
3182+
RED.popover.tooltip(Heal, 'Rebuild Node Routes');
31833183
BA.append(Heal);
31843184

31853185
const Associations = $('<button>');
@@ -3570,7 +3570,8 @@ const ZwaveJsUI = (function () {
35703570

35713571
const Child = renderPropertyElement(Prop);
35723572
propertyList
3573-
.treeList('data')[Index].treeList.addChild({ element: Child });
3573+
.treeList('data')
3574+
[Index].treeList.addChild({ element: Child });
35743575

35753576
if (Writeable && Type !== 'any') {
35763577
const icon = Child.prev();

zwave-js/cmd-factory.js

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -122,28 +122,18 @@ module.exports = function (RED) {
122122
}
123123
}
124124

125-
const RM = {};
126-
RM.mode = 'ValueAPI';
127-
RM.method = config.vapiMode;
128-
RM.node = NodeID;
129-
RM.params = [];
130-
RM.params.push(ValueID);
131-
if (config.vapiMode === 'setValue') {
132-
RM.params.push(Value);
133-
if (Options !== undefined) {
134-
RM.params.push(Options);
125+
const RM = {
126+
cmd: {
127+
api: 'VALUE',
128+
method: config.vapiMode
129+
},
130+
cmdProperties: {
131+
nodeId: NodeID,
132+
value: Value,
133+
valueId: ValueID,
134+
setValueOptions: Options
135135
}
136-
}
137-
138-
if (RM.params.length < 1) {
139-
delete RM['params'];
140-
}
141-
142-
Object.keys(RM).forEach((K) => {
143-
if (typeof RM[K] === 'undefined') {
144-
delete RM[K];
145-
}
146-
});
136+
};
147137

148138
msg.payload = RM;
149139

@@ -218,23 +208,21 @@ module.exports = function (RED) {
218208
}
219209
}
220210

221-
const RM = {};
222-
RM.mode = 'CCAPI';
223-
RM.cc = config.cc;
224-
RM.method = config.method;
225-
RM.responseThroughEvent = NoEvent !== true;
226-
RM.node = NodeID;
227-
RM.endpoint = Endpoint;
228-
RM.params = Params;
229-
if (ForceUpdate !== undefined) {
230-
RM.forceUpdate = ForceUpdate;
231-
}
232-
233-
Object.keys(RM).forEach((K) => {
234-
if (typeof RM[K] === 'undefined') {
235-
delete RM[K];
236-
}
237-
});
211+
const RM = {
212+
cmd: {
213+
api: 'CC',
214+
method: 'invokeCCAPI'
215+
},
216+
cmdProperties: {
217+
nodeId: NodeID,
218+
endpoint: Endpoint,
219+
commandClass: config.cc,
220+
method: config.method,
221+
args: Params
222+
},
223+
responseThroughEvent: NoEvent !== true,
224+
forceUpdate: ForceUpdate
225+
};
238226

239227
msg.payload = RM;
240228

0 commit comments

Comments
 (0)