From 27f3f819250232ca6f3212d96ae9d3d638b51f7c Mon Sep 17 00:00:00 2001 From: Klaus Landsdorf Date: Mon, 15 Apr 2024 20:36:31 +0200 Subject: [PATCH] feat(update): cleaning, testing, updating first steps --- .github/workflows/build.yml | 2 +- CHANGELOG.md | 13 +++++++++++++ README.md | 20 ++++++++++---------- index.js | 2 +- package-lock.json | 20 ++++++++++---------- package.json | 12 ++++++------ src/bacnet-client.html | 2 +- src/bacnet-client.js | 8 ++++---- src/bacnet-command.html | 13 +++++-------- src/bacnet-command.js | 8 ++++++-- src/bacnet-device.html | 2 +- src/bacnet-device.js | 2 +- src/bacnet-instance.html | 2 +- src/bacnet-instance.js | 2 +- src/bacnet-read.html | 29 ++++++++++++++++++++--------- src/bacnet-read.js | 2 +- src/bacnet-write.html | 14 +++++++------- src/bacnet-write.js | 13 +++++++------ src/core/bacnet-core.js | 2 +- test/bacnet-command-test.js | 2 +- test/bacnet-read-test.js | 2 +- test/bacnet-write-test.js | 2 +- 22 files changed, 100 insertions(+), 74 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2ff9852..5d4a959 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - node: [12, 14, 16, 18] + node: [14, 16, 18, 20] steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 diff --git a/CHANGELOG.md b/CHANGELOG.md index 1983312..c688d48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +# [0.3.0](https://github.com/BiancoRoyal/node-red-contrib-bacnet/compare/v0.2.7...v0.3.0) (2024-04-15) + + + +## [0.2.7](https://github.com/BiancoRoyal/node-red-contrib-bacnet/compare/v0.2.6...v0.2.7) (2022-09-25) + + +### Bug Fixes + +* Node-RED PLUS changed to PLUS for Node-RED ([bf86f55](https://github.com/BiancoRoyal/node-red-contrib-bacnet/commit/bf86f55dc3521915ec16b8969618fe20ef8ec31d)) + + + ## [0.2.6](https://github.com/BiancoRoyal/node-red-contrib-bacnet/compare/v0.2.5...v0.2.6) (2022-07-29) diff --git a/README.md b/README.md index b3b5831..53a71e9 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,8 @@ -![Platform Node-RED](http://b.repl.ca/v1/Platform-Node--RED-red.png) -![Node-RED BACnet](http://b.repl.ca/v1/Contribution-BACnet-blue.png) -[![Repository GitHub](http://b.repl.ca/v1/Repository-GitHub-orange.png)](https://github.com/BiancoRoyal/node-red-contrib-bacnet) +![Platform Node-RED](https://img.shields.io/badge/Platform-Node--RED-red.png) +![Node-RED BACnet](https://img.shields.io/badge/Contribution-BACnet-blue.png) +[![Repository GitHub](https://img.shields.io/badge/Repository-GitHub-orange.png)](https://github.com/BiancoRoyal/node-red-contrib-bacnet) [![NPM download](https://img.shields.io/npm/dm/node-red-contrib-bacnet.svg)](http://www.npm-stats.com/~packages/node-red-contrib-bacnet) -[![Quality Travis CI](http://b.repl.ca/v1/Quality-Travis_CI-green.png)](https://travis-ci.org/BiancoRoyal/node-red-contrib-bacnet) -[![Build Status](https://travis-ci.org/BiancoRoyal/node-red-contrib-bacnet.svg?branch=master)](https://travis-ci.org/BiancoRoyal/node-red-contrib-bacnet) +[![Quality Travis CI](https://img.shields.io/badge/Quality-Travis_CI-green.png)](https://travis-ci.org/BiancoRoyal/node-red-contrib-bacnet) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/6cbeb40ab5604b3ab99e6badc9469e8a)](https://www.codacy.com/gh/BiancoRoyal/node-red-contrib-bacnet?utm_source=github.com&utm_medium=referral&utm_content=BiancoRoyal/node-red-contrib-bacnet&utm_campaign=Badge_Grade) [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/BiancoRoyal/node-red-contrib-bacnet) @@ -19,7 +18,7 @@ For an international area, [Iniationware][6] has provided the [PLUS for Node-RED ### IIoT Webseite Deutschland für Node-RED -Für einen deutschsprachigen Bereich hat [Iniationware][6] die Webseite [PLUS for Node-RED Germany][7] bereitgestellt. +Für einen deutschsprachigen Bereich hat [Iniationware][9] die Webseite [PLUS for Node-RED Germany][7] bereitgestellt. ## Install @@ -56,9 +55,10 @@ I'd like to give special thanks to [fh1ch][2] and [Apollon77][4] for their work [1]:https://github.com/sponsors/biancode [2]:https://github.com/fh1ch -[3]:https://noderedplus.de/ +[3]:https://plus4nodered.com/ [4]:https://github.com/Apollon77 [5]:https://github.com/BiancoRoyal -[6]:https://github.com/Iniationware -[7]:https://www.noderedplus.de/de/ -[8]:https://www.noderedplus.de/ +[6]:https://iniationware.com/ +[7]:https://www.p4nr.com/de/ +[8]:https://www.p4nr.com/ +[9]:https://iniationware.de/ \ No newline at end of file diff --git a/index.js b/index.js index eb0f88d..13040d4 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ /* The MIT License - Copyright (c) 2017,2018,2019,2020,2021,2022 Klaus Landsdorf (http://node-red.plus/) + Copyright (c) 2017,2018,2019,2020,2021,2022,2023,2024 Klaus Landsdorf (http://plus4nodered.com/) All rights reserved. node-red-contrib-bacnet */ diff --git a/package-lock.json b/package-lock.json index 09b16c9..1c620d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,18 @@ { "name": "node-red-contrib-bacnet", - "version": "0.2.5", + "version": "0.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "node-red-contrib-bacnet", - "version": "0.2.5", + "version": "0.3.0", "hasInstallScript": true, "license": "MIT", "dependencies": { "debug": "~4.3.4", "node-bacnet": "~0.2.4", - "underscore": "~1.13.4" + "underscore": "~1.13.6" }, "devDependencies": { "@babel/cli": "^7.7.0", @@ -49,7 +49,7 @@ "when": "^3.7.8" }, "engines": { - "node": ">=10" + "node": ">=14" } }, "node_modules/@ampproject/remapping": { @@ -16472,9 +16472,9 @@ } }, "node_modules/underscore": { - "version": "1.13.4", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.4.tgz", - "integrity": "sha512-BQFnUDuAQ4Yf/cYY5LNrK9NCJFKriaRbD9uR1fTeXnBeoa97W0i41qkZfGO9pSo8I5KzjAcSY2XYtdf0oKd7KQ==" + "version": "1.13.6", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.6.tgz", + "integrity": "sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A==" }, "node_modules/undertaker": { "version": "1.3.0", @@ -30362,9 +30362,9 @@ "dev": true }, "underscore": { - "version": "1.13.4", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.4.tgz", - "integrity": "sha512-BQFnUDuAQ4Yf/cYY5LNrK9NCJFKriaRbD9uR1fTeXnBeoa97W0i41qkZfGO9pSo8I5KzjAcSY2XYtdf0oKd7KQ==" + "version": "1.13.6", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.6.tgz", + "integrity": "sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A==" }, "undertaker": { "version": "1.3.0", diff --git a/package.json b/package.json index f9aeb85..431ebf3 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "node-red-contrib-bacnet", - "version": "0.2.7", + "version": "0.3.0", "private": false, - "description": "The BACnet toolbox package for Node-RED.", + "description": "The BACnet toolbox package for Node-RED from the P4NR B2B Community.", "repository": { "type": "git", "url": "git+https://github.com/BiancoRoyal/node-red-contrib-bacnet.git" @@ -19,13 +19,13 @@ "fieldbus", "biancoroyal" ], - "author": "Klaus Landsdorf (https://bianco-royal.space/)", + "author": "P4NR Support (https://plus4nodered.com/)", "contributors": [ { - "name": "Node-RED PLUS (https://noderedplus.de/)" + "name": "P4NR B2B Community (https://p4nr.com/)" }, { - "name": "Iniationware GmbH (https://iniationware.com/)" + "name": "Iniationware GmbH (https://iniationware.com/)" }, { "name": "Ingo Fischer (Gameforge)" @@ -52,7 +52,7 @@ "engines": { "node": ">=14" }, - "homepage": "https://noderedplus.de/", + "homepage": "https://p4nr.com/", "scripts": { "test": "standard --fix && mocha test --recursive --reporter dot --timeout 5000", "test-with-coverage": "istanbul cover _mocha --report lcovonly -- --recursive --timeout 5000 -R spec && cat ./coverage/lcov.info | codacy-coverage --token $CODACY_COVERAGE_TOKEN && rm -rf ./coverage", diff --git a/src/bacnet-client.html b/src/bacnet-client.html index 081ae4f..963f69b 100644 --- a/src/bacnet-client.html +++ b/src/bacnet-client.html @@ -1,7 +1,7 @@ diff --git a/src/bacnet-client.js b/src/bacnet-client.js index 8ac551b..ee9d756 100644 --- a/src/bacnet-client.js +++ b/src/bacnet-client.js @@ -1,7 +1,7 @@ /* The MIT License - Copyright (c) 2017,2018,2019,2020,2021,2022 Klaus Landsdorf (http://node-red.plus/) + Copyright (c) 2017,2018,2019,2020,2021,2022,2023,2024 Klaus Landsdorf (http://plus4nodered.com/) All rights reserved. node-red-contrib-bacnet */ @@ -72,9 +72,9 @@ module.exports = function (RED) { node.whoIsExplicit = function (lowLimit, highLimit, deviceIPAddress, cb) { node.devices = [] const options = { - lowLimit: lowLimit, - highLimit: highLimit, - deviceIPAddress: deviceIPAddress + lowLimit, + highLimit, + deviceIPAddress } node.client.whoIs(options) setTimeout(cb, 3000) diff --git a/src/bacnet-command.html b/src/bacnet-command.html index 4926c93..087efdf 100644 --- a/src/bacnet-command.html +++ b/src/bacnet-command.html @@ -1,7 +1,7 @@ @@ -23,7 +23,6 @@ server: {type: "BACnet-Client", required:true} }, credentials: { - username: {type: "text"}, password: {type: "password"} }, inputs: 1, @@ -60,8 +59,6 @@ let commandTimeSync = $('#commandTimeSync') let commandWhoIsExplicit = $('#commandWhoIsExplicit') - - let enableDisableLookupField = $("#node-lookup-enableDisable") let enableDisableField = $("#node-input-enableDisable") @@ -135,11 +132,11 @@ source: node.lookupItems, minLength: 0, focus: function (event, ui) { - enableDisableField.val(ui.item.value); + enableDisableField.val(parseInt(ui.item.value) || 0); return false; }, select: function (event, ui) { - enableDisableField.val(ui.item.value) + enableDisableField.val(parseInt(ui.item.value) || 0) return false; }, close: function (event, ui) { @@ -163,11 +160,11 @@ source: node.lookupItems, minLength: 0, focus: function (event, ui) { - deviceSateField.val(ui.item.value); + deviceSateField.val(parseInt(ui.item.value) || 0); return false; }, select: function (event, ui) { - deviceSateField.val(ui.item.value) + deviceSateField.val(parseInt(ui.item.value) || 0) return false; }, close: function (event, ui) { diff --git a/src/bacnet-command.js b/src/bacnet-command.js index 0474889..c15d14f 100644 --- a/src/bacnet-command.js +++ b/src/bacnet-command.js @@ -1,7 +1,7 @@ /* The MIT License - Copyright (c) 2017,2018,2019,2020,2021,2022 Klaus Landsdorf (http://node-red.plus/) + Copyright (c) 2017,2018,2019,2020,2021,2022,2023,2024 Klaus Landsdorf (http://plus4nodered.com/) All rights reserved. node-red-contrib-bacnet */ @@ -138,7 +138,11 @@ module.exports = function (RED) { }) } - RED.nodes.registerType('BACnet-Command', BACnetCommand) + RED.nodes.registerType('BACnet-Command', BACnetCommand, { + credentials: { + password: { type: 'password' } + } + }) RED.httpAdmin.get('/bacnet/BacnetEnableDisable', RED.auth.needsPermission('bacnet.CMD.read'), function (req, res) { const typeList = BACnet.enum.EnableDisable diff --git a/src/bacnet-device.html b/src/bacnet-device.html index 8042354..8293eaf 100644 --- a/src/bacnet-device.html +++ b/src/bacnet-device.html @@ -1,7 +1,7 @@ diff --git a/src/bacnet-device.js b/src/bacnet-device.js index f6df5ed..07e86e3 100644 --- a/src/bacnet-device.js +++ b/src/bacnet-device.js @@ -1,7 +1,7 @@ /* The MIT License - Copyright (c) 2017,2018,2019,2020,2021,2022 Klaus Landsdorf (http://node-red.plus/) + Copyright (c) 2017,2018,2019,2020,2021,2022,2023,2024 Klaus Landsdorf (http://plus4nodered.com/) All rights reserved. node-red-contrib-bacnet */ diff --git a/src/bacnet-instance.html b/src/bacnet-instance.html index 6e01e2c..2fde2d1 100644 --- a/src/bacnet-instance.html +++ b/src/bacnet-instance.html @@ -1,7 +1,7 @@ diff --git a/src/bacnet-instance.js b/src/bacnet-instance.js index 1f8bc30..faada16 100644 --- a/src/bacnet-instance.js +++ b/src/bacnet-instance.js @@ -1,7 +1,7 @@ /* The MIT License - Copyright (c) 2017,2018,2019,2020,2021,2022 Klaus Landsdorf (http://node-red.plus/) + Copyright (c) 2017,2018,2019,2020,2021,2022,2023,2024 Klaus Landsdorf (http://plus4nodered.com/) All rights reserved. node-red-contrib-bacnet */ diff --git a/src/bacnet-read.html b/src/bacnet-read.html index e924d0d..13614e1 100644 --- a/src/bacnet-read.html +++ b/src/bacnet-read.html @@ -1,7 +1,7 @@ @@ -62,11 +62,11 @@ source: node.lookupItems, minLength: 0, focus: function (event, ui) { - objectTypeField.val(ui.item.value); + objectTypeField.val(parseInt(ui.item.value) || 0); return false; }, select: function (event, ui) { - objectTypeField.val(ui.item.value) + objectTypeField.val(parseInt(ui.item.value) || 0) return false; }, close: function (event, ui) { @@ -93,11 +93,11 @@ source: node.lookupItems, minLength: 0, focus: function (event, ui) { - datatypeField.val(ui.item.value); + datatypeField.val(parseInt(ui.item.value) || 0); return false; }, select: function (event, ui) { - datatypeField.val(ui.item.value) + datatypeField.val(parseInt(ui.item.value) || 0) return false; }, close: function (event, ui) { @@ -175,10 +175,21 @@

Input

Example of msg.payload.requestArray:

-        const requestArray = [{
-            objectId: {type: 8, instance: 4194303},
-            properties: [{id: 8}]
-        }]
+        {
+            "requestArray": [
+                {
+                    "objectId": {
+                        "type": 8,
+                        "instance": 3457166
+                    },
+                    "properties": [
+                        {
+                            "id": 8
+                        }
+                    ]
+                }
+            ]
+        }
     
diff --git a/src/bacnet-read.js b/src/bacnet-read.js
index a6a9b8b..aa0511a 100644
--- a/src/bacnet-read.js
+++ b/src/bacnet-read.js
@@ -1,7 +1,7 @@
 /*
  The MIT License
 
- Copyright (c) 2017,2018,2019,2020,2021,2022 Klaus Landsdorf (http://node-red.plus/)
+ Copyright (c) 2017,2018,2019,2020,2021,2022,2023,2024 Klaus Landsdorf (http://plus4nodered.com/)
  All rights reserved.
  node-red-contrib-bacnet
  */
diff --git a/src/bacnet-write.html b/src/bacnet-write.html
index f5171f9..125b173 100644
--- a/src/bacnet-write.html
+++ b/src/bacnet-write.html
@@ -1,7 +1,7 @@
 
@@ -63,11 +63,11 @@
             source: node.lookupItems,
             minLength: 0,
             focus: function (event, ui) {
-              objectTypeField.val(ui.item.value);
+              objectTypeField.val(parseInt(ui.item.value) || 0);
               return false;
             },
             select: function (event, ui) {
-              objectTypeField.val(ui.item.value)
+              objectTypeField.val(parseInt(ui.item.value) || 0)
               return false;
             },
             close: function (event, ui) {
@@ -94,11 +94,11 @@
             source: node.lookupItems,
             minLength: 0,
             focus: function (event, ui) {
-              datatypeField.val(ui.item.value);
+              datatypeField.val(parseInt(ui.item.value) || 0);
               return false;
             },
             select: function (event, ui) {
-              datatypeField.val(ui.item.value)
+              datatypeField.val(parseInt(ui.item.value) || 0)
               return false;
             },
             close: function (event, ui) {
@@ -125,11 +125,11 @@
             source: node.lookupItems,
             minLength: 0,
             focus: function (event, ui) {
-              tagTypeField.val(ui.item.value);
+              tagTypeField.val(parseInt(ui.item.value) || 0);
               return false;
             },
             select: function (event, ui) {
-              tagTypeField.val(ui.item.value)
+              tagTypeField.val(parseInt(ui.item.value) || 0)
               return false;
             },
             close: function (event, ui) {
diff --git a/src/bacnet-write.js b/src/bacnet-write.js
index bbe4621..b682fcc 100644
--- a/src/bacnet-write.js
+++ b/src/bacnet-write.js
@@ -1,7 +1,7 @@
 /*
  The MIT License
 
- Copyright (c) 2017,2018,2019,2020,2021,2022 Klaus Landsdorf (http://node-red.plus/)
+ Copyright (c) 2017,2018,2019,2020,2021,2022,2023,2024 Klaus Landsdorf (http://plus4nodered.com/)
  All rights reserved.
  node-red-contrib-bacnet
  */
@@ -112,6 +112,7 @@ module.exports = function (RED) {
           bacnetCore.internalDebugLog('writeProperty default values: ' + JSON.stringify(defaultValues))
           bacnetCore.internalDebugLog('writeProperty msg.payload.values: ' + JSON.stringify(msg.payload.values))
           bacnetCore.internalDebugLog('writeProperty node.propertyId: ' + node.propertyId)
+          bacnetCore.internalDebugLog('writeProperty msg.payload.propertyId: ' + msg.payload.propertyId)
         } catch (e) {
           bacnetCore.internalDebugLog('writeProperty error: ' + e)
         }
@@ -119,7 +120,7 @@ module.exports = function (RED) {
         node.connector.client.writeProperty(
           msg.payload.deviceIPAddress || node.deviceIPAddress,
           msg.payload.objectId || objectId,
-          parseInt(msg.payload.propertyId) || parseInt(node.propertyId),
+          parseInt(msg.payload.propertyId) || parseInt(node.propertyId) || 85,
           msg.payload.values || defaultValues,
           options,
           function (err, value) {
@@ -129,7 +130,7 @@ module.exports = function (RED) {
               node.error(translatedError, msg)
             } else {
               msg.input = msg.payload
-              msg.payload = value
+              msg.payload = value || 'write done'
               node.send(msg)
             }
           })
@@ -146,7 +147,7 @@ module.exports = function (RED) {
 
     let typelistEntry
     for (typelistEntry of invertedTypeList) {
-      resultTypeList.push({ typeValue: typeList[typelistEntry], label: typelistEntry })
+      resultTypeList.push({ typeValue: parseInt(typeList[typelistEntry]) || 0, label: typelistEntry })
     }
 
     res.json(resultTypeList)
@@ -159,7 +160,7 @@ module.exports = function (RED) {
 
     let typelistEntry
     for (typelistEntry of invertedTypeList) {
-      resultTypeList.push({ typeValue: typeList[typelistEntry], label: typelistEntry })
+      resultTypeList.push({ typeValue: parseInt(typeList[typelistEntry]) || 0, label: typelistEntry })
     }
 
     res.json(resultTypeList)
@@ -172,7 +173,7 @@ module.exports = function (RED) {
 
     let typelistEntry
     for (typelistEntry of invertedTypeList) {
-      resultTypeList.push({ typeValue: typeList[typelistEntry], label: typelistEntry })
+      resultTypeList.push({ typeValue: parseInt(typeList[typelistEntry]) || 0, label: typelistEntry })
     }
 
     res.json(resultTypeList)
diff --git a/src/core/bacnet-core.js b/src/core/bacnet-core.js
index 0a73649..0bafab0 100644
--- a/src/core/bacnet-core.js
+++ b/src/core/bacnet-core.js
@@ -1,7 +1,7 @@
 /*
  The MIT License
 
- Copyright (c) 2017,2018,2019,2020,2021,2022 Klaus Landsdorf (http://node-red.plus/)
+ Copyright (c) 2017,2018,2019,2020,2021,2022,2023,2024 Klaus Landsdorf (http://plus4nodered.com/)
  All rights reserved.
  node-red-contrib-bacnet
  */
diff --git a/test/bacnet-command-test.js b/test/bacnet-command-test.js
index 49a9d46..b078bab 100644
--- a/test/bacnet-command-test.js
+++ b/test/bacnet-command-test.js
@@ -2,7 +2,7 @@
  * Original Work Copyright 2014 IBM Corp.
  * node-red
  *
- * Copyright (c) 2017,2018,2019,2020,2021,2022 Klaus Landsdorf (http://node-red.plus/)
+ * Copyright (c) 2017,2018,2019,2020,2021,2022,2023,2024 Klaus Landsdorf (http://plus4nodered.com/)
  * All rights reserved.
  * node-red-contrib-bacnet - The MIT License
  *
diff --git a/test/bacnet-read-test.js b/test/bacnet-read-test.js
index 268cb8c..97ec9ef 100644
--- a/test/bacnet-read-test.js
+++ b/test/bacnet-read-test.js
@@ -2,7 +2,7 @@
  * Original Work Copyright 2014 IBM Corp.
  * node-red
  *
- * Copyright (c) 2017,2018,2019,2020,2021,2022 Klaus Landsdorf (http://node-red.plus/)
+ * Copyright (c) 2017,2018,2019,2020,2021,2022,2023,2024 Klaus Landsdorf (http://plus4nodered.com/)
  * All rights reserved.
  * node-red-contrib-bacnet - The MIT License
  *
diff --git a/test/bacnet-write-test.js b/test/bacnet-write-test.js
index e9db676..1ff6984 100644
--- a/test/bacnet-write-test.js
+++ b/test/bacnet-write-test.js
@@ -2,7 +2,7 @@
  * Original Work Copyright 2014 IBM Corp.
  * node-red
  *
- * Copyright (c) 2017,2018,2019,2020,2021,2022 Klaus Landsdorf (http://node-red.plus/)
+ * Copyright (c) 2017,2018,2019,2020,2021,2022,2023,2024 Klaus Landsdorf (http://plus4nodered.com/)
  * All rights reserved.
  * node-red-contrib-bacnet - The MIT License
  *