Skip to content

Commit c6bf1d5

Browse files
Node RED 3.1
1 parent be2a3b5 commit c6bf1d5

File tree

3 files changed

+80
-15
lines changed

3 files changed

+80
-15
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# node-red-contrib-zwave-js Change Log
22

3+
- 8.2.1
4+
5+
**Changes**
6+
- Bump ZWave JS
7+
8+
**Bug Fixes**
9+
- Address Node RED 3.1 **evaluateJSONataExpression** Warning
10+
11+
312
- 8.2.0
413

514
**Changes**

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
22
"name": "node-red-contrib-zwave-js",
3-
"version": "8.2.0",
3+
"version": "8.2.1",
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",
99
"winston": "^3.10.0",
1010
"winston-transport": "^4.5.0",
11-
"zwave-js": "^11.6.0"
11+
"zwave-js": "^11.14.1"
1212
},
1313
"devDependencies": {
14-
"eslint": "^8.45.0",
15-
"prettier": "^3.0.0"
14+
"eslint": "^8.49.0",
15+
"prettier": "^3.0.3"
1616
},
1717
"scripts": {
1818
"validate": "node-red-dev validate -o validation_result.json"

zwave-js/cmd-factory.js

Lines changed: 67 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,45 +29,79 @@ module.exports = function (RED) {
2929
}
3030
}
3131

32-
function ValueAPI(msg, send) {
32+
let _AwaiterResolver;
33+
const Awaiter = () => {
34+
return new Promise((Resolve) => {
35+
_AwaiterResolver = Resolve;
36+
});
37+
};
38+
39+
async function ValueAPI(msg, send) {
3340
let NodeID = undefined;
3441
let Endpoint = undefined;
3542
let Value = undefined;
3643
let ValueID = undefined;
3744
let Options = undefined;
3845

46+
let Waiter;
47+
3948
if (config.node !== undefined && config.node.length > 0) {
49+
Waiter = Awaiter();
4050
const EXP = RED.util.prepareJSONataExpression(config.node, RedNode);
41-
NodeID = RED.util.evaluateJSONataExpression(EXP, msg);
51+
RED.util.evaluateJSONataExpression(EXP, msg, (Err, Res) => {
52+
NodeID = Res;
53+
_AwaiterResolver();
54+
});
55+
await Promise.all([Waiter]);
4256
}
4357

4458
if (config.endpoint !== undefined && config.endpoint.length > 0) {
59+
Waiter = Awaiter();
4560
const EXP = RED.util.prepareJSONataExpression(config.endpoint, RedNode);
46-
Endpoint = RED.util.evaluateJSONataExpression(EXP, msg);
61+
RED.util.evaluateJSONataExpression(EXP, msg, (Err, Res) => {
62+
Endpoint = Res;
63+
_AwaiterResolver();
64+
});
65+
await Promise.all([Waiter]);
4766
}
4867

4968
if (config.vapiValueId !== undefined && config.vapiValueId.length > 0) {
69+
Waiter = Awaiter();
5070
const EXP = RED.util.prepareJSONataExpression(
5171
config.vapiValueId,
5272
RedNode
5373
);
54-
ValueID = RED.util.evaluateJSONataExpression(EXP, msg);
74+
RED.util.evaluateJSONataExpression(EXP, msg, (Err, Res) => {
75+
ValueID = Res;
76+
_AwaiterResolver();
77+
});
78+
await Promise.all([Waiter]);
5579
}
5680

5781
if (config.vapiOptions !== undefined && config.vapiOptions.length > 0) {
82+
Waiter = Awaiter();
5883
const EXP = RED.util.prepareJSONataExpression(
5984
config.vapiOptions,
6085
RedNode
6186
);
62-
Options = RED.util.evaluateJSONataExpression(EXP, msg);
87+
RED.util.evaluateJSONataExpression(EXP, msg, (Err, Res) => {
88+
Options = Res;
89+
_AwaiterResolver();
90+
});
91+
await Promise.all([Waiter]);
6392
}
6493

6594
if (config.vapiValue !== undefined && config.vapiValue.length > 0) {
95+
Waiter = Awaiter();
6696
const EXP = RED.util.prepareJSONataExpression(
6797
config.vapiValue,
6898
RedNode
6999
);
70-
Value = RED.util.evaluateJSONataExpression(EXP, msg);
100+
RED.util.evaluateJSONataExpression(EXP, msg, (Err, Res) => {
101+
Value = Res;
102+
_AwaiterResolver();
103+
});
104+
await Promise.all([Waiter]);
71105
}
72106

73107
if (ValueID === undefined) {
@@ -120,34 +154,56 @@ module.exports = function (RED) {
120154
}
121155
}
122156

123-
function CCAPI(msg, send) {
157+
async function CCAPI(msg, send) {
124158
let NodeID = undefined;
125159
let Endpoint = undefined;
126160
let Params = undefined;
127161
const NoEvent = config.noEvent || false;
128162
let ForceUpdate = undefined;
129163

164+
let Waiter;
165+
130166
if (config.node !== undefined && config.node.length > 0) {
167+
Waiter = Awaiter();
131168
const EXP = RED.util.prepareJSONataExpression(config.node, RedNode);
132-
NodeID = RED.util.evaluateJSONataExpression(EXP, msg);
169+
RED.util.evaluateJSONataExpression(EXP, msg, (Err, Res) => {
170+
NodeID = Res;
171+
_AwaiterResolver();
172+
});
173+
await Promise.all([Waiter]);
133174
}
134175

135176
if (config.endpoint !== undefined && config.endpoint.length > 0) {
177+
Waiter = Awaiter();
136178
const EXP = RED.util.prepareJSONataExpression(config.endpoint, RedNode);
137-
Endpoint = RED.util.evaluateJSONataExpression(EXP, msg);
179+
RED.util.evaluateJSONataExpression(EXP, msg, (Err, Res) => {
180+
Endpoint = Res;
181+
_AwaiterResolver();
182+
});
183+
await Promise.all([Waiter]);
138184
}
139185

140186
if (config.params !== undefined && config.params.length > 0) {
187+
Waiter = Awaiter();
141188
const EXP = RED.util.prepareJSONataExpression(config.params, RedNode);
142-
Params = RED.util.evaluateJSONataExpression(EXP, msg);
189+
RED.util.evaluateJSONataExpression(EXP, msg, (Err, Res) => {
190+
Params = Res;
191+
_AwaiterResolver();
192+
});
193+
await Promise.all([Waiter]);
143194
}
144195

145196
if (config.forceUpdate !== undefined && config.forceUpdate.length > 0) {
197+
Waiter = Awaiter();
146198
const EXP = RED.util.prepareJSONataExpression(
147199
config.forceUpdate,
148200
RedNode
149201
);
150-
ForceUpdate = RED.util.evaluateJSONataExpression(EXP, msg);
202+
RED.util.evaluateJSONataExpression(EXP, msg, (Err, Res) => {
203+
ForceUpdate = Res;
204+
_AwaiterResolver();
205+
});
206+
await Promise.all([Waiter]);
151207
}
152208

153209
if (Params !== undefined) {

0 commit comments

Comments
 (0)