homebridge-securitysystem 8.1.2 → 8.2.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.
@@ -32,24 +32,25 @@ jobs:
32
32
  - name: Setup node
33
33
  uses: actions/setup-node@v4.0.1
34
34
 
35
- - name: Create tag name
36
- uses: MiguelRipoll23/create-tag-name@v2.1.2
37
- id: create-tag-name
35
+ - name: Get next version
36
+ uses: MiguelRipoll23/get-next-version@v3.0.0
37
+ id: get-next-version
38
38
  with:
39
39
  channel: ${{ inputs.channel }}
40
+ new-build-for-prerelease: ${{ inputs.new-build-for-prerelease }}
40
41
 
41
42
  - name: Update version
42
43
  run: |
43
- npm version --no-git-tag-version ${{ env.TAG_NAME }}
44
+ npm version --no-git-tag-version ${{ env.NEXT_VERSION }}
44
45
  env:
45
- TAG_NAME: ${{ steps.create-tag-name.outputs.tag-name }}
46
+ NEXT_VERSION: ${{ steps.get-next-version.outputs.next-version }}
46
47
 
47
48
  - name: Create pull request
48
49
  uses: peter-evans/create-pull-request@v6
49
50
  with:
50
- branch: version/${{ steps.create-tag-name.outputs.tag-name }}
51
- commit-message: ${{ steps.create-tag-name.outputs.tag-name }}
52
- title: Bump version to ${{ steps.create-tag-name.outputs.tag-name }}
51
+ branch: version/${{ steps.get-next-version.outputs.next-version }}
52
+ commit-message: ${{ steps.get-next-version.outputs.next-version }}
53
+ title: Bump version to ${{ steps.get-next-version.outputs.next-version }}
53
54
  body: Automated pull request triggered by a new release.
54
55
  labels: new-release,ignore-for-release
55
56
  reviewers: MiguelRipoll23
@@ -289,6 +289,13 @@
289
289
  "uniqueItems": true
290
290
  }
291
291
  },
292
+ "arming_sensor": {
293
+ "title": "Show Arming Sensor",
294
+ "description": "Adds a sensor that triggers when the security system is being armed.",
295
+ "type": "boolean",
296
+ "default": false,
297
+ "required": false
298
+ },
292
299
  "tripped_sensor": {
293
300
  "title": "Show Tripped Sensor",
294
301
  "description": "Adds a sensor that triggers multiple times when any of the Trip switches have been turned on.",
@@ -762,6 +769,7 @@
762
769
  "expandable": true,
763
770
  "expanded": false,
764
771
  "items": [
772
+ "arming_sensor",
765
773
  "tripped_sensor",
766
774
  "siren_sensor",
767
775
  {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "homebridge-securitysystem",
3
3
  "displayName": "Homebridge Security System",
4
- "version": "8.1.2",
4
+ "version": "8.2.0-beta.1",
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": {
@@ -46,6 +46,6 @@
46
46
  "node-persist": "^4.0.1"
47
47
  },
48
48
  "devDependencies": {
49
- "eslint": "^8.0.0"
49
+ "eslint": "^9.0.0"
50
50
  }
51
51
  }
package/src/index.js CHANGED
@@ -483,6 +483,8 @@ function SecuritySystem(log, config) {
483
483
  // Services list
484
484
  this.services = [this.service, this.accessoryInformationService];
485
485
 
486
+ this.addArmingMotionSensor();
487
+
486
488
  if (options.trippedMotionSensor) {
487
489
  this.services.push(this.trippedMotionSensorService);
488
490
  }
@@ -649,7 +651,8 @@ SecuritySystem.prototype.load = async function () {
649
651
  Characteristic.SecuritySystemCurrentState,
650
652
  this.currentState
651
653
  );
652
- this.handleStateUpdate(false);
654
+
655
+ this.handleTargetStateChange(false);
653
656
 
654
657
  // Log
655
658
  this.logMode("Current", this.currentState);
@@ -692,6 +695,29 @@ SecuritySystem.prototype.identify = function (callback) {
692
695
  callback(null);
693
696
  };
694
697
 
698
+ // Services
699
+ SecuritySystem.prototype.addArmingMotionSensor = function () {
700
+ if (options.armingMotionSensor === false) {
701
+ return;
702
+ }
703
+
704
+ this.armingMotionSensorService = new Service.MotionSensor(
705
+ "Arming",
706
+ "arming-motion-sensor"
707
+ );
708
+
709
+ this.armingMotionSensorService.addOptionalCharacteristic(
710
+ Characteristic.ConfiguredName
711
+ );
712
+
713
+ this.armingMotionSensorService
714
+ .setCharacteristic(Characteristic.ConfiguredName, "Arming")
715
+ .getCharacteristic(Characteristic.MotionDetected)
716
+ .on("get", this.getArmingMotionDetected.bind(this));
717
+
718
+ this.services.push(this.armingMotionSensorService);
719
+ };
720
+
695
721
  // Security system
696
722
  SecuritySystem.prototype.state2Mode = function (state) {
697
723
  switch (state) {
@@ -778,7 +804,9 @@ SecuritySystem.prototype.setCurrentState = function (state, origin) {
778
804
  Characteristic.SecuritySystemCurrentState,
779
805
  state
780
806
  );
807
+
781
808
  this.logMode("Current", state);
809
+ this.handleCurrentStateChange(false);
782
810
 
783
811
  // Audio
784
812
  this.playAudio("current", state);
@@ -826,7 +854,7 @@ SecuritySystem.prototype.setCurrentState = function (state, origin) {
826
854
  }
827
855
 
828
856
  // Normal flow
829
- this.handleStateUpdate(false);
857
+ this.handleTargetStateChange(false);
830
858
  this.setCurrentState(this.targetState, false);
831
859
  }, options.resetMinutes * 60 * 1000);
832
860
  }
@@ -834,6 +862,11 @@ SecuritySystem.prototype.setCurrentState = function (state, origin) {
834
862
  this.save();
835
863
  };
836
864
 
865
+ SecuritySystem.prototype.handleCurrentStateChange = function (alarmTriggered) {
866
+ // Arming motion sensor
867
+ this.updateArmingMotionDetected(false);
868
+ };
869
+
837
870
  SecuritySystem.prototype.triggerResetSensor = function () {
838
871
  // Update triggered reset motion sensor
839
872
  this.triggeredResetMotionSensorService.updateCharacteristic(
@@ -907,7 +940,7 @@ SecuritySystem.prototype.resetTimers = function () {
907
940
  }
908
941
  };
909
942
 
910
- SecuritySystem.prototype.handleStateUpdate = function (alarmTriggered) {
943
+ SecuritySystem.prototype.handleTargetStateChange = function (alarmTriggered) {
911
944
  // Reset double-knock
912
945
  this.isKnocked = false;
913
946
 
@@ -920,6 +953,7 @@ SecuritySystem.prototype.handleStateUpdate = function (alarmTriggered) {
920
953
  return;
921
954
  }
922
955
 
956
+ // Reset tripped motion sensor
923
957
  const trippedOnCharacteristic = this.tripSwitchService.getCharacteristic(
924
958
  Characteristic.On
925
959
  );
@@ -928,6 +962,7 @@ SecuritySystem.prototype.handleStateUpdate = function (alarmTriggered) {
928
962
  this.updateTripSwitch(false, originTypes.INTERNAL, true, null);
929
963
  }
930
964
 
965
+ // Reset trip switches
931
966
  this.resetTripSwitches();
932
967
  };
933
968
 
@@ -1009,7 +1044,7 @@ SecuritySystem.prototype.updateTargetState = function (
1009
1044
  }
1010
1045
 
1011
1046
  // Reset everything
1012
- this.handleStateUpdate(false);
1047
+ this.handleTargetStateChange(false);
1013
1048
 
1014
1049
  // Commands
1015
1050
  this.executeCommand("target", state, origin);
@@ -1021,6 +1056,9 @@ SecuritySystem.prototype.updateTargetState = function (
1021
1056
  if (state === this.currentState) {
1022
1057
  this.log.warn("Current mode (Already set)");
1023
1058
 
1059
+ // Reset arming motion sensor
1060
+ this.updateArmingMotionDetected(false);
1061
+
1024
1062
  // Play audio
1025
1063
  this.playAudio("current", this.currentState);
1026
1064
 
@@ -1067,6 +1105,9 @@ SecuritySystem.prototype.updateTargetState = function (
1067
1105
  if (armSeconds > 0) {
1068
1106
  this.isArming = true;
1069
1107
 
1108
+ // Trigger arming motion sensor
1109
+ this.updateArmingMotionDetected(true);
1110
+
1070
1111
  // Play sound
1071
1112
  this.playAudio("target", state);
1072
1113
 
@@ -1452,7 +1493,7 @@ SecuritySystem.prototype.startServer = async function () {
1452
1493
  return;
1453
1494
  }
1454
1495
 
1455
- this.handleStateUpdate(true);
1496
+ this.handleTargetStateChange(true);
1456
1497
  this.setCurrentState(
1457
1498
  Characteristic.SecuritySystemCurrentState.ALARM_TRIGGERED,
1458
1499
  true
@@ -2375,6 +2416,22 @@ SecuritySystem.prototype.setAudioSwitch = function (value, callback) {
2375
2416
  callback(null);
2376
2417
  };
2377
2418
 
2419
+ // Tripped Motion Sensor
2420
+ SecuritySystem.prototype.getArmingMotionDetected = function (callback) {
2421
+ const value = this.armingMotionSensorService.getCharacteristic(
2422
+ Characteristic.MotionDetected
2423
+ ).value;
2424
+
2425
+ callback(null, value);
2426
+ };
2427
+
2428
+ SecuritySystem.prototype.updateArmingMotionDetected = function (value) {
2429
+ this.armingMotionSensorService.updateCharacteristic(
2430
+ Characteristic.MotionDetected,
2431
+ value
2432
+ );
2433
+ };
2434
+
2378
2435
  // Tripped Motion Sensor
2379
2436
  SecuritySystem.prototype.getTrippedMotionDetected = function (callback) {
2380
2437
  const value = this.trippedMotionSensorService.getCharacteristic(
@@ -59,6 +59,9 @@ const options = {
59
59
  options.tripOverrideSwitch = config.siren_override_switch;
60
60
  options.tripModeSwitches = config.siren_mode_switches;
61
61
 
62
+ // Arming motion sensor
63
+ options.armingMotionSensor = config.arming_sensor;
64
+
62
65
  // Tripped motion sensor
63
66
  options.trippedMotionSensor = config.tripped_sensor;
64
67
  options.trippedMotionSensorSeconds = config.tripped_sensor_seconds;
@@ -261,18 +264,23 @@ const options = {
261
264
  options.logDirectory = null;
262
265
  }
263
266
 
267
+ // Arming sensor
268
+ if (options.isValueSet(options.armingMotionSensor) === false) {
269
+ options.armingMotionSensor = false;
270
+ }
271
+
264
272
  // Tripped sensor
265
- if (options.isValueSet(options.trippedSensor) === false) {
266
- options.trippedSensor = false;
273
+ if (options.isValueSet(options.trippedMotionSensor) === false) {
274
+ options.trippedMotionSensor = false;
267
275
  }
268
276
 
269
277
  if (options.isValueSet(options.trippedSensorSeconds) === false) {
270
278
  options.trippedSensorSeconds = 5;
271
279
  }
272
280
 
273
- // Tripped sensor
274
- if (options.isValueSet(options.trippedMotionSensor) === false) {
275
- options.trippedMotionSensor = false;
281
+ // Triggered sensor
282
+ if (options.isValueSet(options.triggeredMotionSensor) === false) {
283
+ options.triggeredMotionSensor = false;
276
284
  }
277
285
 
278
286
  if (options.isValueSet(options.triggeredMotionSensorSeconds) === false) {