@ncd-io/node-red-enterprise-sensors 2.0.0 → 2.0.2
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/lib/WirelessGateway.js +128 -1661
- package/lib/sensors/1.js +36 -21
- package/lib/sensors/103.js +38 -23
- package/lib/sensors/110.js +1320 -0
- package/lib/sensors/111.js +1623 -0
- package/lib/sensors/114.js +68 -22
- package/lib/sensors/125.js +40 -28
- package/lib/sensors/126.js +37 -22
- package/lib/sensors/128.js +281 -0
- package/lib/sensors/33.js +581 -0
- package/lib/sensors/554.js +247 -0
- package/lib/sensors/93.js +257 -0
- package/package.json +41 -41
- package/wireless.html +50 -1
- package/wireless.js +182 -86
package/lib/sensors/1.js
CHANGED
|
@@ -151,40 +151,55 @@ module.exports = (globalDevices) => {
|
|
|
151
151
|
};
|
|
152
152
|
|
|
153
153
|
const sync_parse = (rep_buffer) => {
|
|
154
|
-
let response = {
|
|
155
|
-
|
|
154
|
+
let response = {
|
|
155
|
+
'human_readable': {},
|
|
156
|
+
'machine_values': {}
|
|
157
|
+
};
|
|
158
|
+
|
|
156
159
|
// Get the map based on the sensor type byte
|
|
157
160
|
const sync_map = get_config_map(rep_buffer[4]);
|
|
158
161
|
|
|
159
162
|
for (const [key, config] of Object.entries(sync_map)) {
|
|
160
163
|
// Destructure 'type' from inside 'validator' and rename 'read_index' to 'idx'
|
|
161
|
-
const { read_index: idx, length, validator: { type } = {} } = config;
|
|
164
|
+
const { read_index: idx, length, validator: { type } = {}, converter, options } = config;
|
|
162
165
|
|
|
163
166
|
// If for some reason a config doesn't have a validator/type, skip it
|
|
164
167
|
if (!type) continue;
|
|
165
168
|
|
|
166
169
|
switch (type) {
|
|
167
|
-
case 'uint8':
|
|
168
|
-
response[key] = rep_buffer[idx];
|
|
170
|
+
case 'uint8':
|
|
171
|
+
response.machine_values[key] = rep_buffer[idx];
|
|
169
172
|
break;
|
|
170
|
-
case 'uint16be':
|
|
171
|
-
response[key] = rep_buffer.readUInt16BE(idx);
|
|
173
|
+
case 'uint16be':
|
|
174
|
+
response.machine_values[key] = rep_buffer.readUInt16BE(idx);
|
|
172
175
|
break;
|
|
173
|
-
case 'uint32be':
|
|
174
|
-
response[key] = rep_buffer.readUInt32BE(idx);
|
|
176
|
+
case 'uint32be':
|
|
177
|
+
response.machine_values[key] = rep_buffer.readUInt32BE(idx);
|
|
175
178
|
break;
|
|
176
|
-
case 'buffer':
|
|
177
|
-
response[key] = rep_buffer.subarray(idx, idx + length);
|
|
179
|
+
case 'buffer':
|
|
180
|
+
response.machine_values[key] = rep_buffer.subarray(idx, idx + length);
|
|
178
181
|
break;
|
|
179
|
-
case 'hex':
|
|
180
|
-
response[key] = rep_buffer.subarray(idx, idx + length).toString('hex');
|
|
182
|
+
case 'hex':
|
|
183
|
+
response.machine_values[key] = rep_buffer.subarray(idx, idx + length).toString('hex');
|
|
181
184
|
break;
|
|
182
|
-
case 'mac':
|
|
183
|
-
response[key] = rep_buffer.subarray(idx, idx + length).toString('hex');
|
|
185
|
+
case 'mac':
|
|
186
|
+
response.machine_values[key] = rep_buffer.subarray(idx, idx + length).toString('hex');
|
|
184
187
|
break;
|
|
185
188
|
}
|
|
189
|
+
let human_value = response.machine_values[key];
|
|
190
|
+
if(options && options[response.machine_values[key]]){
|
|
191
|
+
human_value = options[response.machine_values[key]];
|
|
192
|
+
}else{
|
|
193
|
+
if(converter && converter.multiplier){
|
|
194
|
+
human_value = human_value * converter.multiplier;
|
|
195
|
+
}
|
|
196
|
+
if(converter && converter.units){
|
|
197
|
+
human_value = human_value + converter.units;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
response.human_readable[key] = human_value;
|
|
186
201
|
}
|
|
187
|
-
if(Object.hasOwn(response, 'destination_address') && response.destination_address.toLowerCase() === '00000000') {
|
|
202
|
+
if (Object.hasOwn(response.machine_values, 'destination_address') && response.machine_values.destination_address.toLowerCase() === '00000000') {
|
|
188
203
|
console.log('##############################');
|
|
189
204
|
console.log('#########Dest Override########');
|
|
190
205
|
console.log('##############################');
|
|
@@ -206,10 +221,10 @@ module.exports = (globalDevices) => {
|
|
|
206
221
|
// that need to be called from outside the scrip
|
|
207
222
|
return {
|
|
208
223
|
type: 1,
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
224
|
+
name: 'Temperature/Humidity',
|
|
225
|
+
parse,
|
|
226
|
+
get_write_buffer_size,
|
|
227
|
+
get_config_map,
|
|
228
|
+
sync_parse
|
|
214
229
|
};
|
|
215
230
|
};
|
package/lib/sensors/103.js
CHANGED
|
@@ -381,40 +381,55 @@ module.exports = (globalDevices) => {
|
|
|
381
381
|
};
|
|
382
382
|
|
|
383
383
|
const sync_parse = (rep_buffer) => {
|
|
384
|
-
let response = {
|
|
385
|
-
|
|
384
|
+
let response = {
|
|
385
|
+
'human_readable': {},
|
|
386
|
+
'machine_values': {}
|
|
387
|
+
};
|
|
388
|
+
|
|
386
389
|
// Get the map based on the sensor type byte
|
|
387
390
|
const sync_map = get_config_map(rep_buffer[4]);
|
|
388
391
|
|
|
389
392
|
for (const [key, config] of Object.entries(sync_map)) {
|
|
390
393
|
// Destructure 'type' from inside 'validator' and rename 'read_index' to 'idx'
|
|
391
|
-
const { read_index: idx, length, validator: { type } = {} } = config;
|
|
394
|
+
const { read_index: idx, length, validator: { type } = {}, converter, options } = config;
|
|
392
395
|
|
|
393
396
|
// If for some reason a config doesn't have a validator/type, skip it
|
|
394
397
|
if (!type) continue;
|
|
395
398
|
|
|
396
399
|
switch (type) {
|
|
397
|
-
case 'uint8':
|
|
398
|
-
response[key] = rep_buffer[idx];
|
|
400
|
+
case 'uint8':
|
|
401
|
+
response.machine_values[key] = rep_buffer[idx];
|
|
399
402
|
break;
|
|
400
|
-
case 'uint16be':
|
|
401
|
-
response[key] = rep_buffer.readUInt16BE(idx);
|
|
403
|
+
case 'uint16be':
|
|
404
|
+
response.machine_values[key] = rep_buffer.readUInt16BE(idx);
|
|
402
405
|
break;
|
|
403
|
-
case 'uint32be':
|
|
404
|
-
response[key] = rep_buffer.readUInt32BE(idx);
|
|
406
|
+
case 'uint32be':
|
|
407
|
+
response.machine_values[key] = rep_buffer.readUInt32BE(idx);
|
|
405
408
|
break;
|
|
406
|
-
case 'buffer':
|
|
407
|
-
response[key] = rep_buffer.subarray(idx, idx + length);
|
|
409
|
+
case 'buffer':
|
|
410
|
+
response.machine_values[key] = rep_buffer.subarray(idx, idx + length);
|
|
408
411
|
break;
|
|
409
|
-
case 'hex':
|
|
410
|
-
response[key] = rep_buffer.subarray(idx, idx + length).toString('hex');
|
|
412
|
+
case 'hex':
|
|
413
|
+
response.machine_values[key] = rep_buffer.subarray(idx, idx + length).toString('hex');
|
|
411
414
|
break;
|
|
412
|
-
case 'mac':
|
|
413
|
-
response[key] = rep_buffer.subarray(idx, idx + length).toString('hex');
|
|
415
|
+
case 'mac':
|
|
416
|
+
response.machine_values[key] = rep_buffer.subarray(idx, idx + length).toString('hex');
|
|
414
417
|
break;
|
|
415
418
|
}
|
|
419
|
+
let human_value = response.machine_values[key];
|
|
420
|
+
if(options && options[response.machine_values[key]]){
|
|
421
|
+
human_value = options[response.machine_values[key]];
|
|
422
|
+
}else{
|
|
423
|
+
if(converter && converter.multiplier){
|
|
424
|
+
human_value = human_value * converter.multiplier;
|
|
425
|
+
}
|
|
426
|
+
if(converter && converter.units){
|
|
427
|
+
human_value = human_value + converter.units;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
response.human_readable[key] = human_value;
|
|
416
431
|
}
|
|
417
|
-
if(Object.hasOwn(response, 'destination_address') && response.destination_address.toLowerCase() === '00000000') {
|
|
432
|
+
if (Object.hasOwn(response.machine_values, 'destination_address') && response.machine_values.destination_address.toLowerCase() === '00000000') {
|
|
418
433
|
console.log('##############################');
|
|
419
434
|
console.log('#########Dest Override########');
|
|
420
435
|
console.log('##############################');
|
|
@@ -1013,12 +1028,12 @@ module.exports = (globalDevices) => {
|
|
|
1013
1028
|
// Export the module with all the necessary functions and properties
|
|
1014
1029
|
// that need to be called from outside the scrip
|
|
1015
1030
|
return {
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1031
|
+
type: 103,
|
|
1032
|
+
name: 'Custom Wireless Accelerometer Sensor',
|
|
1033
|
+
parse,
|
|
1034
|
+
get_write_buffer_size,
|
|
1035
|
+
get_config_map,
|
|
1036
|
+
sync_parse,
|
|
1037
|
+
parse_fly,
|
|
1023
1038
|
};
|
|
1024
1039
|
};
|