homebridge-securitysystem 7.0.0 → 7.1.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.
@@ -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.0",
4
+ "version": "7.1.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": {
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,57 +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
203
+ .setCharacteristic(
204
+ Characteristic.ConfiguredName,
205
+ options.tripAwaySwitchName
206
+ )
197
207
  .getCharacteristic(Characteristic.On)
198
208
  .on("get", this.getTripAwaySwitch.bind(this))
199
209
  .on("set", this.setTripAwaySwitch.bind(this));
200
210
 
201
- this.tripNightSwitchService = new Service.Switch("Trip Night", "siren-night");
211
+ this.tripNightSwitchService = new Service.Switch(
212
+ options.tripNightSwitchName,
213
+ "siren-night"
214
+ );
202
215
 
203
216
  this.tripNightSwitchService.addCharacteristic(Characteristic.ConfiguredName);
204
217
 
205
218
  this.tripNightSwitchService
206
- .setCharacteristic(Characteristic.ConfiguredName, "Trip Night")
219
+ .setCharacteristic(
220
+ Characteristic.ConfiguredName,
221
+ options.tripNightSwitchName
222
+ )
207
223
  .getCharacteristic(Characteristic.On)
208
224
  .on("get", this.getTripNightSwitch.bind(this))
209
225
  .on("set", this.setTripNightSwitch.bind(this));
210
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
+
211
245
  // Arming lock switches
212
246
  this.armingLockSwitchService = new Service.Switch(
213
247
  "Arming Lock",
@@ -1131,7 +1165,7 @@ SecuritySystem.prototype.updateTripSwitch = function (
1131
1165
  if (value) {
1132
1166
  // Already triggered
1133
1167
  if (isCurrentStateAlarmTriggered) {
1134
- this.log.warn("Trip Switch (Already triggered)");
1168
+ this.log.warn("Security System (Already triggered)");
1135
1169
 
1136
1170
  if (callback !== null) {
1137
1171
  callback(HK_NOT_ALLOWED_IN_CURRENT_STATE, false);
@@ -1142,7 +1176,7 @@ SecuritySystem.prototype.updateTripSwitch = function (
1142
1176
 
1143
1177
  // Already about to trigger
1144
1178
  if (this.triggerTimeout !== null) {
1145
- this.log.warn("Trip Switch (Already on)");
1179
+ this.log.warn("Security System (Already tripped)");
1146
1180
 
1147
1181
  if (callback !== null) {
1148
1182
  callback(HK_NOT_ALLOWED_IN_CURRENT_STATE, false);
@@ -1151,7 +1185,7 @@ SecuritySystem.prototype.updateTripSwitch = function (
1151
1185
  return false;
1152
1186
  }
1153
1187
 
1154
- this.log.info("Trip Switch (On)");
1188
+ this.log.info("Security System (Tripped)");
1155
1189
 
1156
1190
  // Update tripped motion sensor
1157
1191
  if (options.trippedMotionSensor) {
@@ -1220,7 +1254,7 @@ SecuritySystem.prototype.updateTripSwitch = function (
1220
1254
  this.sendWebhookEvent("current", "warning", origin);
1221
1255
  } else {
1222
1256
  // Off
1223
- this.log.info("Trip Switch (Off)");
1257
+ this.log.info("Security System (Cancelled)");
1224
1258
  this.stopAudio();
1225
1259
 
1226
1260
  if (isCurrentStateAlarmTriggered) {
@@ -1254,10 +1288,6 @@ SecuritySystem.prototype.updateTripSwitch = function (
1254
1288
  return true;
1255
1289
  };
1256
1290
 
1257
- SecuritySystem.prototype.setTrip = function (value, callback) {
1258
- this.updateTripSwitch(value, originTypes.REGULAR_SWITCH, false, callback);
1259
- };
1260
-
1261
1291
  // Server
1262
1292
  SecuritySystem.prototype.isAuthenticated = function (req, res) {
1263
1293
  // Check if authentication is disabled
@@ -1804,52 +1834,68 @@ SecuritySystem.prototype.getTripSwitch = function (callback) {
1804
1834
  };
1805
1835
 
1806
1836
  SecuritySystem.prototype.setTripSwitch = function (value, callback) {
1837
+ this.log.info(`Trip Switch (${value ? "On" : "Off"})`);
1807
1838
  this.updateTripSwitch(value, originTypes.REGULAR_SWITCH, false, callback);
1808
1839
  };
1809
1840
 
1810
- SecuritySystem.prototype.getTripOverrideSwitch = function (callback) {
1811
- const value = this.tripOverrideSwitchService.getCharacteristic(
1841
+ SecuritySystem.prototype.getTripHomeSwitch = function (callback) {
1842
+ const value = this.tripHomeSwitchService.getCharacteristic(
1812
1843
  Characteristic.On
1813
1844
  ).value;
1814
1845
  callback(null, value);
1815
1846
  };
1816
1847
 
1817
- SecuritySystem.prototype.setTripOverrideSwitch = function (value, callback) {
1818
- 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
+ );
1819
1855
  };
1820
1856
 
1821
- SecuritySystem.prototype.resetTripSwitches = function () {
1822
- const tripHomeOnCharacteristic = this.tripHomeSwitchService.getCharacteristic(
1823
- Characteristic.On
1824
- );
1825
- const tripAwayOnCharacteristic = this.tripAwaySwitchService.getCharacteristic(
1857
+ SecuritySystem.prototype.getTripAwaySwitch = function (callback) {
1858
+ const value = this.tripAwaySwitchService.getCharacteristic(
1826
1859
  Characteristic.On
1827
- );
1828
- const tripNightOnCharacteristic =
1829
- this.tripNightSwitchService.getCharacteristic(Characteristic.On);
1860
+ ).value;
1861
+ callback(null, value);
1862
+ };
1830
1863
 
1831
- const tripOverrideOnCharacteristic =
1832
- 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
+ };
1833
1872
 
1834
- if (tripHomeOnCharacteristic.value) {
1835
- tripHomeOnCharacteristic.updateValue(false);
1836
- this.log.debug("Trip Home Switch (Off)");
1837
- }
1873
+ SecuritySystem.prototype.getTripNightSwitch = function (callback) {
1874
+ const value = this.tripNightSwitchService.getCharacteristic(
1875
+ Characteristic.On
1876
+ ).value;
1877
+ callback(null, value);
1878
+ };
1838
1879
 
1839
- if (tripAwayOnCharacteristic.value) {
1840
- tripAwayOnCharacteristic.updateValue(false);
1841
- this.log.debug("Trip Away Switch (Off)");
1842
- }
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
+ };
1843
1888
 
1844
- if (tripNightOnCharacteristic.value) {
1845
- tripNightOnCharacteristic.updateValue(false);
1846
- this.log.debug("Trip Night Switch (Off)");
1847
- }
1889
+ SecuritySystem.prototype.getTripOverrideSwitch = function (callback) {
1890
+ const value = this.tripOverrideSwitchService.getCharacteristic(
1891
+ Characteristic.On
1892
+ ).value;
1893
+ callback(null, value);
1894
+ };
1848
1895
 
1849
- if (tripOverrideOnCharacteristic.value) {
1850
- tripOverrideOnCharacteristic.updateValue(false);
1851
- this.log.debug("Trip Override Switch (Off)");
1852
- }
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);
1853
1899
  };
1854
1900
 
1855
1901
  SecuritySystem.prototype.triggerIfModeSet = function (
@@ -1868,7 +1914,7 @@ SecuritySystem.prototype.triggerIfModeSet = function (
1868
1914
  ) {
1869
1915
  this.updateTripSwitch(value, originTypes.REGULAR_SWITCH, false, callback);
1870
1916
  } else {
1871
- this.log.debug("Trip (Mode not set)");
1917
+ this.log.debug("Security System (Trip mode not set)");
1872
1918
  callback(HK_NOT_ALLOWED_IN_CURRENT_STATE, false);
1873
1919
  }
1874
1920
  } else {
@@ -1876,52 +1922,38 @@ SecuritySystem.prototype.triggerIfModeSet = function (
1876
1922
  }
1877
1923
  };
1878
1924
 
1879
- SecuritySystem.prototype.getTripHomeSwitch = function (callback) {
1880
- const value = this.tripHomeSwitchService.getCharacteristic(
1925
+ SecuritySystem.prototype.resetTripSwitches = function () {
1926
+ const tripHomeOnCharacteristic = this.tripHomeSwitchService.getCharacteristic(
1881
1927
  Characteristic.On
1882
- ).value;
1883
- callback(null, value);
1884
- };
1885
-
1886
- SecuritySystem.prototype.setTripHomeSwitch = function (value, callback) {
1887
- this.log.debug("Trip Home Switch (On)");
1888
- this.triggerIfModeSet(
1889
- Characteristic.SecuritySystemCurrentState.STAY_ARM,
1890
- value,
1891
- callback
1892
1928
  );
1893
- };
1894
-
1895
- SecuritySystem.prototype.getTripAwaySwitch = function (callback) {
1896
- const value = this.tripAwaySwitchService.getCharacteristic(
1929
+ const tripAwayOnCharacteristic = this.tripAwaySwitchService.getCharacteristic(
1897
1930
  Characteristic.On
1898
- ).value;
1899
- callback(null, value);
1900
- };
1901
-
1902
- SecuritySystem.prototype.setTripAwaySwitch = function (value, callback) {
1903
- this.log.debug("Trip Away Switch (On)");
1904
- this.triggerIfModeSet(
1905
- Characteristic.SecuritySystemCurrentState.AWAY_ARM,
1906
- value,
1907
- callback
1908
1931
  );
1909
- };
1932
+ const tripNightOnCharacteristic =
1933
+ this.tripNightSwitchService.getCharacteristic(Characteristic.On);
1910
1934
 
1911
- SecuritySystem.prototype.getTripNightSwitch = function (callback) {
1912
- const value = this.tripNightSwitchService.getCharacteristic(
1913
- Characteristic.On
1914
- ).value;
1915
- callback(null, value);
1916
- };
1935
+ const tripOverrideOnCharacteristic =
1936
+ this.tripOverrideSwitchService.getCharacteristic(Characteristic.On);
1917
1937
 
1918
- SecuritySystem.prototype.setTripNightSwitch = function (value, callback) {
1919
- this.log.debug("Trip Night Switch (On)");
1920
- this.triggerIfModeSet(
1921
- Characteristic.SecuritySystemCurrentState.NIGHT_ARM,
1922
- value,
1923
- callback
1924
- );
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
+ }
1925
1957
  };
1926
1958
 
1927
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
  }