homebridge-securitysystem 6.2.1 → 6.3.0-beta.0
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/config.schema.json +8 -0
- package/package.json +2 -1
- package/src/index.js +21 -3
- package/src/utils/options.js +1 -0
- package/pull_request_template.md +0 -1
package/config.schema.json
CHANGED
|
@@ -333,6 +333,13 @@
|
|
|
333
333
|
"de-DE"
|
|
334
334
|
]
|
|
335
335
|
},
|
|
336
|
+
"audio_configuration": {
|
|
337
|
+
"title": "Audio Configuration",
|
|
338
|
+
"type": "string",
|
|
339
|
+
"required": false,
|
|
340
|
+
"default": "SDL_AUDIODRIVER=\"alsa\" AUDIODEV=\"hw:0,0\"",
|
|
341
|
+
"placeholder": "SDL_AUDIODRIVER=\"alsa\" AUDIODEV=\"hw:0,0\""
|
|
342
|
+
},
|
|
336
343
|
"audio_path": {
|
|
337
344
|
"title": "Custom Audio Path",
|
|
338
345
|
"description": "Instructions will be created in this path.",
|
|
@@ -653,6 +660,7 @@
|
|
|
653
660
|
"audio_language"
|
|
654
661
|
]
|
|
655
662
|
},
|
|
663
|
+
"audio_configuration",
|
|
656
664
|
{
|
|
657
665
|
"type": "div",
|
|
658
666
|
"displayFlex": true,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-securitysystem",
|
|
3
3
|
"displayName": "Homebridge Security System",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.3.0-beta.0",
|
|
5
5
|
"description": "Homebridge plugin that creates a security system accessory that can be triggered by HomeKit sensors.",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"scripts": {
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"express": "^4.17.1",
|
|
44
|
+
"express-rate-limit": "^6.2.1",
|
|
44
45
|
"node-fetch": "^2.6.0",
|
|
45
46
|
"node-persist": "^3.0.5"
|
|
46
47
|
},
|
package/src/index.js
CHANGED
|
@@ -4,6 +4,7 @@ const storage = require('node-persist');
|
|
|
4
4
|
const { spawn } = require('child_process');
|
|
5
5
|
const fetch = require('node-fetch');
|
|
6
6
|
const express = require('express');
|
|
7
|
+
const rateLimit = require('express-rate-limit');
|
|
7
8
|
|
|
8
9
|
const packageJson = require('../package.json');
|
|
9
10
|
const options = require('./utils/options.js');
|
|
@@ -1095,6 +1096,15 @@ SecuritySystem.prototype.sendResultResponse = function (res, sucess) {
|
|
|
1095
1096
|
};
|
|
1096
1097
|
|
|
1097
1098
|
SecuritySystem.prototype.startServer = async function () {
|
|
1099
|
+
const apiLimiter = rateLimit({
|
|
1100
|
+
windowMs: 1 * 60 * 1000,
|
|
1101
|
+
max: 100,
|
|
1102
|
+
standardHeaders: true,
|
|
1103
|
+
legacyHeaders: false
|
|
1104
|
+
});
|
|
1105
|
+
|
|
1106
|
+
app.use(apiLimiter);
|
|
1107
|
+
|
|
1098
1108
|
app.get('/', (req, res) => {
|
|
1099
1109
|
res.redirect('https://github.com/MiguelRipoll23/homebridge-securitysystem/wiki/Server');
|
|
1100
1110
|
});
|
|
@@ -1294,11 +1304,19 @@ SecuritySystem.prototype.playAudio = async function (type, state) {
|
|
|
1294
1304
|
}
|
|
1295
1305
|
|
|
1296
1306
|
// Process
|
|
1297
|
-
|
|
1298
|
-
|
|
1307
|
+
let command = '';
|
|
1308
|
+
|
|
1309
|
+
if (options.isValueSet(options.audioConfiguration)) {
|
|
1310
|
+
command += `${options.audioConfiguration} `;
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
command += `ffplay ${commandArguments.join(' ')}`;
|
|
1314
|
+
|
|
1315
|
+
this.audioProcess = spawn(command, { shell: true });
|
|
1316
|
+
this.log.debug(command);
|
|
1299
1317
|
|
|
1300
1318
|
this.audioProcess.on('error', data => {
|
|
1301
|
-
// Check if
|
|
1319
|
+
// Check if ffmpeg is installed
|
|
1302
1320
|
if (data !== null && data.toString().indexOf('ENOENT') > -1) {
|
|
1303
1321
|
this.log.error('Unable to play sound, ffmpeg is not installed.');
|
|
1304
1322
|
return;
|
package/src/utils/options.js
CHANGED
|
@@ -70,6 +70,7 @@ const options = {
|
|
|
70
70
|
|
|
71
71
|
// Audio
|
|
72
72
|
options.audio = config.audio;
|
|
73
|
+
options.audioConfiguration = config.audio_configuration;
|
|
73
74
|
options.audioPath = config.audio_path;
|
|
74
75
|
options.audioLanguage = config.audio_language;
|
|
75
76
|
options.audioVolume = config.audio_volume;
|
package/pull_request_template.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Closes #XXX
|