@mschaeffler/node-red-bthome 1.6.1 → 1.7.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.
package/README.md CHANGED
@@ -102,7 +102,7 @@ There are two output ports:
102
102
  With this JSON string the installed [BT-Home](https://bthome.io) devices are configured:
103
103
  ```
104
104
  {
105
- "<mac address of the device>": { "topic": "<name of the device>", "key": "<encryption key, if device is encrypted>" }
105
+ "<mac address of the device in lower case>": { "topic": "<name of the device>", "key": "<encryption key, if device is encrypted>" }
106
106
  }
107
107
  ```
108
108
 
package/bthome.html CHANGED
@@ -195,7 +195,7 @@
195
195
  <h4>Device-Configuration</h4>
196
196
  <p>With this JSON string the installed <a href="https://bthome.io">BT-Home</a> devices are configured:</p>
197
197
  <pre><code>{
198
- "<mac address of the device>": { "topic": "<name of the device>", "key": "<encryption key, if device is encrypted>" }
198
+ "<mac address of the device in lower case>": { "topic": "<name of the device>", "key": "<encryption key, if device is encrypted>" }
199
199
  }</code></pre>
200
200
 
201
201
  <p>An example for such a config from the unit tests:</p>
package/bthome.js CHANGED
@@ -4,10 +4,42 @@ const Rawdata = require( "./rawdata.js" );
4
4
  const BtEvent = require( "./btevent.js" );
5
5
 
6
6
  class TypeIds {
7
+ static bluButton = 1;
7
8
  static bluDW = 2;
8
9
  static bluRemote = 9;
9
10
  }
11
+ class DeviceNames {
12
+ static 0x01 = "SBBT-002C";
13
+ static 0x02 = "SBDW-002C";
14
+ static 0x03 = "SBHT-003C";
15
+ static 0x05 = "SBHT-003C";
16
+ static 0x06 = "SBBT-004CEU";
17
+ static 0x07 = "SBBT-004CUS";
18
+ static 0x08 = "SBTR-001AEU";
19
+ static 0x09 = "SBRC-005B";
20
+ static 0x0A = "SBDI-003E";
21
+ static 0x0B = "SBWS-90CM";
22
+ static 0x0C = "SBHT-103C";
23
+ static 0x11 = "SBHT-203C";
24
+ static 0x14 = "SBDW-103C";
25
+ static 0x15 = "SBBT-104CEU"
26
+ static 0x16 = "SBBT-104CUS";
27
+ static 0x17 = "SBBT-102C";
28
+ static 0x201A = "SBCB-01PXNEUB6";
29
+ static 0x201B = "SBCB-01PXNEUB10";
30
+ static 0x201C = "SBCB-01PXNEUB13";
31
+ static 0x201D = "SBCB-01PXNEUB16";
32
+ static 0x201E = "SBCB-01PXNEUB20";
33
+ static 0x201F = "SBCB-01PXNEUB25";
34
+ static 0x203A = "SBCB-01PXNEUC6";
35
+ static 0x203B = "SBCB-01PXNEUC10";
36
+ static 0x203C = "SBCB-01PXNEUC13";
37
+ static 0x203D = "SBCB-01PXNEUC16";
38
+ static 0x203E = "SBCB-01PXNEUC20";
39
+ static 0x203F = "SBCB-01PXNEUC25";
40
+ }
10
41
  Object.freeze( TypeIds );
42
+ Object.freeze( DeviceNames );
11
43
 
12
44
  module.exports = function(RED) {
13
45
 
@@ -56,6 +88,11 @@ module.exports = function(RED) {
56
88
  node.log( mac + e.message );
57
89
  device.key = null;
58
90
  }
91
+ if( mac !== mac.toLowerCase() )
92
+ {
93
+ console.log( `BT addresses must be lower case: ${mac}` );
94
+ node.error( `BT addresses must be lower case: ${mac}` );
95
+ }
59
96
  }
60
97
 
61
98
  node.on('input', function(msg,send,done) {
@@ -78,6 +115,10 @@ module.exports = function(RED) {
78
115
  done( "msg.payload.data must be an Array!" );
79
116
  return;
80
117
  }
118
+ if( msg.payload.addr )
119
+ {
120
+ msg.payload.addr = msg.payload.addr.toLowerCase();
121
+ }
81
122
 
82
123
  function checkMsg()
83
124
  {
@@ -256,6 +297,12 @@ module.exports = function(RED) {
256
297
  case 0x46:
257
298
  setData( "uv", rawdata.getUInt8() / 10 );
258
299
  break;
300
+ case 0x53:
301
+ setData( "text", rawdata.getBuffer().toString() );
302
+ break;
303
+ case 0x54:
304
+ setData( "raw", rawdata.getBuffer() );
305
+ break;
259
306
  case 0x59:
260
307
  setData( "count", rawdata.getInt8() );
261
308
  break;
@@ -269,7 +316,8 @@ module.exports = function(RED) {
269
316
  setData( "channel", rawdata.getUInt8() + 1 );
270
317
  break;
271
318
  case 0xF0:
272
- item.typeId = rawdata.getUInt16() & 0xFF;
319
+ item.typeId = rawdata.getUInt16() & 0xF0FF;
320
+ item.model = DeviceNames[item.typeId] ?? null;
273
321
  break;
274
322
  case 0xF1:
275
323
  item.version = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mschaeffler/node-red-bthome",
3
- "version": "1.6.1",
3
+ "version": "1.7.0",
4
4
  "description": "A Node Red node to decrypt and decode BT-Home frames",
5
5
  "author": {
6
6
  "name": "Mathias Schäffler",
package/rawdata.js CHANGED
@@ -61,6 +61,16 @@ class Rawdata {
61
61
  {
62
62
  return values[this.getUInt8()] ?? "";
63
63
  }
64
+ getBuffer()
65
+ {
66
+ const size = this.getUInt8();
67
+ let buf = Buffer.alloc( size );
68
+ for( let i = 0; i < size; i++ )
69
+ {
70
+ buf[i] = this.getUInt8();
71
+ }
72
+ return buf;
73
+ }
64
74
  }
65
75
 
66
76
  module.exports = Rawdata;