@mschaeffler/node-red-bthome 1.6.2 → 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
@@ -88,6 +88,11 @@ module.exports = function(RED) {
88
88
  node.log( mac + e.message );
89
89
  device.key = null;
90
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
+ }
91
96
  }
92
97
 
93
98
  node.on('input', function(msg,send,done) {
@@ -110,6 +115,10 @@ module.exports = function(RED) {
110
115
  done( "msg.payload.data must be an Array!" );
111
116
  return;
112
117
  }
118
+ if( msg.payload.addr )
119
+ {
120
+ msg.payload.addr = msg.payload.addr.toLowerCase();
121
+ }
113
122
 
114
123
  function checkMsg()
115
124
  {
@@ -288,6 +297,12 @@ module.exports = function(RED) {
288
297
  case 0x46:
289
298
  setData( "uv", rawdata.getUInt8() / 10 );
290
299
  break;
300
+ case 0x53:
301
+ setData( "text", rawdata.getBuffer().toString() );
302
+ break;
303
+ case 0x54:
304
+ setData( "raw", rawdata.getBuffer() );
305
+ break;
291
306
  case 0x59:
292
307
  setData( "count", rawdata.getInt8() );
293
308
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mschaeffler/node-red-bthome",
3
- "version": "1.6.2",
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;