@mschaeffler/node-red-bthome 0.3.1 → 0.4.0

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.
Files changed (2) hide show
  1. package/bthome.js +15 -1
  2. package/package.json +1 -1
package/bthome.js CHANGED
@@ -16,6 +16,7 @@ module.exports = function(RED) {
16
16
  this.contextVar = config.contextVar ?? "bthome";
17
17
  this.contextStore = config.contextStore ?? "none";
18
18
  this.data = {};
19
+ this.statistics = { ok:0, err:0, old:0, dup:0 };
19
20
  node.status( "" );
20
21
  if( node.contextStore !== "none" )
21
22
  {
@@ -34,6 +35,7 @@ module.exports = function(RED) {
34
35
  }
35
36
  }
36
37
  } );
38
+ node.flowcontext.set( node.contextVar+"-stat", node.statistics );
37
39
  }
38
40
  for( const mac in node.devices )
39
41
  {
@@ -52,6 +54,7 @@ module.exports = function(RED) {
52
54
  node.on('input', function(msg,send,done) {
53
55
  if( ! Array.isArray( msg.payload.data ) )
54
56
  {
57
+ node.statistics.err++;
55
58
  done( "msg.payload.data must be an Array!" );
56
59
  return;
57
60
  }
@@ -172,6 +175,7 @@ module.exports = function(RED) {
172
175
  if( pid < item.pid && pid > 10 /*&& pid > item.pid - 10*/ )
173
176
  {
174
177
  // veraltete Nachricht und nicht reboot
178
+ node.statistics.old++;
175
179
  node.warn( `old ble message ${name} from ${msg.payload.gateway} dropped, ${pid} < ${item.pid}` );
176
180
  return false;
177
181
  }
@@ -182,7 +186,16 @@ module.exports = function(RED) {
182
186
  rssi: msg.payload.rssi ?? null
183
187
  };
184
188
  }
185
- return pid !== null && pid !== item.pid;
189
+ if( pid !== null && pid !== item.pid )
190
+ {
191
+ node.statistics.ok++;
192
+ return true;
193
+ }
194
+ else
195
+ {
196
+ node.statistics.dup++;
197
+ return false;
198
+ }
186
199
  }
187
200
 
188
201
  function newMessage()
@@ -232,6 +245,7 @@ module.exports = function(RED) {
232
245
  }
233
246
  catch( e )
234
247
  {
248
+ node.statistics.err++;
235
249
  done( e.message );
236
250
  }
237
251
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mschaeffler/node-red-bthome",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "A Node Red node to decrypt and decode BT-Home frames",
5
5
  "author": {
6
6
  "name": "Mathias Schäffler",