Skip to content

Commit

Permalink
Node RED 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-j-davies committed Sep 10, 2023
1 parent be2a3b5 commit c6bf1d5
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 15 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# node-red-contrib-zwave-js Change Log

- 8.2.1

**Changes**
- Bump ZWave JS

**Bug Fixes**
- Address Node RED 3.1 **evaluateJSONataExpression** Warning


- 8.2.0

**Changes**
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "node-red-contrib-zwave-js",
"version": "8.2.0",
"version": "8.2.1",
"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.6.0"
"zwave-js": "^11.14.1"
},
"devDependencies": {
"eslint": "^8.45.0",
"prettier": "^3.0.0"
"eslint": "^8.49.0",
"prettier": "^3.0.3"
},
"scripts": {
"validate": "node-red-dev validate -o validation_result.json"
Expand Down
78 changes: 67 additions & 11 deletions zwave-js/cmd-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,45 +29,79 @@ module.exports = function (RED) {
}
}

function ValueAPI(msg, send) {
let _AwaiterResolver;
const Awaiter = () => {
return new Promise((Resolve) => {
_AwaiterResolver = Resolve;
});
};

async function ValueAPI(msg, send) {
let NodeID = undefined;
let Endpoint = undefined;
let Value = undefined;
let ValueID = undefined;
let Options = undefined;

let Waiter;

if (config.node !== undefined && config.node.length > 0) {
Waiter = Awaiter();
const EXP = RED.util.prepareJSONataExpression(config.node, RedNode);
NodeID = RED.util.evaluateJSONataExpression(EXP, msg);
RED.util.evaluateJSONataExpression(EXP, msg, (Err, Res) => {
NodeID = Res;
_AwaiterResolver();
});
await Promise.all([Waiter]);
}

if (config.endpoint !== undefined && config.endpoint.length > 0) {
Waiter = Awaiter();
const EXP = RED.util.prepareJSONataExpression(config.endpoint, RedNode);
Endpoint = RED.util.evaluateJSONataExpression(EXP, msg);
RED.util.evaluateJSONataExpression(EXP, msg, (Err, Res) => {
Endpoint = Res;
_AwaiterResolver();
});
await Promise.all([Waiter]);
}

if (config.vapiValueId !== undefined && config.vapiValueId.length > 0) {
Waiter = Awaiter();
const EXP = RED.util.prepareJSONataExpression(
config.vapiValueId,
RedNode
);
ValueID = RED.util.evaluateJSONataExpression(EXP, msg);
RED.util.evaluateJSONataExpression(EXP, msg, (Err, Res) => {
ValueID = Res;
_AwaiterResolver();
});
await Promise.all([Waiter]);
}

if (config.vapiOptions !== undefined && config.vapiOptions.length > 0) {
Waiter = Awaiter();
const EXP = RED.util.prepareJSONataExpression(
config.vapiOptions,
RedNode
);
Options = RED.util.evaluateJSONataExpression(EXP, msg);
RED.util.evaluateJSONataExpression(EXP, msg, (Err, Res) => {
Options = Res;
_AwaiterResolver();
});
await Promise.all([Waiter]);
}

if (config.vapiValue !== undefined && config.vapiValue.length > 0) {
Waiter = Awaiter();
const EXP = RED.util.prepareJSONataExpression(
config.vapiValue,
RedNode
);
Value = RED.util.evaluateJSONataExpression(EXP, msg);
RED.util.evaluateJSONataExpression(EXP, msg, (Err, Res) => {
Value = Res;
_AwaiterResolver();
});
await Promise.all([Waiter]);
}

if (ValueID === undefined) {
Expand Down Expand Up @@ -120,34 +154,56 @@ module.exports = function (RED) {
}
}

function CCAPI(msg, send) {
async function CCAPI(msg, send) {
let NodeID = undefined;
let Endpoint = undefined;
let Params = undefined;
const NoEvent = config.noEvent || false;
let ForceUpdate = undefined;

let Waiter;

if (config.node !== undefined && config.node.length > 0) {
Waiter = Awaiter();
const EXP = RED.util.prepareJSONataExpression(config.node, RedNode);
NodeID = RED.util.evaluateJSONataExpression(EXP, msg);
RED.util.evaluateJSONataExpression(EXP, msg, (Err, Res) => {
NodeID = Res;
_AwaiterResolver();
});
await Promise.all([Waiter]);
}

if (config.endpoint !== undefined && config.endpoint.length > 0) {
Waiter = Awaiter();
const EXP = RED.util.prepareJSONataExpression(config.endpoint, RedNode);
Endpoint = RED.util.evaluateJSONataExpression(EXP, msg);
RED.util.evaluateJSONataExpression(EXP, msg, (Err, Res) => {
Endpoint = Res;
_AwaiterResolver();
});
await Promise.all([Waiter]);
}

if (config.params !== undefined && config.params.length > 0) {
Waiter = Awaiter();
const EXP = RED.util.prepareJSONataExpression(config.params, RedNode);
Params = RED.util.evaluateJSONataExpression(EXP, msg);
RED.util.evaluateJSONataExpression(EXP, msg, (Err, Res) => {
Params = Res;
_AwaiterResolver();
});
await Promise.all([Waiter]);
}

if (config.forceUpdate !== undefined && config.forceUpdate.length > 0) {
Waiter = Awaiter();
const EXP = RED.util.prepareJSONataExpression(
config.forceUpdate,
RedNode
);
ForceUpdate = RED.util.evaluateJSONataExpression(EXP, msg);
RED.util.evaluateJSONataExpression(EXP, msg, (Err, Res) => {
ForceUpdate = Res;
_AwaiterResolver();
});
await Promise.all([Waiter]);
}

if (Params !== undefined) {
Expand Down

0 comments on commit c6bf1d5

Please sign in to comment.