homebridge-rtl 0.0.29 → 0.0.33

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 +41 -3
  2. package/package.json +1 -1
  3. package/sensor.js +49 -7
package/README.md CHANGED
@@ -14,7 +14,7 @@ Contributor added sensors:
14
14
  * [Mighty Mule Driveway alarm](https://www.amazon.com/Mighty-Mule-Wireless-Driveway-FM231/dp/B003765W0W) see [instructions here](MIGHTY-MULE-DRIVEWAY-ALARM-INSTRUCTIONS.md)
15
15
 
16
16
  ## Features
17
- * Supported sensors include Motion, Temperature and Humidity
17
+ * Supported sensors include Motion, Contact, Temperature and Humidity
18
18
  * Also shows "not responding" if the sensor stops sending data
19
19
  * For temperature and humidity sensors, has ability to create alarms if the current value exceeds a alarm value
20
20
 
@@ -32,7 +32,7 @@ I have tested this on both a Mac and a RPI3
32
32
  * `platform`: "rtl_433"
33
33
  * `name`: "Front Porch" - Name of device for display in the Home App
34
34
  * `id`: id number of device - To find the ID of your device, run homebridge in DEBUG mode, and it will log the message received from all rtl_433 devices. See below for examples
35
- * `type`: Type of sensor device. Supported sensors are `motion`, `temperature`, `humidity`
35
+ * `type`: Type of sensor device. Supported sensors are `motion`, `temperature`, `humidity`, and `contact`
36
36
  * `alarm`: Optional, Create a fake contact sensor called name + Alarm. Value is temperature in Celsius that if exceeded will trigger contact sensor.
37
37
  * `humidity`: Optional, For devices of type `temperature` that emits also humidity set to `true` and humidity will shows in HomeKit/Eve app in the sensor.
38
38
 
@@ -46,7 +46,18 @@ Example configuration:
46
46
  "id": "1e3e8",
47
47
  "name": "Front Porch",
48
48
  "type": "motion"
49
- }]
49
+ },
50
+ {
51
+ "id": "92",
52
+ "name": "Outside temperature",
53
+ "type": "temperature"
54
+ },
55
+ {
56
+ "id": "834551",
57
+ "name": "Front Door Sensor",
58
+ "type": "contact"
59
+ }
60
+ ]
50
61
  }]
51
62
  ```
52
63
 
@@ -58,6 +69,10 @@ Example configuration:
58
69
  Message {"time" : "2019-04-03 09:43:05", "model" : "Skylink HA-434TL motion sensor", "motion" : "false", "id" : "1e3e8", "raw" : "5e3e8"}
59
70
 
60
71
  id is 1e3e8
72
+
73
+ Message {"time" : "2022-03-23 20:11:54.643434", "protocol" : 68, "model" : "Kerui-Security", "id" : 840811, "cmd" : 10, "motion" : 1, "state" : "motion" }
74
+
75
+ id is 840811
61
76
  ```
62
77
 
63
78
  * Temperature sensor log entries
@@ -85,6 +100,29 @@ Message {"time" : "2020-03-14 14:40:41", "model" : "Acurite tower sensor", "id"
85
100
  id is 15424
86
101
  ```
87
102
 
103
+ ```
104
+ Message {"time" : "2022-03-23 21:28:05.748872", "protocol" : 38, "model" : "Generic-Temperature", "id" : 92, "battery_ok" : 1, "temperature_C" : 6.100 }
105
+
106
+ id is 92 the channel 1 for tiny AVIDSEN Weather station
107
+ ```
108
+
109
+ ```
110
+ Message {"time" : "2022-03-29 21:32:16.707696", "protocol" : 19, "model" : "Nexus-TH", "id" : 36, "channel" : 1, "battery_ok" : 1, "temperature_C" : 11.800, "humidity" : 77 }
111
+ Message {"time" : "2022-03-29 21:32:35.938421", "protocol" : 19, "model" : "Nexus-TH", "id" : 31, "channel" : 2, "battery_ok" : 1, "temperature_C" : 12.800, "humidity" : 66 }
112
+ Message {"time" : "2022-03-29 21:32:47.165018", "protocol" : 19, "model" : "Nexus-TH", "id" : 198, "channel" : 3, "battery_ok" : 1, "temperature_C" : 20.900, "humidity" : 45 }
113
+
114
+ id are 36, 31 and 198 (Bresser Temeo Hygro Quadro)
115
+ ```
116
+
117
+ * Contact Sensor log entries (Door or Window Open/Close)
118
+
119
+ ```
120
+ Message {"time" : "2022-03-23 20:12:15.579712", "protocol" : 68, "model" : "Kerui-Security", "id" : 843552, "cmd" : 14, "opened" : 1, "state" : "open" }
121
+ Message {"time" : "2022-03-23 20:12:18.993887", "protocol" : 68, "model" : "Kerui-Security", "id" : 843552, "cmd" : 7, "opened" : 0, "state" : "close" }
122
+
123
+ id is 843552
124
+ ```
125
+
88
126
  ## Credits
89
127
  * merbanan - RTL_433 Sensor decoder
90
128
  * simont77 - History Service
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homebridge-rtl",
3
- "version": "0.0.29",
3
+ "version": "0.0.33",
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,24 @@ 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
+ //this.timeout = setTimeout(deviceTimeout.bind(this), this.deviceTimeout * 60 * 1000);
253
+ clearTimeout(this.timeout);
254
+
255
+ if (data.battery !== undefined || data.battery_ok != undefined) {
256
+ this.sensorService
257
+ .setCharacteristic(Characteristic.StatusLowBattery, (data.battery === "OK" || data.battery_ok === 1 ? Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL : Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW));
258
+ }
259
+ break;
260
+
239
261
  default:
240
262
  this.log.error("No events defined for sensor type %s", this.type);
241
263
  }
@@ -272,7 +294,8 @@ Rtl433Accessory.prototype = {
272
294
  this.sensorService.log = this.log;
273
295
  this.loggingService = new FakeGatoHistoryService("weather", this.sensorService, {
274
296
  storage: this.storage,
275
- minutes: this.refresh * 10 / 60
297
+ minutes: this.refresh * 10 / 60,
298
+ disableRepeatLastData: true
276
299
  });
277
300
  if (this.alarm !== undefined) {
278
301
  this.alarmService = new Service.ContactSensor(this.name + " Alarm");
@@ -299,7 +322,8 @@ Rtl433Accessory.prototype = {
299
322
  this.sensorService.log = this.log;
300
323
  this.loggingService = new FakeGatoHistoryService("weather", this.sensorService, {
301
324
  storage: this.storage,
302
- minutes: this.refresh * 10 / 60
325
+ minutes: this.refresh * 10 / 60,
326
+ disableRepeatLastData: true
303
327
  });
304
328
  if (this.alarm !== undefined) {
305
329
  this.alarmService = new Service.ContactSensor(this.name + " Alarm");
@@ -326,6 +350,21 @@ Rtl433Accessory.prototype = {
326
350
  informationService
327
351
  .setCharacteristic(Characteristic.Model, "Motion Sensor");
328
352
  break;
353
+ case "contact":
354
+ // debug("get door this--->",this);
355
+ // console.log("get door this--->",this);
356
+
357
+ this.sensorService = new Service.ContactSensor(this.name);
358
+ this.sensorService.addCharacteristic(CustomCharacteristic.LastActivation);
359
+
360
+ //this.timeoutCharacteristic = Characteristic.ContactSensorState;
361
+ //this.timeout = setTimeout(deviceTimeout.bind(this), this.deviceTimeout * 60 * 1000); // 5 minutes
362
+
363
+ this.sensorService.log = this.log;
364
+ informationService
365
+ .setCharacteristic(Characteristic.Model, "Contact Sensor");
366
+ break;
367
+
329
368
  default:
330
369
  this.log.error("No events defined for sensor type %s", this.type);
331
370
  }
@@ -340,8 +379,10 @@ Rtl433Accessory.prototype = {
340
379
 
341
380
  function deviceTimeout() {
342
381
  this.log("Timeout", this.name);
343
- this.sensorService
344
- .getCharacteristic(this.timeoutCharacteristic).updateValue(new Error("No response"));
382
+
383
+ if (this.sensorService !== undefined && this.timeoutCharacteristic !== undefined )
384
+ this.sensorService
385
+ .getCharacteristic(this.timeoutCharacteristic).updateValue(new Error("No response"));
345
386
  }
346
387
 
347
388
  function roundInt(string) {
@@ -388,3 +429,4 @@ function duplicateMessage(last, current) {
388
429
  }
389
430
  return false;
390
431
  }
432
+