homebridge-rtl 0.0.27 → 0.0.30

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.
Files changed (3) hide show
  1. package/README.md +9 -10
  2. package/package.json +1 -1
  3. package/sensor.js +39 -3
package/README.md CHANGED
@@ -50,16 +50,12 @@ Example configuration:
50
50
  }]
51
51
  ```
52
52
 
53
- ## Sample log file entries from homebridge in DEBUG mode to determine sensor ID
54
-
55
- * To start homebridge in DEBUG mode please use this command
56
-
57
- `DEBUG=* homebridge`
53
+ ## Sample log file entries from homebridge to determine sensor ID
58
54
 
59
55
  * Motion sensor log entries
60
56
 
61
57
  ```
62
- Wed, 03 Apr 2019 13:43:05 GMT homebridge-rtl_433 Message {"time" : "2019-04-03 09:43:05", "model" : "Skylink HA-434TL motion sensor", "motion" : "false", "id" : "1e3e8", "raw" : "5e3e8"}
58
+ Message {"time" : "2019-04-03 09:43:05", "model" : "Skylink HA-434TL motion sensor", "motion" : "false", "id" : "1e3e8", "raw" : "5e3e8"}
63
59
 
64
60
  id is 1e3e8
65
61
  ```
@@ -67,21 +63,24 @@ id is 1e3e8
67
63
  * Temperature sensor log entries
68
64
 
69
65
  ```
70
- Thu, 04 Apr 2019 01:07:48 GMT homebridge-rtl_433 Message {"time" : "2018-06-02 08:27:20", "model" : "Acurite 986 Sensor", "id" : 3929, "channel" : "2F", "temperature_F" : -11, "temperature_C" : -23.889, "battery" : "OK", "status" : 0}
66
+ [rtl_433] FYI: Message from unknown device ID 21650
67
+ [rtl_433] Message {"time" : "2021-02-02 10:22:30", "model" : "Acurite 986 Sensor", "id" : 21650, "channel" : "1R", "temperature_C" : 20.556, "battery" : "OK", "status" : 0}
68
+ [rtl_433] FYI: Message from unknown device ID 21650
69
+ [rtl_433] Message {"time" : "2021-02-02 10:22:30", "model" : "Acurite 986 Sensor", "id" : 21650, "channel" : "1R", "temperature_C" : 20.556, "battery" : "OK", "status" : 0}
71
70
 
72
- id is 3929
71
+ id is 21650
73
72
  ```
74
73
 
75
74
  If the device does not transmit an ID value, will default to channel
76
75
 
77
76
  ```
78
- Thu, 04 Apr 2019 01:07:48 GMT homebridge-rtl_433{"time" : "2020-03-14 11:34:22", "model" : "Philips outdoor temperature sensor", "channel" : 1, "temperature_C" : 1.500, "battery" : "LOW"}
77
+ Message {"time" : "2020-03-14 11:34:22", "model" : "Philips outdoor temperature sensor", "channel" : 1, "temperature_C" : 1.500, "battery" : "LOW"}
79
78
 
80
79
  id is the channel 1
81
80
  ```
82
81
 
83
82
  ```
84
- Sat, 14 Mar 2020 18:40:41 GMT homebridge-rtl_433 Message {"time" : "2020-03-14 14:40:41", "model" : "Acurite tower sensor", "id" : 15424, "sensor_id" : 15424, "channel" : "A", "temperature_C" : 3.600, "humidity" : 60, "battery_low" : 0}
83
+ Message {"time" : "2020-03-14 14:40:41", "model" : "Acurite tower sensor", "id" : 15424, "sensor_id" : 15424, "channel" : "A", "temperature_C" : 3.600, "humidity" : 60, "battery_low" : 0}
85
84
 
86
85
  id is 15424
87
86
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homebridge-rtl",
3
- "version": "0.0.27",
3
+ "version": "0.0.30",
4
4
  "description": "RTL_433 based sensor for Homebridge",
5
5
  "main": "sensor.js",
6
6
  "scripts": {
package/sensor.js CHANGED
@@ -55,9 +55,11 @@ function rtl433Server() {
55
55
  var readline = require('readline');
56
56
  var previousMessage;
57
57
  this.log("Spawning rtl_433");
58
+ // if you start rtl_433 outside homebride to get log: rtl_433 -v -F json -C si -M protocol > /tmp/rtl433.json
59
+ //var proc = childProcess.spawn('/usr/bin/truncate -s 0 /tmp/rtl433.json;/usr/bin/tail', ['-F','/tmp/rtl433.json'], {
58
60
  var proc = childProcess.spawn('pkill rtl_433;/usr/local/bin/rtl_433', ['-q', '-F', 'json', '-C', 'si'], {
59
61
  shell: true
60
- });
62
+ });
61
63
  readline.createInterface({
62
64
  input: proc.stdout,
63
65
  terminal: false
@@ -205,8 +207,10 @@ Rtl433Accessory.prototype = {
205
207
  break;
206
208
  case "motion":
207
209
  // {"time" : "2018-09-30 19:20:26", "model" : "Skylink HA-434TL motion sensor", "motion" : "true", "id" : "1e3e8", "raw" : "be3e8"}
208
- // debug("this--->",this);
209
- var value = (data.motion === "true");
210
+ // {"time" : "2022-03-17 21:58:46.319049", "protocol" : 68, "model" : "Kerui-Security", "id" : 840811, "cmd" : 10, "motion" : 1, "state" : "motion" }
211
+ // debug("update motion this--->",this);
212
+
213
+ var value = (data.motion === "true" || data.motion === 1 ? true : false ) ;
210
214
  if (this.sensorService.getCharacteristic(Characteristic.MotionDetected).value !== value) {
211
215
  this.sensorService.getCharacteristic(CustomCharacteristic.LastActivation)
212
216
  .updateValue(moment().unix() - this.loggingService.getInitialTime());
@@ -236,6 +240,21 @@ Rtl433Accessory.prototype = {
236
240
  }
237
241
 
238
242
  break;
243
+ case "contact":
244
+ // {"time" : "2022-03-17 23:04:08.430623", "protocol" : 68, "model" : "Kerui-Security", "id" : 297536, "cmd" : 14, "opened" : 1, "state" : "open" }
245
+ // {"time" : "2022-03-17 23:04:19.447761", "protocol" : 68, "model" : "Kerui-Security", "id" : 297536, "cmd" : 7, "opened" : 0, "state" : "close" }
246
+ // debug("update door this--->",this);
247
+ // console.log("update door this--->",this);
248
+
249
+ this.sensorService
250
+ .setCharacteristic(Characteristic.ContactSensorState, ( data.opened === 1 ? Characteristic.ContactSensorState.CONTACT_NOT_DETECTED : Characteristic.ContactSensorState.CONTACT_DETECTED ));
251
+
252
+ if (data.battery !== undefined || data.battery_ok != undefined) {
253
+ this.sensorService
254
+ .setCharacteristic(Characteristic.StatusLowBattery, (data.battery === "OK" || data.battery_ok === 1 ? Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL : Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW));
255
+ }
256
+ break;
257
+
239
258
  default:
240
259
  this.log.error("No events defined for sensor type %s", this.type);
241
260
  }
@@ -313,6 +332,8 @@ Rtl433Accessory.prototype = {
313
332
  case "motion":
314
333
  this.sensorService = new Service.MotionSensor(this.name);
315
334
 
335
+ this.sensorService.addCharacteristic(CustomCharacteristic.LastActivation);
336
+
316
337
  this.timeoutCharacteristic = Characteristic.MotionDetected;
317
338
  this.timeout = setTimeout(deviceTimeout.bind(this), this.deviceTimeout * 60 * 1000); // 5 minutes
318
339
 
@@ -324,6 +345,21 @@ Rtl433Accessory.prototype = {
324
345
  informationService
325
346
  .setCharacteristic(Characteristic.Model, "Motion Sensor");
326
347
  break;
348
+ case "contact":
349
+ // debug("get door this--->",this);
350
+ // console.log("get door this--->",this);
351
+
352
+ this.sensorService = new Service.ContactSensor(this.name);
353
+ this.sensorService.addCharacteristic(CustomCharacteristic.LastActivation);
354
+
355
+ this.timeoutCharacteristic = Characteristic.ContactSensorState;
356
+ this.timeout = setTimeout(deviceTimeout.bind(this), this.deviceTimeout * 60 * 1000); // 5 minutes
357
+
358
+ this.sensorService.log = this.log;
359
+ informationService
360
+ .setCharacteristic(Characteristic.Model, "Contact Sensor");
361
+ break;
362
+
327
363
  default:
328
364
  this.log.error("No events defined for sensor type %s", this.type);
329
365
  }