homebridge-securitysystem 6.2.0 → 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.
@@ -0,0 +1,16 @@
1
+ name: Analyze package
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - stable
7
+
8
+ pull_request:
9
+
10
+ jobs:
11
+ analyze-package:
12
+ name: Analyze package
13
+ uses: MiguelRipoll23/global/.github/workflows/analyze-package.yml@main
14
+
15
+ with:
16
+ node-version: 16
@@ -2,29 +2,13 @@ name: Build package
2
2
 
3
3
  on:
4
4
  push:
5
- branches:
6
- - 'beta'
7
- - 'hotfix/*'
8
-
9
- pull_request:
10
- branches:
11
- - 'beta'
12
- - 'hotfix/*'
5
+ branches-ignore:
6
+ - stable
13
7
 
14
8
  jobs:
15
9
  build-package:
16
10
  name: Build package
17
- runs-on: ubuntu-latest
18
-
19
- steps:
20
- - name: Checkout repository
21
- uses: actions/checkout@v2
22
-
23
- - name: Setup node
24
- uses: actions/setup-node@v2
25
- with:
26
- node-version: '14'
27
- cache: 'npm'
11
+ uses: MiguelRipoll23/global/.github/workflows/build-package.yml@main
28
12
 
29
- - name: Install package
30
- run: npm ci
13
+ with:
14
+ node-version: 16
@@ -0,0 +1,10 @@
1
+ name: Clean issues
2
+
3
+ on:
4
+ schedule:
5
+ - cron: "0 9 * * *"
6
+
7
+ jobs:
8
+ clean-issues:
9
+ name: Clean issues
10
+ uses: MiguelRipoll23/global/.github/workflows/clean-issues.yml@main
@@ -5,27 +5,12 @@ on:
5
5
  types: [published]
6
6
 
7
7
  jobs:
8
- publish-npm:
8
+ publish-package:
9
9
  name: Publish package
10
- runs-on: ubuntu-latest
10
+ uses: MiguelRipoll23/global/.github/workflows/publish-package.yml@main
11
11
 
12
- steps:
13
- - name: Get version
14
- run: |
15
- echo "NPM_VERSION=${GITHUB_REF##*/v}" >> $GITHUB_ENV
12
+ with:
13
+ node-version: 16
16
14
 
17
- - name: Checkout repository
18
- uses: actions/checkout@v2
19
-
20
- - name: Setup node
21
- uses: actions/setup-node@v2
22
- with:
23
- node-version: "14"
24
- cache: "npm"
25
- registry-url: https://registry.npmjs.org/
26
-
27
- - name: Publish package
28
- env:
29
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
30
- run: |
31
- npm publish --access public --tag "$(if [[ $NPM_VERSION == *-* ]]; then echo beta; else echo latest; fi)"
15
+ secrets:
16
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -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,11 +1,12 @@
1
1
  {
2
2
  "name": "homebridge-securitysystem",
3
3
  "displayName": "Homebridge Security System",
4
- "version": "6.2.0",
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": {
8
- "test": "npm install -g && homebridge -I -D"
8
+ "test": "npm install -g && homebridge -I -D",
9
+ "build": "exit 0"
9
10
  },
10
11
  "keywords": [
11
12
  "homebridge-plugin",
@@ -40,6 +41,7 @@
40
41
  },
41
42
  "dependencies": {
42
43
  "express": "^4.17.1",
44
+ "express-rate-limit": "^6.2.1",
43
45
  "node-fetch": "^2.6.0",
44
46
  "node-persist": "^3.0.5"
45
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
- this.audioProcess = spawn('ffplay', commandArguments);
1298
- this.log.debug(`ffplay ${commandArguments.join(' ')}`);
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 command is missing
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;
@@ -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;
@@ -1,17 +0,0 @@
1
- name: Assign issue
2
-
3
- on:
4
- issues:
5
- types: [opened]
6
-
7
- jobs:
8
- auto-assign:
9
- name: Assign issue
10
- runs-on: ubuntu-latest
11
-
12
- steps:
13
- - name: Assign issue
14
- uses: pozil/auto-assign-issue@v1
15
- with:
16
- repo-token: ${{ secrets.GITHUB_TOKEN }}
17
- assignees: MiguelRipoll23
@@ -1,18 +0,0 @@
1
- name: 'Close stale issues and PRs'
2
- on:
3
- schedule:
4
- - cron: '0 9 * * *'
5
-
6
- jobs:
7
- stale:
8
- name: Check activity
9
- runs-on: ubuntu-latest
10
-
11
- steps:
12
- - name: Check issues/pull requests
13
- uses: actions/stale@v3
14
- with:
15
- days-before-stale: 14
16
- days-before-close: 7
17
- exempt-issue-labels: 'pinned,help wanted,investigating,evaluating'
18
- stale-issue-message: 'This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
@@ -1 +0,0 @@
1
- Closes #XXX