node-red-contrib-boolean-logic-ultimate 1.1.20 → 1.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
 
4
4
  # CHANGELOG
5
5
 
6
+ <p>
7
+ <b>Version 1.1.22</b> November 2024<br/>
8
+ - Kalman Filter node: added filter's reset by issuing meg.reset=true.</br>
9
+ </p>
10
+ <p>
11
+ <b>Version 1.1.21</b> November 2024<br/>
12
+ - Kalman Filter node: rounded the output paylad to three decimals.</br>
13
+ </p>
14
+ <p>
15
+ <b>Version 1.1.20</b> November 2024<br/>
16
+ - NEW: Kalman Filter node.</br>
17
+ </p>
6
18
  <p>
7
19
  <b>Version 1.1.19</b> October 2024<br/>
8
20
  - Maintenance release.</br>
package/README.md CHANGED
@@ -1,18 +1,12 @@
1
1
  ![Logo](img/logo.png)
2
2
 
3
3
  [![NPM version][npm-version-image]][npm-url]
4
-
5
4
  [![NPM downloads per month][npm-downloads-month-image]][npm-url]
6
-
7
5
  [![NPM downloads total][npm-downloads-total-image]][npm-url]
8
-
9
6
  [![MIT License][license-image]][license-url]
10
-
11
7
  [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
12
-
13
- [![Donate via PayPal](https://img.shields.io/badge/Donate-PayPal-blue.svg?style=flat-square)](https://www.paypal.me/techtoday)
14
-
15
- [![youtube][youtube-image]][youtube-url]
8
+ [![Donate via PayPal](https://img.shields.io/badge/Donate-PayPal-blue.svg?style=flat-square)](https://www.paypal.me/techtoday)
9
+ [![youtube][youtube-image]][youtube-url]
16
10
 
17
11
  A set of Node-RED enhanced boolean logic and utility nodes, with persistent values after reboot. Compatible also with Homeassistant values.
18
12
 
@@ -534,6 +528,13 @@ Please refer to [this](https://github.com/wouterbulten/kalmanjs) link, on how it
534
528
 
535
529
  <br/>
536
530
 
531
+ ### Inputs
532
+
533
+ : reset (any) : by passing msg.reset, the Kalman filter will be reset.
534
+ : payload (number) : the payload containing the number. If you've changed the incoming evaluation property in the ***Input*** field, the number to be evaluated must be put in such message's property, instead of the *payload* property.
535
+
536
+ <br/>
537
+
537
538
  [license-image]: https://img.shields.io/badge/license-MIT-blue.svg
538
539
 
539
540
  [license-url]: https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate/master/LICENSE
@@ -75,6 +75,13 @@ Please refer to [this](https://github.com/wouterbulten/kalmanjs) link, on how it
75
75
 
76
76
  <br/>
77
77
 
78
+ ### Inputs
79
+
80
+ : reset (any) : by passing msg.reset, the Kalman filter will be reset.
81
+ : payload (number) : the payload containing the number. If you've changed the incoming evaluation property in the ***Input*** field, the number to be evaluated must be put in such message's property, instead of the *payload* property.
82
+
83
+ <br/>
84
+
78
85
  [Find it useful?](https://www.paypal.me/techtoday)
79
86
 
80
87
  </script>
@@ -4,11 +4,15 @@ module.exports = function (RED) {
4
4
  this.config = config;
5
5
  var node = this;
6
6
  const KalmanFilter = require('kalmanjs');
7
- try {
8
- var kalmanFilter = new KalmanFilter({ R: config.R || 0.01, Q: config.Q || 3 });
9
- } catch (error) {
10
- }
7
+ var kalmanFilter = undefined;
11
8
 
9
+ function initFilter() {
10
+ try {
11
+ kalmanFilter = new KalmanFilter({ R: config.R || 0.01, Q: config.Q || 3 });
12
+ } catch (error) {
13
+ }
14
+ }
15
+ initFilter();
12
16
 
13
17
  function setNodeStatus({ fill, shape, text }) {
14
18
  let dDate = new Date();
@@ -35,6 +39,16 @@ module.exports = function (RED) {
35
39
  config.payloadPropName || "payload"
36
40
  );
37
41
 
42
+ if (msg.reset !== undefined) {
43
+ initFilter();
44
+ setNodeStatus({
45
+ fill: "grey",
46
+ shape: "dot",
47
+ text: "Filter initialized"
48
+ });
49
+ return;
50
+ }
51
+
38
52
  // 15/11/2021 inform user about undefined topic or payload
39
53
  if (sPayload === undefined) {
40
54
  setNodeStatus({
@@ -53,6 +67,7 @@ module.exports = function (RED) {
53
67
  } else {
54
68
  msg.payload = kalmanFilter.filter(sPayload);
55
69
  }
70
+ msg.payload = Math.round((msg.payload + Number.EPSILON) * 1000) / 1000
56
71
  setNodeStatus({
57
72
  fill: "green",
58
73
  shape: "dot",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-boolean-logic-ultimate",
3
- "version": "1.1.20",
3
+ "version": "1.1.22",
4
4
  "description": "A set of Node-RED enhanced boolean logic and utility nodes, flow interruption, blinker, invert, filter, toggle etc.., with persistent values after reboot. Compatible also with Homeassistant values.",
5
5
  "author": "Supergiovane (https://github.com/Supergiovane)",
6
6
  "dependencies": {