homebridge-securitysystem 6.1.0-beta.0 → 6.2.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,21 @@
1
+ changelog:
2
+ exclude:
3
+ labels:
4
+ - ignore-for-release
5
+
6
+ categories:
7
+ - title: Breaking Changes ⚠️
8
+ labels:
9
+ - breaking-change
10
+
11
+ - title: New Features 🎉
12
+ labels:
13
+ - enhancement
14
+
15
+ - title: Bug Fixes
16
+ labels:
17
+ - bug
18
+
19
+ - title: Other Changes
20
+ labels:
21
+ - "*"
@@ -0,0 +1,5 @@
1
+ {
2
+ "javascript.inlayHints.parameterNames.enabled": "all",
3
+ "editor.bracketPairColorization.enabled": true,
4
+ "editor.guides.bracketPairs": true
5
+ }
@@ -309,6 +309,13 @@
309
309
  "default": true,
310
310
  "required": false
311
311
  },
312
+ "audio_switch": {
313
+ "title": "Show Audio Switch",
314
+ "description": "Adds a global switch to enable or disable audio except for alarm triggered.",
315
+ "type": "boolean",
316
+ "default": false,
317
+ "required": false
318
+ },
312
319
  "audio": {
313
320
  "title": "Play Sounds (local-only, ffmpeg required)",
314
321
  "description": "Warns of pending or current events by playing sounds.",
@@ -603,7 +610,8 @@
603
610
  "arming_lock_switches",
604
611
  "siren_switch",
605
612
  "siren_override_switch",
606
- "siren_mode_switches"
613
+ "siren_mode_switches",
614
+ "audio_switch"
607
615
  ]
608
616
  },
609
617
  {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "homebridge-securitysystem",
3
- "displayName": "Security System",
4
- "version": "6.1.0-beta.0",
3
+ "displayName": "Homebridge Security System",
4
+ "version": "6.2.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": {
@@ -44,6 +44,6 @@
44
44
  "node-persist": "^3.0.5"
45
45
  },
46
46
  "devDependencies": {
47
- "eslint": "^7.26.0"
47
+ "eslint": "^8.0.0"
48
48
  }
49
49
  }
@@ -1,7 +1 @@
1
- **Issue (if exists)**
2
-
3
- *Fixes #XX / None*
4
-
5
- **Changes proposed**
6
-
7
- *Write a description of the changes proposed here and thank you for contributing!*
1
+ Closes #XXX
package/src/index.js CHANGED
@@ -252,6 +252,16 @@ function SecuritySystem(log, config) {
252
252
  .on('get', this.getModePauseSwitch.bind(this))
253
253
  .on('set', this.setModePauseSwitch.bind(this));
254
254
 
255
+ // Audio switch
256
+ this.audioSwitchService = new Service.Switch('Audio', 'kx82r64zN3txDXKFiX9JDi');
257
+
258
+ this.audioSwitchService
259
+ .getCharacteristic(Characteristic.On)
260
+ .on('get', this.getAudioSwitch.bind(this))
261
+ .on('set', this.setAudioSwitch.bind(this))
262
+
263
+ this.audioSwitchService.getCharacteristic(Characteristic.On).value = true;
264
+
255
265
  // Siren sensors
256
266
  this.sirenTrippedMotionSensorService = new Service.MotionSensor('Siren Tripped', 'siren-tripped');
257
267
 
@@ -359,6 +369,10 @@ function SecuritySystem(log, config) {
359
369
  this.services.push(this.modePauseSwitchService);
360
370
  }
361
371
 
372
+ if (options.audio && options.audioSwitch) {
373
+ this.services.push(this.audioSwitchService);
374
+ }
375
+
362
376
  // Storage
363
377
  if (options.saveState) {
364
378
  this.load();
@@ -485,6 +499,7 @@ SecuritySystem.prototype.state2Mode = function (state) {
485
499
 
486
500
  // Custom
487
501
  case 'lock':
502
+ // Audio sound
488
503
  return state;
489
504
 
490
505
  case 'warning':
@@ -679,6 +694,7 @@ SecuritySystem.prototype.handleStateUpdate = function (alarmTriggered) {
679
694
  SecuritySystem.prototype.updateTargetState = function (state, origin, delay, callback) {
680
695
  const isTargetStateAlreadySet = this.targetState === state;
681
696
  const isCurrentStateAlarmTriggered = this.currentState === Characteristic.SecuritySystemCurrentState.ALARM_TRIGGERED;
697
+ const isTargetStateDisarm = state === Characteristic.SecuritySystemTargetState.DISARM;
682
698
 
683
699
  // Check if target state is already set
684
700
  if (isTargetStateAlreadySet && isCurrentStateAlarmTriggered === false) {
@@ -704,7 +720,9 @@ SecuritySystem.prototype.updateTargetState = function (state, origin, delay, cal
704
720
  }
705
721
 
706
722
  // Check arming lock switches
707
- if (this.isArmingLocked(state)) {
723
+ const isArmingLockEnabled = options.isValueSet(options.armingLockSwitch) || options.isValueSet(options.armingLockSwitches);
724
+
725
+ if (isTargetStateDisarm === false && isArmingLockEnabled && this.isArmingLocked(state)) {
708
726
  this.log.warn('Arming lock (Not allowed)');
709
727
 
710
728
  if (callback !== null) {
@@ -722,7 +740,6 @@ SecuritySystem.prototype.updateTargetState = function (state, origin, delay, cal
722
740
  const isTargetStateHome = this.targetState === Characteristic.SecuritySystemTargetState.STAY_ARM;
723
741
  const isTargetStateAway = this.targetState === Characteristic.SecuritySystemTargetState.AWAY_ARM;
724
742
  const isTargetStateNight = this.targetState === Characteristic.SecuritySystemTargetState.NIGHT_ARM;
725
- const isTargetStateDisarm = this.targetState === Characteristic.SecuritySystemTargetState.DISARM;
726
743
 
727
744
  // Update characteristic
728
745
  if (origin === originTypes.INTERNAL || origin === originTypes.EXTERNAL) {
@@ -1211,6 +1228,9 @@ SecuritySystem.prototype.playAudio = async function (type, state) {
1211
1228
 
1212
1229
  const mode = this.state2Mode(state);
1213
1230
 
1231
+ // Close previous player
1232
+ this.stopAudio();
1233
+
1214
1234
  // Ignore 'Current Off' event
1215
1235
  if (mode === 'off') {
1216
1236
  if (type === 'target') {
@@ -1218,8 +1238,13 @@ SecuritySystem.prototype.playAudio = async function (type, state) {
1218
1238
  }
1219
1239
  }
1220
1240
 
1221
- // Close previous player
1222
- this.stopAudio();
1241
+ // Check audio switch except for triggered
1242
+ const audioSwitchOnCharacteristic = this.audioSwitchService.getCharacteristic(Characteristic.On);
1243
+ const isAudioDisabledBySwitch = audioSwitchOnCharacteristic.value === false;
1244
+
1245
+ if (mode !== 'triggered' && isAudioDisabledBySwitch) {
1246
+ return;
1247
+ }
1223
1248
 
1224
1249
  // Directory
1225
1250
  let directory = `${__dirname}/../sounds`;
@@ -1362,7 +1387,7 @@ SecuritySystem.prototype.executeCommand = function (type, state, origin) {
1362
1387
  break;
1363
1388
 
1364
1389
  default:
1365
- this.log.error(`Unknown ${type} state (${state})`);
1390
+ this.log.error(`Unknown command ${type} state (${state})`);
1366
1391
  }
1367
1392
 
1368
1393
  if (command === undefined || command === null) {
@@ -1446,7 +1471,7 @@ SecuritySystem.prototype.sendWebhookEvent = function (type, state, origin) {
1446
1471
  break;
1447
1472
 
1448
1473
  default:
1449
- this.log.error(`Unknown ${type} state (${state})`);
1474
+ this.log.error(`Unknown webhook ${type} state (${state})`);
1450
1475
  return;
1451
1476
  }
1452
1477
 
@@ -1598,6 +1623,7 @@ SecuritySystem.prototype.isArmingLocked = function (state) {
1598
1623
  // Check mode switches
1599
1624
  switch (state) {
1600
1625
  case 'global':
1626
+ // Server status endpoint
1601
1627
  return false;
1602
1628
 
1603
1629
  case Characteristic.SecuritySystemCurrentState.STAY_ARM:
@@ -1613,7 +1639,7 @@ SecuritySystem.prototype.isArmingLocked = function (state) {
1613
1639
  break;
1614
1640
 
1615
1641
  default:
1616
- this.log.error(`Unknown state (${state})`);
1642
+ this.log.debug(`Unknown arming lock state (${state})`);
1617
1643
  }
1618
1644
 
1619
1645
  return armingLockSwitchService.getCharacteristic(Characteristic.On).value;
@@ -1640,7 +1666,7 @@ SecuritySystem.prototype.updateArmingLock = function (mode, value) {
1640
1666
  break;
1641
1667
 
1642
1668
  default:
1643
- this.log.warn(`Unknown arming lock type (${mode})`);
1669
+ this.log.debug(`Unknown arming lock mode (${mode})`);
1644
1670
  return false;
1645
1671
  }
1646
1672
 
@@ -1842,6 +1868,16 @@ SecuritySystem.prototype.setModePauseSwitch = function (value, callback) {
1842
1868
  callback(null);
1843
1869
  };
1844
1870
 
1871
+ SecuritySystem.prototype.getAudioSwitch = function (callback) {
1872
+ const value = this.audioSwitchService.getCharacteristic(Characteristic.On).value;
1873
+ callback(null, value);
1874
+ };
1875
+
1876
+ SecuritySystem.prototype.setAudioSwitch = function (value, callback) {
1877
+ this.log.info(`Audio (${value ? 'Enabled' : 'Disabled'})`);
1878
+ callback(null);
1879
+ };
1880
+
1845
1881
  // Siren Tripped Motion Sensor
1846
1882
  SecuritySystem.prototype.getSirenTrippedMotionDetected = function (callback) {
1847
1883
  const value = this.sirenTrippedMotionSensorService.getCharacteristic(Characteristic.MotionDetected).value;
@@ -62,6 +62,8 @@ const options = {
62
62
  options.awayDoubleKnockSeconds = config.away_double_knock_seconds;
63
63
  options.nightDoubleKnockSeconds = config.night_double_knock_seconds;
64
64
 
65
+ options.audioSwitch = config.audio_switch;
66
+
65
67
  // Server
66
68
  options.serverPort = config.server_port;
67
69
  options.serverCode = config.server_code;
@@ -276,15 +278,13 @@ const options = {
276
278
  },
277
279
 
278
280
  validateValues: (log) => {
279
- if (options.isValueSet(options.resetMinutes) && options.resetMinutes === 0) {
281
+ if (options.resetMinutes === 0) {
280
282
  log.error('Value of setting \'Reset Delay Seconds\' should be at least 1.');
281
283
  options.resetMinutes = 1;
282
284
  }
283
285
 
284
- if (options.serverPort !== null) {
285
- if (options.serverPort < 0 || options.serverPort > 65535) {
286
- log.error('Value of setting \'Server Port\' not between 0 and 65535.');
287
- }
286
+ if (options.serverPort < 0 || options.serverPort > 65535) {
287
+ log.error('Value of setting \'Server Port\' not between 0 and 65535.');
288
288
  }
289
289
  },
290
290