homebridge-rtl 0.1.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 +6 -6
- package/src/sensor.js +10 -16
- package/MIGHTY-MULE-DRIVEWAY-ALARM-INSTRUCTIONS.md +0 -62
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-rtl",
|
|
3
|
-
"version": "0.1.
|
|
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": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "git+https://github.com/NorthernMan54/homebridge-rtl"
|
|
15
|
+
"url": "git+https://github.com/NorthernMan54/homebridge-rtl.git"
|
|
16
16
|
},
|
|
17
17
|
"keywords": [
|
|
18
18
|
"homebridge-plugin",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"url": "https://github.com/northernman54/homebridge-rtl/issues"
|
|
30
30
|
},
|
|
31
31
|
"engines": {
|
|
32
|
-
"homebridge": "^1.6.0 || ^2.0.0
|
|
33
|
-
"node": "
|
|
32
|
+
"homebridge": "^1.6.0 || ^2.0.0",
|
|
33
|
+
"node": ">=18"
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://github.com/northernman54/homebridge-rtl#readme",
|
|
36
36
|
"dependencies": {
|
|
@@ -58,10 +58,10 @@
|
|
|
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"
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
}
|
|
67
|
+
}
|
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;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
# How to add MightyMule Wireless Driveway Alarm System - FM231
|
|
2
|
-
|
|
3
|
-
Using slightly modified version of the [MightMule-FM231.conf](https://github.com/merbanan/rtl_433/blob/master/conf/MightyMule-FM231.conf) you can add this driveway alarm as a device and have it show up as a motion sensor. For more info on the fm231 and rtl_433, [see here](https://github.com/merbanan/rtl_433/issues/1407).
|
|
4
|
-
|
|
5
|
-
Note one quirk is that this package was designed for 433 motion senors that constantly communicate and this one does not so eventually it wants to show that sensor has timed out (unresponsive status in homekit) if it hasn't triggered. You can however specify the timeout in homebridge conf so I set it to 7200 minutes so it doesn't use the 2 hour default. Even if sensor shows as "unresponsive" it will still trigger immediately when the driveway alarm transmits so it really does not matter if it shows unresponsive in homekit other than aesthetics.
|
|
6
|
-
|
|
7
|
-
### Add FM231 conf to rtl_433.conf
|
|
8
|
-
Put the below modified MightMule-FM231.conf into `rtl_433.conf` and make sure that file is placed in a location that rtl_433 looks on startup. ie I used `/usr/local/etc/rtl_433/rtl_433.conf`. This will cause rtl_433 to treat it like one of the supported devices and automatically look for its transmissions on startup.
|
|
9
|
-
|
|
10
|
-
#### /usr/local/etc/rtl_433/rtl_433.conf
|
|
11
|
-
```
|
|
12
|
-
# Decoder for the Mighty Mule FM231 Driveway alarm from GTO Inc
|
|
13
|
-
# FCC Test report, including RF waveforms is here:
|
|
14
|
-
# https://fccid.io/I6HGTOFM231/Test-Report/Test-Report-1214140.pdf
|
|
15
|
-
|
|
16
|
-
# Use the Accurite and similar convention for reporting battery.
|
|
17
|
-
# The name is 'battery_ok' with values 1 (ok) and 0. (which are
|
|
18
|
-
# numerically reversed from what the FM231 reports)
|
|
19
|
-
|
|
20
|
-
# The DIP switches for setting a unique device ID are labeled 1-4
|
|
21
|
-
# from left to right, but appear in the # data stream in reverse
|
|
22
|
-
# order.
|
|
23
|
-
|
|
24
|
-
decoder {
|
|
25
|
-
name=MightyMule-FM231,
|
|
26
|
-
modulation=OOK_PWM,
|
|
27
|
-
short=650,
|
|
28
|
-
long=1200,
|
|
29
|
-
sync=3800,
|
|
30
|
-
reset=1100,
|
|
31
|
-
rows=1,
|
|
32
|
-
bits=9,
|
|
33
|
-
get=@4:{1}:battery_ok:[0:1 1:0],
|
|
34
|
-
get=@5:{4}:id,
|
|
35
|
-
get=@0:{1}:motion:[0:true 1:true],
|
|
36
|
-
unique
|
|
37
|
-
}
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
The modification I made to the original mule conf was just to add `get=@0:{1}:motion:[0:true 1:true]`, because that is what homebridge-rtl built in support for motion sensor device expects and it will return `motion: true` on any triggering which is what we want.
|
|
41
|
-
|
|
42
|
-
### Homebridge conf
|
|
43
|
-
Then in homebridge, once homebridge-rtl is installed, add the following platform to your homebridge config file. `id` is the ID that results from you dip switch settings on the driveway alarm. You can get this just by running `rtl_433` if you have already setup `rtl_433.conf` and trigger the alarm. You will see the ID listed.
|
|
44
|
-
|
|
45
|
-
Restart homebridge and now homekit should have a motion sensor that will trigger when a car is detected and automatically turn off after a few min.
|
|
46
|
-
|
|
47
|
-
#### homebridg conf
|
|
48
|
-
```
|
|
49
|
-
{
|
|
50
|
-
"platform": "rtl_433",
|
|
51
|
-
"devices": [
|
|
52
|
-
{
|
|
53
|
-
"id": "8",
|
|
54
|
-
"name": "Car Motion",
|
|
55
|
-
"type": "motion",
|
|
56
|
-
"timeout": 7200
|
|
57
|
-
}
|
|
58
|
-
]
|
|
59
|
-
}
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
|