Skip to content

Commit

Permalink
Merge pull request #105 from zwave-js/dev
Browse files Browse the repository at this point in the history
Supplementary 5.1.1 update
  • Loading branch information
marcus-j-davies authored Sep 6, 2021
2 parents 58072ce + 7de217f commit e8941bb
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 80 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# node-red-contrib-zwave-js Change Log

- 5.1.1

**Changes**
- Display Driver DB Version in node config
- Bump serial ports to 9.2.1
- Fix LGTM Alerts

- 5.1.0

**New Features**
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "node-red-contrib-zwave-js",
"version": "5.1.0",
"version": "5.1.1",
"license": "MIT",
"description": "An extremely powerful, easy to use, zero dependency and feature rich Z-Wave node for Node Red, based on Z-Wave JS.",
"dependencies": {
"@serialport/bindings": "9.2.0",
"@serialport/bindings": "9.2.1",
"express": "4.17.1",
"lodash": "4.17.21",
"serialport": "9.2.0",
"serialport": "9.2.1",
"winston": "3.3.3",
"winston-transport": "4.4.0",
"zwave-js": "^8.2.3"
Expand All @@ -21,7 +21,7 @@
"npm": ">=6.14.13"
},
"scripts": {
"preinstall": "npm install @serialport/[email protected].0 --build-from-source && npm install [email protected].0 --build-from-source"
"preinstall": "npm install @serialport/[email protected].1 --build-from-source && npm install [email protected].1 --build-from-source"
},
"keywords": [
"node-red",
Expand Down
104 changes: 36 additions & 68 deletions zwave-js/ui/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ const ZwaveJsUI = (function () {
});
}

async function GenerateMapJSON(Nodes, Neigbhors) {
async function GenerateMapJSON(Nodes) {
const _Promises = [];
const _Nodes = [];
const _Edges = [];
Expand Down Expand Up @@ -365,79 +365,47 @@ const ZwaveJsUI = (function () {
_Nodes.push(ND);
});

if (typeof Neigbhors === 'undefined') {
Nodes.forEach((N) => {
if (N.isControllerNode) {
return;
}
Nodes.forEach((N) => {
if (N.isControllerNode) {
return;
}

const P = new Promise((res) => {
ControllerCMD('ControllerAPI', 'getNodeNeighbors', undefined, [
N.nodeId
]).then(({ node, object }) => {
object.forEach((NodeNeighbor) => {
const Neighbor = _Nodes.filter(
(Node) => Node.id === NodeNeighbor
)[0];
if (Neighbor.canRoute) {
const AlreadyAttached = _Edges.filter(
const P = new Promise((res) => {
ControllerCMD('ControllerAPI', 'getNodeNeighbors', undefined, [
N.nodeId
]).then(({ node, object }) => {
object.forEach((NodeNeighbor) => {
const Neighbor = _Nodes.filter(
(Node) => Node.id === NodeNeighbor
)[0];
if (Neighbor.canRoute) {
const AlreadyAttached = _Edges.filter(
(E) => E.from === NodeNeighbor && E.to === node
);
if (AlreadyAttached.length < 1) {
const Color = {
highlight: Neighbor.isControllerNode ? 'green' : '#000000',
color: '#d3d3d3'
};
_Edges.push({
color: Color,
from: node,
to: NodeNeighbor,
arrows: { to: { enabled: true, type: 'arrow' } }
});
} else {
_Edges.filter(
(E) => E.from === NodeNeighbor && E.to === node
);
if (AlreadyAttached.length < 1) {
const Color = {
highlight: Neighbor.isControllerNode ? 'green' : '#000000',
color: '#d3d3d3'
};
_Edges.push({
color: Color,
from: node,
to: NodeNeighbor,
arrows: { to: { enabled: true, type: 'arrow' } }
});
} else {
_Edges.filter(
(E) => E.from === NodeNeighbor && E.to === node
)[0].arrows.from = { enabled: true, type: 'arrow' };
}
)[0].arrows.from = { enabled: true, type: 'arrow' };
}
});
res();
});
});
_Promises.push(P);
});
await Promise.all(_Promises);
} else {
Neigbhors.forEach(({ node, object }) => {
if (_Nodes.filter((Node) => Node.id === node)[0].isControllerNode) {
return;
}
object.forEach((NodeNeighbor) => {
const Neighbor = _Nodes.filter((Node) => Node.id === NodeNeighbor)[0];
if (Neighbor.canRoute) {
const AlreadyAttached = _Edges.filter(
(E) => E.from === NodeNeighbor && E.to === node
);
if (AlreadyAttached.length < 1) {
const Color = {
highlight: Neighbor.isControllerNode ? 'green' : '#000000',
color: '#d3d3d3'
};
_Edges.push({
color: Color,
from: node,
to: NodeNeighbor,
arrows: { to: { enabled: true, type: 'arrow' } }
});
} else {
_Edges.filter(
(E) => E.from === NodeNeighbor && E.to === node
)[0].arrows.from = { enabled: true, type: 'arrow' };
}
}
});
res();
});
});
}
_Promises.push(P);
});
await Promise.all(_Promises);

return { _Nodes, _Edges };
}
Expand Down
5 changes: 5 additions & 0 deletions zwave-js/zwave-js.html
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@
$.getJSON('zwjsgetversion', function (data) {
$('#MOD_Version').val(data.moduleversion);
$('#ZWJS_Version').val(data.zwjsversion);
$('#ZWJS_CFGVersion').val(data.zwjscfgversion);
});
}
</script>
Expand Down Expand Up @@ -757,6 +758,10 @@
<label for="ZWJS_Version" style="width:130px"><i class="fa fa-info"></i> Driver Version</label>
<input type="text" id="ZWJS_Version" readonly>
</div>
<div class="form-row">
<label for="ZWJS_CFGVersion" style="width:130px"><i class="fa fa-info"></i> DB Version</label>
<input type="text" id="ZWJS_CFGVersion" readonly>
</div>
</script>

<script type="text/x-red" data-help-name="zwave-js">
Expand Down
15 changes: 7 additions & 8 deletions zwave-js/zwave-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = function (RED) {
ZWaveErrorCodes
} = require('@zwave-js/core');
const ZWaveJSPackage = require('zwave-js/package.json');
const ZWaveCFGPackage = require('@zwave-js/config/package.json');
const Winston = require('winston');
const { Pin2LogTransport } = require('./Pin2LogTransport');

Expand Down Expand Up @@ -1189,15 +1190,12 @@ module.exports = function (RED) {
function printForceUpdate(NID, Value) {
const Lines = [];
Lines.push('[Node: ' + NID + ']');
Lines.push('└─[ValueID]');
const OBKeys = Object.keys(Value);
OBKeys.forEach((K) => {
Lines.push(' ' + (K + ': ') + Value[K]);
});

if (typeof Value !== 'undefined') {
Lines.push('└─[ValueID]');

const OBKeys = Object.keys(Value);
OBKeys.forEach((K) => {
Lines.push(' ' + (K + ': ') + Value[K]);
});
}
return Lines;
}

Expand Down Expand Up @@ -1646,6 +1644,7 @@ module.exports = function (RED) {
RED.httpAdmin.get('/zwjsgetversion', function (req, res) {
res.json({
zwjsversion: ZWaveJSPackage.version,
zwjscfgversion: ZWaveCFGPackage.version,
moduleversion: ModulePackage.version
});
});
Expand Down

0 comments on commit e8941bb

Please sign in to comment.