homebridge-rtl 0.0.33 → 0.1.0-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/README.md +31 -0
- package/package.json +36 -11
- package/{sensor.js → src/sensor.js} +48 -41
- package/lib/CustomCharacteristic.js +0 -181
package/README.md
CHANGED
|
@@ -30,6 +30,9 @@ I have tested this on both a Mac and a RPI3
|
|
|
30
30
|
|
|
31
31
|
## Configuration
|
|
32
32
|
* `platform`: "rtl_433"
|
|
33
|
+
* `rtl433Path`: by default this is "/usr/local/bin/"; for windows, the directory rtl433 exe is located. End this with a \.
|
|
34
|
+
* `rtl433Bin`: by default this is "rtl_433"; for windows, this is the exe.
|
|
35
|
+
* `killCommand`: by default this is "pkill"; for windows, this is taskkill /IM, however, the service may not have sufficient privileges to do this. " " for no command.
|
|
33
36
|
* `name`: "Front Porch" - Name of device for display in the Home App
|
|
34
37
|
* `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
38
|
* `type`: Type of sensor device. Supported sensors are `motion`, `temperature`, `humidity`, and `contact`
|
|
@@ -61,6 +64,34 @@ Example configuration:
|
|
|
61
64
|
}]
|
|
62
65
|
```
|
|
63
66
|
|
|
67
|
+
Example windows configuration:
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
"platforms": [{
|
|
71
|
+
"platform": "rtl_433",
|
|
72
|
+
"rtl433Path": "c:\\temp\\",
|
|
73
|
+
"rtp433Bin": "rtl_433_64bit_static.exe",
|
|
74
|
+
"killCommand": " ",
|
|
75
|
+
"devices": [
|
|
76
|
+
{
|
|
77
|
+
"id": "1e3e8",
|
|
78
|
+
"name": "Front Porch",
|
|
79
|
+
"type": "motion"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"id": "92",
|
|
83
|
+
"name": "Outside temperature",
|
|
84
|
+
"type": "temperature"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"id": "834551",
|
|
88
|
+
"name": "Front Door Sensor",
|
|
89
|
+
"type": "contact"
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
}]
|
|
93
|
+
```
|
|
94
|
+
|
|
64
95
|
## Sample log file entries from homebridge to determine sensor ID
|
|
65
96
|
|
|
66
97
|
* Motion sensor log entries
|
package/package.json
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-rtl",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.1.0-beta.1",
|
|
4
4
|
"description": "RTL_433 based sensor for Homebridge",
|
|
5
|
-
"main": "sensor.js",
|
|
5
|
+
"main": "src/sensor.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"
|
|
7
|
+
"lint": "eslint --max-warnings=0 .",
|
|
8
|
+
"lint:fix": "eslint --fix --max-warnings=0 .",
|
|
9
|
+
"watch": "nodemon",
|
|
10
|
+
"test": "jest --detectOpenHandles",
|
|
11
|
+
"test-coverage": "jest --coverage"
|
|
8
12
|
},
|
|
9
13
|
"repository": {
|
|
10
14
|
"type": "git",
|
|
11
|
-
"url": "git://github.com/
|
|
15
|
+
"url": "git+https://github.com/NorthernMan54/homebridge-rtl"
|
|
12
16
|
},
|
|
13
17
|
"keywords": [
|
|
14
18
|
"homebridge-plugin",
|
|
@@ -25,18 +29,39 @@
|
|
|
25
29
|
"url": "https://github.com/northernman54/homebridge-rtl/issues"
|
|
26
30
|
},
|
|
27
31
|
"engines": {
|
|
28
|
-
"
|
|
29
|
-
"
|
|
32
|
+
"homebridge": "^1.6.0 || ^2.0.0-beta.0",
|
|
33
|
+
"node": "^18.20.4 || ^20.15.1 || ^22.0.0"
|
|
30
34
|
},
|
|
31
35
|
"homepage": "https://github.com/northernman54/homebridge-rtl#readme",
|
|
32
36
|
"dependencies": {
|
|
33
|
-
"debug": "^
|
|
34
|
-
"fakegato-history": "^0.5
|
|
37
|
+
"debug": "^4.3.7",
|
|
38
|
+
"fakegato-history": "^0.6.5",
|
|
35
39
|
"lodash": "^4.17.20",
|
|
36
40
|
"mcuiot-logger": "0.0.12",
|
|
37
|
-
"moment": "^2.18.1"
|
|
41
|
+
"moment": "^2.18.1",
|
|
42
|
+
"nodemon": "^3.1.7",
|
|
43
|
+
"semver": "^7.6.3",
|
|
44
|
+
"homebridge-lib": "^6.0.1"
|
|
38
45
|
},
|
|
39
|
-
"
|
|
40
|
-
"
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@eslint/js": "^9.14.0",
|
|
48
|
+
"eslint": "^8.57.1",
|
|
49
|
+
"eslint-plugin-format": "^0.1.2",
|
|
50
|
+
"eslint-plugin-jest": "^28.8.3",
|
|
51
|
+
"globals": "^15.12.0",
|
|
52
|
+
"jest": "^29.7.0",
|
|
53
|
+
"nodemon": "^3.1.7"
|
|
54
|
+
},
|
|
55
|
+
"nodemonConfig": {
|
|
56
|
+
"watch": [
|
|
57
|
+
"src"
|
|
58
|
+
],
|
|
59
|
+
"ext": "js",
|
|
60
|
+
"ignore": [],
|
|
61
|
+
"exec": "~/npm/bin/homebridge -U ./test/hbConfig -T -D -P .",
|
|
62
|
+
"signal": "SIGTERM",
|
|
63
|
+
"env": {
|
|
64
|
+
"NODE_OPTIONS": "--trace-warnings"
|
|
65
|
+
}
|
|
41
66
|
}
|
|
42
67
|
}
|
|
@@ -6,9 +6,10 @@ const moment = require('moment');
|
|
|
6
6
|
var os = require("os");
|
|
7
7
|
var _ = require('lodash');
|
|
8
8
|
var hostname = os.hostname();
|
|
9
|
+
var homebridgeLib = require('homebridge-lib');
|
|
9
10
|
|
|
10
11
|
let Service, Characteristic;
|
|
11
|
-
var
|
|
12
|
+
var CustomCharacteristics;
|
|
12
13
|
var FakeGatoHistoryService;
|
|
13
14
|
|
|
14
15
|
var myAccessories = [];
|
|
@@ -16,7 +17,7 @@ var myAccessories = [];
|
|
|
16
17
|
module.exports = (homebridge) => {
|
|
17
18
|
Service = homebridge.hap.Service;
|
|
18
19
|
Characteristic = homebridge.hap.Characteristic;
|
|
19
|
-
|
|
20
|
+
CustomCharacteristics = new homebridgeLib.EveHomeKitTypes(homebridge).Characteristics;
|
|
20
21
|
FakeGatoHistoryService = require('fakegato-history')(homebridge);
|
|
21
22
|
|
|
22
23
|
homebridge.registerPlatform('homebridge-rtl', 'rtl_433', rtl433Plugin);
|
|
@@ -27,7 +28,10 @@ function rtl433Plugin(log, config, api) {
|
|
|
27
28
|
this.refresh = config['refresh'] || 60; // Update every minute
|
|
28
29
|
this.options = config.options || {};
|
|
29
30
|
this.storage = config['storage'] || "fs";
|
|
30
|
-
|
|
31
|
+
//8/28/2022 JDR added this for Windows.
|
|
32
|
+
this.rtl433Path = config['rtl433Path'] || "/usr/local/bin/";
|
|
33
|
+
this.rtl433Bin = config['rtl433Bin'] || "rtl_433";
|
|
34
|
+
this.killCommand = config['killCommand'] || ("pkill " + this.rtl433Bin);// for linux/mac windows: taskkill /im "rtl_433_64bit_static.exe"
|
|
31
35
|
this.spreadsheetId = config['spreadsheetId'];
|
|
32
36
|
this.devices = config['devices'];
|
|
33
37
|
|
|
@@ -38,7 +42,7 @@ function rtl433Plugin(log, config, api) {
|
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
rtl433Plugin.prototype = {
|
|
41
|
-
accessories: function(callback) {
|
|
45
|
+
accessories: function (callback) {
|
|
42
46
|
for (var i in this.devices) {
|
|
43
47
|
this.log("Adding device", i, this.devices[i].name);
|
|
44
48
|
myAccessories.push(new Rtl433Accessory(this.devices[i], this.log, i));
|
|
@@ -54,16 +58,18 @@ function rtl433Server() {
|
|
|
54
58
|
var childProcess = require('child_process');
|
|
55
59
|
var readline = require('readline');
|
|
56
60
|
var previousMessage;
|
|
57
|
-
this.log("Spawning rtl_433");
|
|
61
|
+
this.log("Spawning rtl_433 " + this.killCommand + '; ' + this.rtl433Path + this.rtl433Bin);
|
|
58
62
|
// if you start rtl_433 outside homebride to get log: rtl_433 -v -F json -C si -M protocol > /tmp/rtl433.json
|
|
59
63
|
//var proc = childProcess.spawn('/usr/bin/truncate -s 0 /tmp/rtl433.json;/usr/bin/tail', ['-F','/tmp/rtl433.json'], {
|
|
60
|
-
|
|
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, ['-d 0', '-F json', '-C si'], {
|
|
61
66
|
shell: true
|
|
62
|
-
|
|
67
|
+
});
|
|
63
68
|
readline.createInterface({
|
|
64
69
|
input: proc.stdout,
|
|
65
70
|
terminal: false
|
|
66
|
-
}).on('line', function(message) {
|
|
71
|
+
}).on('line', function (message) {
|
|
72
|
+
this.log("Message", message.toString());
|
|
67
73
|
debug("Message", message.toString());
|
|
68
74
|
|
|
69
75
|
if (message.toString().startsWith('{')) {
|
|
@@ -96,17 +102,17 @@ function rtl433Server() {
|
|
|
96
102
|
}
|
|
97
103
|
}
|
|
98
104
|
}.bind(this));
|
|
99
|
-
proc.on('close', function(code) {
|
|
105
|
+
proc.on('close', function (code) {
|
|
100
106
|
this.log.error('child close code (spawn)', code);
|
|
101
107
|
setTimeout(rtl433Server.bind(this), 10 * 1000);
|
|
102
108
|
}.bind(this));
|
|
103
|
-
proc.on('disconnect', function(code) {
|
|
109
|
+
proc.on('disconnect', function (code) {
|
|
104
110
|
this.log.error('child disconnect code (spawn)', code);
|
|
105
111
|
}.bind(this));
|
|
106
|
-
proc.on('error', function(code) {
|
|
112
|
+
proc.on('error', function (code) {
|
|
107
113
|
this.log.error('child error code (spawn)', code);
|
|
108
114
|
}.bind(this));
|
|
109
|
-
proc.on('exit', function(code) {
|
|
115
|
+
proc.on('exit', function (code) {
|
|
110
116
|
this.log.error('child exit code (spawn)', code);
|
|
111
117
|
}.bind(this));
|
|
112
118
|
}
|
|
@@ -122,16 +128,17 @@ function Rtl433Accessory(device, log, unit) {
|
|
|
122
128
|
}
|
|
123
129
|
|
|
124
130
|
Rtl433Accessory.prototype = {
|
|
125
|
-
updateStatus: function(data) {
|
|
131
|
+
updateStatus: function (data) {
|
|
126
132
|
try {
|
|
127
133
|
this.log("Updating", this.name);
|
|
128
134
|
this.lastUpdated = Date.now();
|
|
129
135
|
clearTimeout(this.timeout);
|
|
130
136
|
this.timeout = setTimeout(deviceTimeout.bind(this), this.deviceTimeout * 60 * 1000);
|
|
137
|
+
var entry, batteryOk;
|
|
131
138
|
switch (this.type) {
|
|
132
139
|
case "temperature":
|
|
133
140
|
var humidity;
|
|
134
|
-
|
|
141
|
+
entry = {
|
|
135
142
|
time: moment().unix(),
|
|
136
143
|
temp: roundInt(data.temperature_C)
|
|
137
144
|
}
|
|
@@ -156,7 +163,7 @@ Rtl433Accessory.prototype = {
|
|
|
156
163
|
}
|
|
157
164
|
|
|
158
165
|
if (data.battery !== undefined || data.battery_ok != undefined) {
|
|
159
|
-
|
|
166
|
+
batteryOk = data.battery === "OK" || data.battery_ok === 1
|
|
160
167
|
this.sensorService
|
|
161
168
|
.setCharacteristic(Characteristic.StatusLowBattery, batteryOk ? Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL : Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW);
|
|
162
169
|
}
|
|
@@ -172,7 +179,7 @@ Rtl433Accessory.prototype = {
|
|
|
172
179
|
}
|
|
173
180
|
break;
|
|
174
181
|
case "humidity":
|
|
175
|
-
|
|
182
|
+
entry = {
|
|
176
183
|
time: moment().unix(),
|
|
177
184
|
humidity: roundInt(data.humidity)
|
|
178
185
|
}
|
|
@@ -190,7 +197,7 @@ Rtl433Accessory.prototype = {
|
|
|
190
197
|
.setCharacteristic(Characteristic.CurrentRelativeHumidity, roundInt(data.humidity))
|
|
191
198
|
|
|
192
199
|
if (data.battery !== undefined || data.battery_ok != undefined) {
|
|
193
|
-
|
|
200
|
+
batteryOk = data.battery === "OK" || data.battery_ok === 1
|
|
194
201
|
this.sensorService
|
|
195
202
|
.setCharacteristic(Characteristic.StatusLowBattery, batteryOk ? Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL : Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW);
|
|
196
203
|
}
|
|
@@ -207,12 +214,12 @@ Rtl433Accessory.prototype = {
|
|
|
207
214
|
break;
|
|
208
215
|
case "motion":
|
|
209
216
|
// {"time" : "2018-09-30 19:20:26", "model" : "Skylink HA-434TL motion sensor", "motion" : "true", "id" : "1e3e8", "raw" : "be3e8"}
|
|
210
|
-
|
|
217
|
+
// {"time" : "2022-03-17 21:58:46.319049", "protocol" : 68, "model" : "Kerui-Security", "id" : 840811, "cmd" : 10, "motion" : 1, "state" : "motion" }
|
|
211
218
|
// debug("update motion this--->",this);
|
|
212
219
|
|
|
213
|
-
|
|
220
|
+
var value = (data.motion === "true" || data.motion === 1 ? true : false);
|
|
214
221
|
if (this.sensorService.getCharacteristic(Characteristic.MotionDetected).value !== value) {
|
|
215
|
-
this.sensorService.getCharacteristic(
|
|
222
|
+
this.sensorService.getCharacteristic(CustomCharacteristics.LastActivation)
|
|
216
223
|
.updateValue(moment().unix() - this.loggingService.getInitialTime());
|
|
217
224
|
}
|
|
218
225
|
this.sensorService.getCharacteristic(Characteristic.MotionDetected)
|
|
@@ -224,10 +231,10 @@ Rtl433Accessory.prototype = {
|
|
|
224
231
|
|
|
225
232
|
if (value) {
|
|
226
233
|
clearTimeout(this.motionTimeout);
|
|
227
|
-
this.motionTimeout = setTimeout(function() {
|
|
234
|
+
this.motionTimeout = setTimeout(function () {
|
|
228
235
|
var value = false;
|
|
229
236
|
if (this.sensorService.getCharacteristic(Characteristic.MotionDetected).value !== value) {
|
|
230
|
-
this.sensorService.getCharacteristic(
|
|
237
|
+
this.sensorService.getCharacteristic(CustomCharacteristics.LastActivation)
|
|
231
238
|
.updateValue(moment().unix() - this.loggingService.getInitialTime());
|
|
232
239
|
}
|
|
233
240
|
this.sensorService.getCharacteristic(Characteristic.MotionDetected)
|
|
@@ -241,22 +248,22 @@ Rtl433Accessory.prototype = {
|
|
|
241
248
|
|
|
242
249
|
break;
|
|
243
250
|
case "contact":
|
|
244
|
-
|
|
245
|
-
|
|
251
|
+
// {"time" : "2022-03-17 23:04:08.430623", "protocol" : 68, "model" : "Kerui-Security", "id" : 297536, "cmd" : 14, "opened" : 1, "state" : "open" }
|
|
252
|
+
// {"time" : "2022-03-17 23:04:19.447761", "protocol" : 68, "model" : "Kerui-Security", "id" : 297536, "cmd" : 7, "opened" : 0, "state" : "close" }
|
|
246
253
|
// debug("update door this--->",this);
|
|
247
254
|
// console.log("update door this--->",this);
|
|
248
255
|
|
|
249
256
|
this.sensorService
|
|
250
|
-
|
|
257
|
+
.setCharacteristic(Characteristic.ContactSensorState, (data.opened === 1 ? Characteristic.ContactSensorState.CONTACT_NOT_DETECTED : Characteristic.ContactSensorState.CONTACT_DETECTED));
|
|
251
258
|
|
|
252
|
-
|
|
253
|
-
|
|
259
|
+
//this.timeout = setTimeout(deviceTimeout.bind(this), this.deviceTimeout * 60 * 1000);
|
|
260
|
+
clearTimeout(this.timeout);
|
|
254
261
|
|
|
255
262
|
if (data.battery !== undefined || data.battery_ok != undefined) {
|
|
256
263
|
this.sensorService
|
|
257
|
-
|
|
264
|
+
.setCharacteristic(Characteristic.StatusLowBattery, (data.battery === "OK" || data.battery_ok === 1 ? Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL : Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW));
|
|
258
265
|
}
|
|
259
|
-
|
|
266
|
+
break;
|
|
260
267
|
|
|
261
268
|
default:
|
|
262
269
|
this.log.error("No events defined for sensor type %s", this.type);
|
|
@@ -266,7 +273,7 @@ Rtl433Accessory.prototype = {
|
|
|
266
273
|
}
|
|
267
274
|
},
|
|
268
275
|
|
|
269
|
-
getServices: function() {
|
|
276
|
+
getServices: function () {
|
|
270
277
|
this.log("getServices", this.name);
|
|
271
278
|
// Information Service
|
|
272
279
|
var informationService = new Service.AccessoryInformation();
|
|
@@ -274,7 +281,7 @@ Rtl433Accessory.prototype = {
|
|
|
274
281
|
informationService
|
|
275
282
|
.setCharacteristic(Characteristic.Manufacturer, "homebridge-rtl_433")
|
|
276
283
|
.setCharacteristic(Characteristic.SerialNumber, hostname + "-" + this.name)
|
|
277
|
-
.setCharacteristic(Characteristic.FirmwareRevision, require('
|
|
284
|
+
.setCharacteristic(Characteristic.FirmwareRevision, require('../package.json').version);
|
|
278
285
|
// Thermostat Service
|
|
279
286
|
|
|
280
287
|
switch (this.type) {
|
|
@@ -337,7 +344,7 @@ Rtl433Accessory.prototype = {
|
|
|
337
344
|
case "motion":
|
|
338
345
|
this.sensorService = new Service.MotionSensor(this.name);
|
|
339
346
|
|
|
340
|
-
this.sensorService.addCharacteristic(
|
|
347
|
+
this.sensorService.addCharacteristic(CustomCharacteristics.LastActivation);
|
|
341
348
|
|
|
342
349
|
this.timeoutCharacteristic = Characteristic.MotionDetected;
|
|
343
350
|
this.timeout = setTimeout(deviceTimeout.bind(this), this.deviceTimeout * 60 * 1000); // 5 minutes
|
|
@@ -351,17 +358,17 @@ Rtl433Accessory.prototype = {
|
|
|
351
358
|
.setCharacteristic(Characteristic.Model, "Motion Sensor");
|
|
352
359
|
break;
|
|
353
360
|
case "contact":
|
|
354
|
-
|
|
355
|
-
|
|
361
|
+
// debug("get door this--->",this);
|
|
362
|
+
// console.log("get door this--->",this);
|
|
356
363
|
|
|
357
|
-
|
|
358
|
-
|
|
364
|
+
this.sensorService = new Service.ContactSensor(this.name);
|
|
365
|
+
this.sensorService.addCharacteristic(CustomCharacteristics.LastActivation);
|
|
359
366
|
|
|
360
|
-
|
|
361
|
-
|
|
367
|
+
//this.timeoutCharacteristic = Characteristic.ContactSensorState;
|
|
368
|
+
//this.timeout = setTimeout(deviceTimeout.bind(this), this.deviceTimeout * 60 * 1000); // 5 minutes
|
|
362
369
|
|
|
363
|
-
|
|
364
|
-
|
|
370
|
+
this.sensorService.log = this.log;
|
|
371
|
+
informationService
|
|
365
372
|
.setCharacteristic(Characteristic.Model, "Contact Sensor");
|
|
366
373
|
break;
|
|
367
374
|
|
|
@@ -380,7 +387,7 @@ Rtl433Accessory.prototype = {
|
|
|
380
387
|
function deviceTimeout() {
|
|
381
388
|
this.log("Timeout", this.name);
|
|
382
389
|
|
|
383
|
-
if (this.sensorService !== undefined && this.timeoutCharacteristic !== undefined
|
|
390
|
+
if (this.sensorService !== undefined && this.timeoutCharacteristic !== undefined)
|
|
384
391
|
this.sensorService
|
|
385
392
|
.getCharacteristic(this.timeoutCharacteristic).updateValue(new Error("No response"));
|
|
386
393
|
}
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
var inherits = require('util').inherits;
|
|
2
|
-
var Service, Characteristic;
|
|
3
|
-
|
|
4
|
-
module.exports = function(homebridge) {
|
|
5
|
-
Service = homebridge.hap.Service;
|
|
6
|
-
Characteristic = homebridge.hap.Characteristic;
|
|
7
|
-
|
|
8
|
-
var CustomCharacteristic = {};
|
|
9
|
-
|
|
10
|
-
// Motion Sensor
|
|
11
|
-
// Persistence of motion indication in seconds.
|
|
12
|
-
|
|
13
|
-
CustomCharacteristic.Duration = function() {
|
|
14
|
-
Characteristic.call(this, 'Duration', CustomCharacteristic.Duration.UUID);
|
|
15
|
-
this.setProps({
|
|
16
|
-
format: Characteristic.Formats.UINT16,
|
|
17
|
-
unit: "seconds",
|
|
18
|
-
minValue: 5,
|
|
19
|
-
maxValue: 15 * 3600,
|
|
20
|
-
validValues: [
|
|
21
|
-
5, 10, 20, 30,
|
|
22
|
-
1 * 60, 2 * 60, 3 * 60, 5 * 60, 10 * 60, 20 * 60, 30 * 60,
|
|
23
|
-
1 * 3600, 2 * 3600, 3 * 3600, 5 * 3600, 10 * 3600, 12 * 3600, 15 * 3600
|
|
24
|
-
],
|
|
25
|
-
perms: [Characteristic.Perms.READ, Characteristic.Perms.NOTIFY, Characteristic.Perms.WRITE]
|
|
26
|
-
});
|
|
27
|
-
this.value = this.getDefaultValue();
|
|
28
|
-
};
|
|
29
|
-
CustomCharacteristic.Duration.UUID = 'E863F12D-079E-48FF-8F27-9C2605A29F52';
|
|
30
|
-
inherits(CustomCharacteristic.Duration, Characteristic);
|
|
31
|
-
|
|
32
|
-
// Motion Sensor
|
|
33
|
-
// Time of last activation
|
|
34
|
-
|
|
35
|
-
CustomCharacteristic.LastActivation = function() {
|
|
36
|
-
Characteristic.call(this, 'Last Activation', CustomCharacteristic.LastActivation.UUID);
|
|
37
|
-
this.setProps({
|
|
38
|
-
format: Characteristic.Formats.UINT32,
|
|
39
|
-
unit: "seconds",
|
|
40
|
-
perms: [Characteristic.Perms.READ, Characteristic.Perms.NOTIFY]
|
|
41
|
-
});
|
|
42
|
-
this.value = this.getDefaultValue();
|
|
43
|
-
};
|
|
44
|
-
CustomCharacteristic.LastActivation.UUID = 'E863F11A-079E-48FF-8F27-9C2605A29F52';
|
|
45
|
-
inherits(CustomCharacteristic.LastActivation, Characteristic);
|
|
46
|
-
|
|
47
|
-
// Motion Sensor
|
|
48
|
-
// Sensitivity of sensor
|
|
49
|
-
|
|
50
|
-
CustomCharacteristic.Sensitivity = function() {
|
|
51
|
-
Characteristic.call(this, 'Sensitivity', CustomCharacteristic.Sensitivity.UUID);
|
|
52
|
-
this.setProps({
|
|
53
|
-
format: Characteristic.Formats.UINT8,
|
|
54
|
-
unit: "seconds",
|
|
55
|
-
minValue: 0,
|
|
56
|
-
maxValue: 7,
|
|
57
|
-
validValues: [0, 4, 7],
|
|
58
|
-
perms: [Characteristic.Perms.READ, Characteristic.Perms.NOTIFY, Characteristic.Perms.WRITE]
|
|
59
|
-
});
|
|
60
|
-
this.value = this.getDefaultValue();
|
|
61
|
-
};
|
|
62
|
-
CustomCharacteristic.Sensitivity.UUID = 'E863F120-079E-48FF-8F27-9C2605A29F52';
|
|
63
|
-
inherits(CustomCharacteristic.Sensitivity, Characteristic);
|
|
64
|
-
|
|
65
|
-
// Door
|
|
66
|
-
|
|
67
|
-
CustomCharacteristic.ResetTotal = function() {
|
|
68
|
-
Characteristic.call(this, 'Reset Total', CustomCharacteristic.ResetTotal.UUID);
|
|
69
|
-
this.setProps({
|
|
70
|
-
format: Characteristic.Formats.UINT32,
|
|
71
|
-
unit: "seconds",
|
|
72
|
-
perms: [Characteristic.Perms.READ, Characteristic.Perms.NOTIFY, Characteristic.Perms.WRITE]
|
|
73
|
-
});
|
|
74
|
-
this.value = this.getDefaultValue();
|
|
75
|
-
};
|
|
76
|
-
CustomCharacteristic.ResetTotal.UUID = 'E863F112-079E-48FF-8F27-9C2605A29F52';
|
|
77
|
-
inherits(CustomCharacteristic.ResetTotal, Characteristic);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
CustomCharacteristic.OpenDuration = function() {
|
|
81
|
-
Characteristic.call(this, 'Open Duration', CustomCharacteristic.OpenDuration.UUID);
|
|
82
|
-
this.setProps({
|
|
83
|
-
format: Characteristic.Formats.UINT32,
|
|
84
|
-
unit: "seconds",
|
|
85
|
-
perms: [Characteristic.Perms.READ, Characteristic.Perms.NOTIFY, Characteristic.Perms.WRITE]
|
|
86
|
-
});
|
|
87
|
-
this.value = this.getDefaultValue();
|
|
88
|
-
};
|
|
89
|
-
CustomCharacteristic.OpenDuration.UUID = 'E863F118-079E-48FF-8F27-9C2605A29F52';
|
|
90
|
-
inherits(CustomCharacteristic.OpenDuration, Characteristic);
|
|
91
|
-
|
|
92
|
-
CustomCharacteristic.ClosedDuration = function() {
|
|
93
|
-
Characteristic.call(this, 'Closed Duration', CustomCharacteristic.ClosedDuration.UUID);
|
|
94
|
-
this.setProps({
|
|
95
|
-
format: Characteristic.Formats.UINT32,
|
|
96
|
-
unit: "seconds",
|
|
97
|
-
perms: [Characteristic.Perms.READ, Characteristic.Perms.NOTIFY, Characteristic.Perms.WRITE]
|
|
98
|
-
});
|
|
99
|
-
this.value = this.getDefaultValue();
|
|
100
|
-
};
|
|
101
|
-
CustomCharacteristic.ClosedDuration.UUID = 'E863F119-079E-48FF-8F27-9C2605A29F52';
|
|
102
|
-
inherits(CustomCharacteristic.ClosedDuration, Characteristic);
|
|
103
|
-
|
|
104
|
-
CustomCharacteristic.TimesOpened = function() {
|
|
105
|
-
Characteristic.call(this, 'Times Opened', CustomCharacteristic.TimesOpened.UUID);
|
|
106
|
-
this.setProps({
|
|
107
|
-
format: Characteristic.Formats.UINT32,
|
|
108
|
-
perms: [Characteristic.Perms.READ, Characteristic.Perms.NOTIFY]
|
|
109
|
-
});
|
|
110
|
-
this.value = this.getDefaultValue();
|
|
111
|
-
};
|
|
112
|
-
CustomCharacteristic.TimesOpened.UUID = 'E863F129-079E-48FF-8F27-9C2605A29F52';
|
|
113
|
-
inherits(CustomCharacteristic.TimesOpened, Characteristic);
|
|
114
|
-
|
|
115
|
-
CustomCharacteristic.AtmosphericPressureLevel = function() {
|
|
116
|
-
Characteristic.call(this, 'Air Pressure', CustomCharacteristic.AtmosphericPressureLevel.UUID);
|
|
117
|
-
this.setProps({
|
|
118
|
-
format: Characteristic.Formats.UINT16,
|
|
119
|
-
unit: "mbar",
|
|
120
|
-
minValue: 700,
|
|
121
|
-
maxValue: 1200,
|
|
122
|
-
minStep: 1,
|
|
123
|
-
perms: [Characteristic.Perms.READ, Characteristic.Perms.NOTIFY]
|
|
124
|
-
});
|
|
125
|
-
this.value = this.getDefaultValue();
|
|
126
|
-
};
|
|
127
|
-
CustomCharacteristic.AtmosphericPressureLevel.UUID = 'E863F10F-079E-48FF-8F27-9C2605A29F52';
|
|
128
|
-
inherits(CustomCharacteristic.AtmosphericPressureLevel, Characteristic);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
// courtesy of https://github.com/robi-van-kinobi/homebridge-cubesensors
|
|
132
|
-
CustomCharacteristic.AtmosphericPressureSensor = function(displayName, subtype) {
|
|
133
|
-
Service.call(this, displayName, CustomCharacteristic.AtmosphericPressureSensor.UUID, subtype);
|
|
134
|
-
|
|
135
|
-
// Required Characteristics
|
|
136
|
-
this.addCharacteristic(CustomCharacteristic.AtmosphericPressureLevel);
|
|
137
|
-
|
|
138
|
-
// Optional Characteristics
|
|
139
|
-
this.addOptionalCharacteristic(Characteristic.StatusActive);
|
|
140
|
-
this.addOptionalCharacteristic(Characteristic.StatusFault);
|
|
141
|
-
this.addOptionalCharacteristic(Characteristic.StatusLowBattery);
|
|
142
|
-
this.addOptionalCharacteristic(Characteristic.StatusTampered);
|
|
143
|
-
this.addOptionalCharacteristic(Characteristic.Name);
|
|
144
|
-
};
|
|
145
|
-
CustomCharacteristic.AtmosphericPressureSensor.UUID = 'B77831FD-D66A-46A4-B66D-FD7EE8DFE3CE';
|
|
146
|
-
inherits(CustomCharacteristic.AtmosphericPressureSensor, Service);
|
|
147
|
-
|
|
148
|
-
CustomCharacteristic.ValvePosition = function() {
|
|
149
|
-
Characteristic.call(this, 'Valve position', 'E863F12E-079E-48FF-8F27-9C2605A29F52');
|
|
150
|
-
this.setProps({
|
|
151
|
-
format: Characteristic.Formats.UINT8,
|
|
152
|
-
unit: Characteristic.Units.PERCENTAGE,
|
|
153
|
-
perms: [Characteristic.Perms.READ, Characteristic.Perms.NOTIFY]
|
|
154
|
-
});
|
|
155
|
-
this.value = this.getDefaultValue();
|
|
156
|
-
};
|
|
157
|
-
inherits(CustomCharacteristic.ValvePosition, Characteristic);
|
|
158
|
-
|
|
159
|
-
CustomCharacteristic.ProgramCommand = function() {
|
|
160
|
-
Characteristic.call(this, 'Program command', 'E863F12C-079E-48FF-8F27-9C2605A29F52');
|
|
161
|
-
this.setProps({
|
|
162
|
-
format: Characteristic.Formats.DATA,
|
|
163
|
-
perms: [Characteristic.Perms.WRITE, Characteristic.Perms.NOTIFY]
|
|
164
|
-
});
|
|
165
|
-
this.value = this.getDefaultValue();
|
|
166
|
-
};
|
|
167
|
-
inherits(CustomCharacteristic.ProgramCommand, Characteristic);
|
|
168
|
-
|
|
169
|
-
CustomCharacteristic.ProgramData = function() {
|
|
170
|
-
Characteristic.call(this, 'Program data', 'E863F12F-079E-48FF-8F27-9C2605A29F52');
|
|
171
|
-
this.setProps({
|
|
172
|
-
format: Characteristic.Formats.DATA,
|
|
173
|
-
perms: [Characteristic.Perms.READ, Characteristic.Perms.NOTIFY]
|
|
174
|
-
});
|
|
175
|
-
this.value = this.getDefaultValue();
|
|
176
|
-
};
|
|
177
|
-
inherits(CustomCharacteristic.ProgramData, Characteristic);
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
return CustomCharacteristic;
|
|
181
|
-
};
|