homebridge-rtl 0.1.1-beta.0 → 0.1.1-beta.1
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/package.json +3 -3
- package/src/sensor.js +10 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-rtl",
|
|
3
|
-
"version": "0.1.1-beta.
|
|
3
|
+
"version": "0.1.1-beta.1",
|
|
4
4
|
"description": "RTL_433 based sensor for Homebridge",
|
|
5
5
|
"main": "src/sensor.js",
|
|
6
6
|
"scripts": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"engines": {
|
|
32
32
|
"homebridge": "^1.6.0 || ^2.0.0",
|
|
33
|
-
"node": "
|
|
33
|
+
"node": ">=18"
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://github.com/northernman54/homebridge-rtl#readme",
|
|
36
36
|
"dependencies": {
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
],
|
|
59
59
|
"ext": "js",
|
|
60
60
|
"ignore": [],
|
|
61
|
-
"exec": "~/
|
|
61
|
+
"exec": "NODE_PATH=`pwd`:.. DEBUG=-HAP-NodeJS:*,homebridge-rtl_433* node ~/node_modules/homebridge-config-ui-x/dist/bin/hb-service.js run --stdout -U ./test/hbConfig -T -D -I -P ./",
|
|
62
62
|
"signal": "SIGTERM",
|
|
63
63
|
"env": {
|
|
64
64
|
"NODE_OPTIONS": "--trace-warnings"
|
package/src/sensor.js
CHANGED
|
@@ -45,7 +45,7 @@ rtl433Plugin.prototype = {
|
|
|
45
45
|
accessories: function (callback) {
|
|
46
46
|
for (var i in this.devices) {
|
|
47
47
|
this.log("Adding device", i, this.devices[i].name);
|
|
48
|
-
myAccessories.push(new Rtl433Accessory(this.devices[i], this.log, i));
|
|
48
|
+
myAccessories.push(new Rtl433Accessory(this.devices[i], this.log, i, this.storage, this.refresh));
|
|
49
49
|
}
|
|
50
50
|
callback(myAccessories);
|
|
51
51
|
// console.log("Pre-This", this);
|
|
@@ -62,7 +62,7 @@ function rtl433Server() {
|
|
|
62
62
|
// if you start rtl_433 outside homebride to get log: rtl_433 -v -F json -C si -M protocol > /tmp/rtl433.json
|
|
63
63
|
//var proc = childProcess.spawn('/usr/bin/truncate -s 0 /tmp/rtl433.json;/usr/bin/tail', ['-F','/tmp/rtl433.json'], {
|
|
64
64
|
////8/28/2022 JDR added this for Windows. fixed command line arguments. They weren't working for Windows, but should still work for others.
|
|
65
|
-
var proc = childProcess.spawn(this.killCommand + '; ' + this.rtl433Path + this.rtl433Bin
|
|
65
|
+
var proc = childProcess.spawn(this.killCommand + '; ' + this.rtl433Path + this.rtl433Bin + ' -d 0 -F json -C si', [], {
|
|
66
66
|
shell: true
|
|
67
67
|
});
|
|
68
68
|
readline.createInterface({
|
|
@@ -117,7 +117,7 @@ function rtl433Server() {
|
|
|
117
117
|
}.bind(this));
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
function Rtl433Accessory(device, log, unit) {
|
|
120
|
+
function Rtl433Accessory(device, log, unit, storage, refresh) {
|
|
121
121
|
this.id = device.id;
|
|
122
122
|
this.type = device.type;
|
|
123
123
|
this.log = log;
|
|
@@ -125,6 +125,8 @@ function Rtl433Accessory(device, log, unit) {
|
|
|
125
125
|
this.alarm = device['alarm']
|
|
126
126
|
this.deviceTimeout = device['timeout'] || 120; // Mark as unavailable after 2 hours
|
|
127
127
|
this.humidity = device['humidity'] || false; // Add humidity data to temerature sensor
|
|
128
|
+
this.storage = storage || 'fs';
|
|
129
|
+
this.refresh = refresh || 60;
|
|
128
130
|
}
|
|
129
131
|
|
|
130
132
|
Rtl433Accessory.prototype = {
|
|
@@ -377,9 +379,9 @@ Rtl433Accessory.prototype = {
|
|
|
377
379
|
}
|
|
378
380
|
|
|
379
381
|
if (this.alarm !== undefined) {
|
|
380
|
-
return [informationService, this.sensorService, this.alarmService, this.loggingService];
|
|
382
|
+
return [informationService, this.sensorService, this.alarmService, this.loggingService].filter(Boolean);
|
|
381
383
|
} else {
|
|
382
|
-
return [informationService, this.sensorService, this.loggingService];
|
|
384
|
+
return [informationService, this.sensorService, this.loggingService].filter(Boolean);
|
|
383
385
|
}
|
|
384
386
|
}
|
|
385
387
|
};
|
|
@@ -411,19 +413,11 @@ function getDevices(unit) {
|
|
|
411
413
|
return devices;
|
|
412
414
|
}
|
|
413
415
|
|
|
414
|
-
function seconds(dateTime) {
|
|
415
|
-
// "2018-10-01 20:52:33"
|
|
416
|
-
var hms = dateTime.split(" ");
|
|
417
|
-
// debug("TIME", hms[1]);
|
|
418
|
-
var tt = hms[1].split(":");
|
|
419
|
-
var sec = tt[0] * 3600 + tt[1] * 60 + tt[2] * 1;
|
|
420
|
-
return (sec);
|
|
421
|
-
}
|
|
422
|
-
|
|
423
416
|
function duplicateMessage(last, current) {
|
|
424
417
|
if (last) {
|
|
425
|
-
|
|
426
|
-
|
|
418
|
+
var lastMs = Date.parse(last.time.replace(' ', 'T'));
|
|
419
|
+
var currentMs = Date.parse(current.time.replace(' ', 'T'));
|
|
420
|
+
if (!isNaN(lastMs) && !isNaN(currentMs) && Math.abs(currentMs - lastMs) < 2000) {
|
|
427
421
|
var tCurrent = Object.assign({}, current);
|
|
428
422
|
var tLast = Object.assign({}, last);
|
|
429
423
|
delete tCurrent.time;
|