@mschaeffler/node-red-bthome 0.4.0 → 0.4.4

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
@@ -130,6 +130,11 @@ Example:
130
130
  }
131
131
  ```
132
132
 
133
+ If content storage is active, statistical data is also stored in a variable with the suffix `-stat`:
134
+ ```
135
+ { ok:0, err:0, old:0, dup:0 }
136
+ ```
137
+
133
138
  ## Example Flow
134
139
 
135
140
  [example flow](https://github.com/m-schaeffler/node-red-my-nodes/raw/main/node-red-bthome/examples/bthome.json)
package/bthome.html CHANGED
@@ -181,17 +181,17 @@
181
181
 
182
182
  <h4>Device-Configuration</h4>
183
183
  <p>With this JSON string the installed <a href="https://bthome.io">BT-Home</a> devices are configured:</p>
184
- <code>{<br>
185
- "<mac address of the device>": { "topic": "<name of the device>", "key": "<encryption key, if device is encrypted>" }<br>
186
- }</code>
184
+ <pre><code>{
185
+ "<mac address of the device>": { "topic": "<name of the device>", "key": "<encryption key, if device is encrypted>" }
186
+ }</code></pre>
187
187
 
188
188
  <p>An example for such a config from the unit tests:</p>
189
- <code>{<br>
190
- "11:22:33:44:55:66": { "topic": "dev_unencrypted_1" },<br>
191
- "00:01:02:03:04:05": { "topic": "dev_unencrypted_2" },<br>
192
- "00:10:20:30:40:50": { "topic": "dev_encrypted_1", "key": "00112233445566778899AABBCCDDEEFF" },<br>
193
- "00:00:00:00:00:00": { "topic": "dev_encrypted_2", "key": [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] }<br>
194
- }</code>
189
+ <pre><code>{
190
+ "11:22:33:44:55:66": { "topic": "dev_unencrypted_1" },
191
+ "00:01:02:03:04:05": { "topic": "dev_unencrypted_2" },
192
+ "00:10:20:30:40:50": { "topic": "dev_encrypted_1", "key": "00112233445566778899AABBCCDDEEFF" },
193
+ "00:00:00:00:00:00": { "topic": "dev_encrypted_2", "key": [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] }
194
+ }</code></pre>
195
195
 
196
196
  <h4>Context storage</h4>
197
197
  <p>All recorded data can be stored in a flow context variable for</p>
@@ -202,16 +202,19 @@
202
202
  </ul>
203
203
 
204
204
  <p>Example:</p>
205
- <code>{<br>
206
- "dev_unencrypted_1":<br>
207
- {<br>
208
- "pid": 164,<br>
209
- "time": 1745395033113,<br>
210
- "encrypted": false,<br>
211
- "battery": 100,<br>
212
- "gw": { "Shelly Gateway": { "time": 1745395033113, "rssi":-85 } },<br>
213
- "data": { "humidity":56, "temperature":-21.3 }<br>
205
+ <pre><code>{<br>
206
+ "dev_unencrypted_1":
207
+ {
208
+ "pid": 164,
209
+ "time": 1745395033113,
210
+ "encrypted": false,
211
+ "battery": 100,
212
+ "gw": { "Shelly Gateway": { "time": 1745395033113, "rssi":-85 } },
213
+ "data": { "humidity":56, "temperature":-21.3 }
214
214
  }
215
- }<code>
215
+ }</code></pre>
216
+
217
+ <p>If content storage is active, statistical data is also stored in a variable with the suffix <code>-stat</code>:</p>
218
+ <pre><code>{ ok:0, err:0, old:0, dup:0 }</code></pre>
216
219
 
217
220
  </script>
package/bthome.js CHANGED
@@ -16,7 +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
+ this.statistics = { ok:0, dup:0, old:0, err:0 };
20
20
  node.status( "" );
21
21
  if( node.contextStore !== "none" )
22
22
  {
@@ -87,8 +87,8 @@ module.exports = function(RED) {
87
87
  if( node.counterTime )
88
88
  {
89
89
  const counterInt = counter[0] | (counter[1]<<8) | (counter[2]<<16) | (counter[3]<<24);
90
- const delta = Math.abs( msgTime - counterInt*1000 );
91
- if( delta > 15000 )
90
+ const delta = msgTime - counterInt*1000;
91
+ if( delta > 30000 || delta < -15000 )
92
92
  {
93
93
  throw new Error( "bthome "+msg.payload.gateway+" "+name+" "+(new Date(counterInt*1000))+" "+delta );
94
94
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mschaeffler/node-red-bthome",
3
- "version": "0.4.0",
3
+ "version": "0.4.4",
4
4
  "description": "A Node Red node to decrypt and decode BT-Home frames",
5
5
  "author": {
6
6
  "name": "Mathias Schäffler",