homebridge-securitysystem 7.0.1 → 7.1.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.
@@ -68,6 +68,42 @@
68
68
  "default": false,
69
69
  "required": false
70
70
  },
71
+ "security_system_name": {
72
+ "title": "Security System Name",
73
+ "type": "string",
74
+ "default": "Security System",
75
+ "required": false
76
+ },
77
+ "trip_switch_name": {
78
+ "title": "Trip Switch Name",
79
+ "type": "string",
80
+ "default": "Trip",
81
+ "required": false
82
+ },
83
+ "trip_home_switch_name": {
84
+ "title": "Trip Home Switch Name",
85
+ "type": "string",
86
+ "default": "Trip Home",
87
+ "required": false
88
+ },
89
+ "trip_away_switch_name": {
90
+ "title": "Trip Away Switch Name",
91
+ "type": "string",
92
+ "default": "Trip Away",
93
+ "required": false
94
+ },
95
+ "trip_night_switch_name": {
96
+ "title": "Trip Night Switch Name",
97
+ "type": "string",
98
+ "default": "Trip Night",
99
+ "required": false
100
+ },
101
+ "trip_override_switch_name": {
102
+ "title": "Trip Override Switch Name",
103
+ "type": "string",
104
+ "default": "Trip Override",
105
+ "required": false
106
+ },
71
107
  "log_directory": {
72
108
  "title": "Log Directory Path",
73
109
  "type": "string",
@@ -516,6 +552,21 @@
516
552
  },
517
553
  "save_state",
518
554
  "test_mode",
555
+ {
556
+ "type": "fieldset",
557
+ "title": "Accessory Names",
558
+ "description": "Change the accessory names provided by your own.",
559
+ "expandable": true,
560
+ "expanded": false,
561
+ "items": [
562
+ "security_system_name",
563
+ "trip_switch_name",
564
+ "trip_home_switch_name",
565
+ "trip_away_switch_name",
566
+ "trip_night_switch_name",
567
+ "trip_override_switch_name"
568
+ ]
569
+ },
519
570
  {
520
571
  "type": "fieldset",
521
572
  "title": "Advanced Options",
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "homebridge-securitysystem",
3
3
  "displayName": "Homebridge Security System",
4
- "version": "7.0.1",
4
+ "version": "7.1.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
- "debug": "npm install -g && homebridge -I -D",
8
+ "debug": "homebridge -I -D",
9
9
  "test": "exit 0",
10
10
  "build": "exit 0"
11
11
  },
package/src/index.js CHANGED
@@ -135,14 +135,20 @@ function SecuritySystem(log, config) {
135
135
  }
136
136
 
137
137
  // Security system
138
- this.service = new Service.SecuritySystem(options.name);
138
+ this.service = new Service.SecuritySystem(options.securitySystemName);
139
139
  this.availableTargetStates = this.getAvailableTargetStates();
140
140
 
141
141
  this.service.getCharacteristic(
142
142
  Characteristic.SecuritySystemTargetState
143
143
  ).value = this.targetState;
144
144
 
145
+ this.service.addCharacteristic(Characteristic.ConfiguredName);
146
+
145
147
  this.service
148
+ .setCharacteristic(
149
+ Characteristic.ConfiguredName,
150
+ options.securitySystemName
151
+ )
146
152
  .getCharacteristic(Characteristic.SecuritySystemTargetState)
147
153
  .setProps({ validValues: this.availableTargetStates })
148
154
  .on("get", this.getTargetState.bind(this))
@@ -157,58 +163,85 @@ function SecuritySystem(log, config) {
157
163
  .on("get", this.getCurrentState.bind(this));
158
164
 
159
165
  // Trip switches
160
- this.tripSwitchService = new Service.Switch("Trip", "siren-switch");
166
+ this.tripSwitchService = new Service.Switch(
167
+ options.tripSwitchName,
168
+ "siren-switch"
169
+ );
170
+
161
171
  this.tripSwitchService.addCharacteristic(Characteristic.ConfiguredName);
162
172
 
163
173
  this.tripSwitchService
164
- .setCharacteristic(Characteristic.ConfiguredName, "Trip")
174
+ .setCharacteristic(Characteristic.ConfiguredName, options.tripSwitchName)
165
175
  .getCharacteristic(Characteristic.On)
166
176
  .on("get", this.getTripSwitch.bind(this))
167
177
  .on("set", this.setTripSwitch.bind(this));
168
178
 
169
- this.tripOverrideSwitchService = new Service.Switch(
170
- "Trip Override",
171
- "BdW9ce0mUYatqiRqEjT4iA"
179
+ this.tripHomeSwitchService = new Service.Switch(
180
+ options.tripHomeSwitchName,
181
+ "siren-home"
172
182
  );
173
183
 
174
- this.tripOverrideSwitchService.addCharacteristic(
175
- Characteristic.ConfiguredName
176
- );
177
-
178
- this.tripOverrideSwitchService
179
- .setCharacteristic(Characteristic.ConfiguredName, "Trip Override")
180
- .getCharacteristic(Characteristic.On)
181
- .on("get", this.getTripOverrideSwitch.bind(this))
182
- .on("set", this.setTripOverrideSwitch.bind(this));
183
-
184
- this.tripHomeSwitchService = new Service.Switch("Trip Home", "siren-home");
185
184
  this.tripHomeSwitchService.addCharacteristic(Characteristic.ConfiguredName);
186
185
 
187
186
  this.tripHomeSwitchService
188
- .setCharacteristic(Characteristic.ConfiguredName, "Trip Home")
187
+ .setCharacteristic(
188
+ Characteristic.ConfiguredName,
189
+ options.tripHomeSwitchName
190
+ )
189
191
  .getCharacteristic(Characteristic.On)
190
192
  .on("get", this.getTripHomeSwitch.bind(this))
191
193
  .on("set", this.setTripHomeSwitch.bind(this));
192
194
 
193
- this.tripAwaySwitchService = new Service.Switch("Trip Away", "siren-away");
195
+ this.tripAwaySwitchService = new Service.Switch(
196
+ options.tripAwaySwitchName,
197
+ "siren-away"
198
+ );
199
+
194
200
  this.tripAwaySwitchService.addCharacteristic(Characteristic.ConfiguredName);
195
201
 
196
202
  this.tripAwaySwitchService
197
- .setCharacteristic(Characteristic.ConfiguredName, "Trip Away")
203
+ .setCharacteristic(
204
+ Characteristic.ConfiguredName,
205
+ options.tripAwaySwitchName
206
+ )
198
207
  .getCharacteristic(Characteristic.On)
199
208
  .on("get", this.getTripAwaySwitch.bind(this))
200
209
  .on("set", this.setTripAwaySwitch.bind(this));
201
210
 
202
- this.tripNightSwitchService = new Service.Switch("Trip Night", "siren-night");
211
+ this.tripNightSwitchService = new Service.Switch(
212
+ options.tripNightSwitchName,
213
+ "siren-night"
214
+ );
203
215
 
204
216
  this.tripNightSwitchService.addCharacteristic(Characteristic.ConfiguredName);
205
217
 
206
218
  this.tripNightSwitchService
207
- .setCharacteristic(Characteristic.ConfiguredName, "Trip Night")
219
+ .setCharacteristic(
220
+ Characteristic.ConfiguredName,
221
+ options.tripNightSwitchName
222
+ )
208
223
  .getCharacteristic(Characteristic.On)
209
224
  .on("get", this.getTripNightSwitch.bind(this))
210
225
  .on("set", this.setTripNightSwitch.bind(this));
211
226
 
227
+ this.tripOverrideSwitchService = new Service.Switch(
228
+ options.tripOverrideSwitchName,
229
+ "BdW9ce0mUYatqiRqEjT4iA"
230
+ );
231
+
232
+ this.tripOverrideSwitchService.addCharacteristic(
233
+ Characteristic.ConfiguredName
234
+ );
235
+
236
+ this.tripOverrideSwitchService
237
+ .setCharacteristic(
238
+ Characteristic.ConfiguredName,
239
+ options.tripOverrideSwitchName
240
+ )
241
+ .getCharacteristic(Characteristic.On)
242
+ .on("get", this.getTripOverrideSwitch.bind(this))
243
+ .on("set", this.setTripOverrideSwitch.bind(this));
244
+
212
245
  // Arming lock switches
213
246
  this.armingLockSwitchService = new Service.Switch(
214
247
  "Arming Lock",
@@ -1132,7 +1165,7 @@ SecuritySystem.prototype.updateTripSwitch = function (
1132
1165
  if (value) {
1133
1166
  // Already triggered
1134
1167
  if (isCurrentStateAlarmTriggered) {
1135
- this.log.warn("Trip Switch (Already triggered)");
1168
+ this.log.warn("Security System (Already triggered)");
1136
1169
 
1137
1170
  if (callback !== null) {
1138
1171
  callback(HK_NOT_ALLOWED_IN_CURRENT_STATE, false);
@@ -1143,7 +1176,7 @@ SecuritySystem.prototype.updateTripSwitch = function (
1143
1176
 
1144
1177
  // Already about to trigger
1145
1178
  if (this.triggerTimeout !== null) {
1146
- this.log.warn("Trip Switch (Already on)");
1179
+ this.log.warn("Security System (Already tripped)");
1147
1180
 
1148
1181
  if (callback !== null) {
1149
1182
  callback(HK_NOT_ALLOWED_IN_CURRENT_STATE, false);
@@ -1152,7 +1185,7 @@ SecuritySystem.prototype.updateTripSwitch = function (
1152
1185
  return false;
1153
1186
  }
1154
1187
 
1155
- this.log.info("Trip Switch (On)");
1188
+ this.log.info("Security System (Tripped)");
1156
1189
 
1157
1190
  // Update tripped motion sensor
1158
1191
  if (options.trippedMotionSensor) {
@@ -1221,7 +1254,7 @@ SecuritySystem.prototype.updateTripSwitch = function (
1221
1254
  this.sendWebhookEvent("current", "warning", origin);
1222
1255
  } else {
1223
1256
  // Off
1224
- this.log.info("Trip Switch (Off)");
1257
+ this.log.info("Security System (Cancelled)");
1225
1258
  this.stopAudio();
1226
1259
 
1227
1260
  if (isCurrentStateAlarmTriggered) {
@@ -1255,10 +1288,6 @@ SecuritySystem.prototype.updateTripSwitch = function (
1255
1288
  return true;
1256
1289
  };
1257
1290
 
1258
- SecuritySystem.prototype.setTrip = function (value, callback) {
1259
- this.updateTripSwitch(value, originTypes.REGULAR_SWITCH, false, callback);
1260
- };
1261
-
1262
1291
  // Server
1263
1292
  SecuritySystem.prototype.isAuthenticated = function (req, res) {
1264
1293
  // Check if authentication is disabled
@@ -1805,52 +1834,68 @@ SecuritySystem.prototype.getTripSwitch = function (callback) {
1805
1834
  };
1806
1835
 
1807
1836
  SecuritySystem.prototype.setTripSwitch = function (value, callback) {
1837
+ this.log.info(`Trip Switch (${value ? "On" : "Off"})`);
1808
1838
  this.updateTripSwitch(value, originTypes.REGULAR_SWITCH, false, callback);
1809
1839
  };
1810
1840
 
1811
- SecuritySystem.prototype.getTripOverrideSwitch = function (callback) {
1812
- const value = this.tripOverrideSwitchService.getCharacteristic(
1841
+ SecuritySystem.prototype.getTripHomeSwitch = function (callback) {
1842
+ const value = this.tripHomeSwitchService.getCharacteristic(
1813
1843
  Characteristic.On
1814
1844
  ).value;
1815
1845
  callback(null, value);
1816
1846
  };
1817
1847
 
1818
- SecuritySystem.prototype.setTripOverrideSwitch = function (value, callback) {
1819
- this.updateTripSwitch(value, originTypes.SPECIAL_SWITCH, false, callback);
1848
+ SecuritySystem.prototype.setTripHomeSwitch = function (value, callback) {
1849
+ this.log.info(`Trip Home Switch (${value ? "On" : "Off"})`);
1850
+ this.triggerIfModeSet(
1851
+ Characteristic.SecuritySystemCurrentState.STAY_ARM,
1852
+ value,
1853
+ callback
1854
+ );
1820
1855
  };
1821
1856
 
1822
- SecuritySystem.prototype.resetTripSwitches = function () {
1823
- const tripHomeOnCharacteristic = this.tripHomeSwitchService.getCharacteristic(
1824
- Characteristic.On
1825
- );
1826
- const tripAwayOnCharacteristic = this.tripAwaySwitchService.getCharacteristic(
1857
+ SecuritySystem.prototype.getTripAwaySwitch = function (callback) {
1858
+ const value = this.tripAwaySwitchService.getCharacteristic(
1827
1859
  Characteristic.On
1828
- );
1829
- const tripNightOnCharacteristic =
1830
- this.tripNightSwitchService.getCharacteristic(Characteristic.On);
1860
+ ).value;
1861
+ callback(null, value);
1862
+ };
1831
1863
 
1832
- const tripOverrideOnCharacteristic =
1833
- this.tripOverrideSwitchService.getCharacteristic(Characteristic.On);
1864
+ SecuritySystem.prototype.setTripAwaySwitch = function (value, callback) {
1865
+ this.log.info(`Trip Away Switch (${value ? "On" : "Off"})`);
1866
+ this.triggerIfModeSet(
1867
+ Characteristic.SecuritySystemCurrentState.AWAY_ARM,
1868
+ value,
1869
+ callback
1870
+ );
1871
+ };
1834
1872
 
1835
- if (tripHomeOnCharacteristic.value) {
1836
- tripHomeOnCharacteristic.updateValue(false);
1837
- this.log.debug("Trip Home Switch (Off)");
1838
- }
1873
+ SecuritySystem.prototype.getTripNightSwitch = function (callback) {
1874
+ const value = this.tripNightSwitchService.getCharacteristic(
1875
+ Characteristic.On
1876
+ ).value;
1877
+ callback(null, value);
1878
+ };
1839
1879
 
1840
- if (tripAwayOnCharacteristic.value) {
1841
- tripAwayOnCharacteristic.updateValue(false);
1842
- this.log.debug("Trip Away Switch (Off)");
1843
- }
1880
+ SecuritySystem.prototype.setTripNightSwitch = function (value, callback) {
1881
+ this.log.info(`Trip Night Switch (${value ? "On" : "Off"})`);
1882
+ this.triggerIfModeSet(
1883
+ Characteristic.SecuritySystemCurrentState.NIGHT_ARM,
1884
+ value,
1885
+ callback
1886
+ );
1887
+ };
1844
1888
 
1845
- if (tripNightOnCharacteristic.value) {
1846
- tripNightOnCharacteristic.updateValue(false);
1847
- this.log.debug("Trip Night Switch (Off)");
1848
- }
1889
+ SecuritySystem.prototype.getTripOverrideSwitch = function (callback) {
1890
+ const value = this.tripOverrideSwitchService.getCharacteristic(
1891
+ Characteristic.On
1892
+ ).value;
1893
+ callback(null, value);
1894
+ };
1849
1895
 
1850
- if (tripOverrideOnCharacteristic.value) {
1851
- tripOverrideOnCharacteristic.updateValue(false);
1852
- this.log.debug("Trip Override Switch (Off)");
1853
- }
1896
+ SecuritySystem.prototype.setTripOverrideSwitch = function (value, callback) {
1897
+ this.log.info(`Trip Override Switch (${value ? "On" : "Off"})`);
1898
+ this.updateTripSwitch(value, originTypes.SPECIAL_SWITCH, false, callback);
1854
1899
  };
1855
1900
 
1856
1901
  SecuritySystem.prototype.triggerIfModeSet = function (
@@ -1869,7 +1914,7 @@ SecuritySystem.prototype.triggerIfModeSet = function (
1869
1914
  ) {
1870
1915
  this.updateTripSwitch(value, originTypes.REGULAR_SWITCH, false, callback);
1871
1916
  } else {
1872
- this.log.debug("Trip (Mode not set)");
1917
+ this.log.debug("Security System (Trip mode not set)");
1873
1918
  callback(HK_NOT_ALLOWED_IN_CURRENT_STATE, false);
1874
1919
  }
1875
1920
  } else {
@@ -1877,52 +1922,38 @@ SecuritySystem.prototype.triggerIfModeSet = function (
1877
1922
  }
1878
1923
  };
1879
1924
 
1880
- SecuritySystem.prototype.getTripHomeSwitch = function (callback) {
1881
- const value = this.tripHomeSwitchService.getCharacteristic(
1925
+ SecuritySystem.prototype.resetTripSwitches = function () {
1926
+ const tripHomeOnCharacteristic = this.tripHomeSwitchService.getCharacteristic(
1882
1927
  Characteristic.On
1883
- ).value;
1884
- callback(null, value);
1885
- };
1886
-
1887
- SecuritySystem.prototype.setTripHomeSwitch = function (value, callback) {
1888
- this.log.debug("Trip Home Switch (On)");
1889
- this.triggerIfModeSet(
1890
- Characteristic.SecuritySystemCurrentState.STAY_ARM,
1891
- value,
1892
- callback
1893
1928
  );
1894
- };
1895
-
1896
- SecuritySystem.prototype.getTripAwaySwitch = function (callback) {
1897
- const value = this.tripAwaySwitchService.getCharacteristic(
1929
+ const tripAwayOnCharacteristic = this.tripAwaySwitchService.getCharacteristic(
1898
1930
  Characteristic.On
1899
- ).value;
1900
- callback(null, value);
1901
- };
1902
-
1903
- SecuritySystem.prototype.setTripAwaySwitch = function (value, callback) {
1904
- this.log.debug("Trip Away Switch (On)");
1905
- this.triggerIfModeSet(
1906
- Characteristic.SecuritySystemCurrentState.AWAY_ARM,
1907
- value,
1908
- callback
1909
1931
  );
1910
- };
1932
+ const tripNightOnCharacteristic =
1933
+ this.tripNightSwitchService.getCharacteristic(Characteristic.On);
1911
1934
 
1912
- SecuritySystem.prototype.getTripNightSwitch = function (callback) {
1913
- const value = this.tripNightSwitchService.getCharacteristic(
1914
- Characteristic.On
1915
- ).value;
1916
- callback(null, value);
1917
- };
1935
+ const tripOverrideOnCharacteristic =
1936
+ this.tripOverrideSwitchService.getCharacteristic(Characteristic.On);
1918
1937
 
1919
- SecuritySystem.prototype.setTripNightSwitch = function (value, callback) {
1920
- this.log.debug("Trip Night Switch (On)");
1921
- this.triggerIfModeSet(
1922
- Characteristic.SecuritySystemCurrentState.NIGHT_ARM,
1923
- value,
1924
- callback
1925
- );
1938
+ if (tripHomeOnCharacteristic.value) {
1939
+ tripHomeOnCharacteristic.updateValue(false);
1940
+ this.log.debug("Trip Home Switch (Off)");
1941
+ }
1942
+
1943
+ if (tripAwayOnCharacteristic.value) {
1944
+ tripAwayOnCharacteristic.updateValue(false);
1945
+ this.log.debug("Trip Away Switch (Off)");
1946
+ }
1947
+
1948
+ if (tripNightOnCharacteristic.value) {
1949
+ tripNightOnCharacteristic.updateValue(false);
1950
+ this.log.debug("Trip Night Switch (Off)");
1951
+ }
1952
+
1953
+ if (tripOverrideOnCharacteristic.value) {
1954
+ tripOverrideOnCharacteristic.updateValue(false);
1955
+ this.log.debug("Trip Override Switch (Off)");
1956
+ }
1926
1957
  };
1927
1958
 
1928
1959
  // Arming lock switches
@@ -12,8 +12,16 @@ const options = {
12
12
  options.saveState = config.save_state;
13
13
  options.proxyMode = config.proxy_mode;
14
14
  options.testMode = config.test_mode;
15
- options.logDirectory = config.log_directory;
16
15
 
16
+ // Names
17
+ options.securitySystemName = config.security_system_name;
18
+ options.tripSwitchName = config.trip_switch_name;
19
+ options.tripHomeSwitchName = config.trip_home_switch_name;
20
+ options.tripAwaySwitchName = config.trip_away_switch_name;
21
+ options.tripNightSwitchName = config.trip_night_switch_name;
22
+ options.tripOverrideSwitchName = config.trip_override_switch_name;
23
+
24
+ options.logDirectory = config.log_directory;
17
25
  options.overrideOff = config.override_off;
18
26
  options.resetOffFlow = config.reset_off_flow;
19
27
  options.disabledModes = config.disabled_modes;
@@ -161,6 +169,30 @@ const options = {
161
169
  options.resetMinutes = 10;
162
170
  }
163
171
 
172
+ if (options.isValueSet(options.securitySystemName) === false) {
173
+ options.securitySystemName = "Security System";
174
+ }
175
+
176
+ if (options.isValueSet(options.tripSwitchName) === false) {
177
+ options.tripSwitchName = "Trip";
178
+ }
179
+
180
+ if (options.isValueSet(options.tripHomeSwitchName) === false) {
181
+ options.tripHomeSwitchName = "Trip Home";
182
+ }
183
+
184
+ if (options.isValueSet(options.tripAwaySwitchName) === false) {
185
+ options.tripAwaySwitchName = "Trip Away";
186
+ }
187
+
188
+ if (options.isValueSet(options.tripNightSwitchName) === false) {
189
+ options.tripNightSwitchName = "Trip Night";
190
+ }
191
+
192
+ if (options.isValueSet(options.tripOverrideSwitchName) === false) {
193
+ options.tripOverrideSwitchName = "Trip Override";
194
+ }
195
+
164
196
  if (options.isValueSet(options.overrideOff) === false) {
165
197
  options.overrideOff = false;
166
198
  }