homebridge-verisure 1.15.0 → 1.16.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 1.16.0 (Aug 27, 2022)
2
+
3
+ ### Plugin
4
+
5
+ * Added config options for door lock; auto-lock and volume.
6
+
1
7
  ## 1.15.0 (Jan 11, 2022)
2
8
 
3
9
  ### Plugin
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # homebridge-verisure
2
2
 
3
- [![Greenkeeper badge](https://badges.greenkeeper.io/ptz0n/homebridge-verisure.svg)](https://greenkeeper.io/)
3
+ [![Verified by Homebridge](https://badgen.net/badge/homebridge/verified/purple)](https://github.com/homebridge/homebridge/wiki/Verified-Plugins)
4
+
5
+ [![Synk badge](https://snyk.io/test/github/ptz0n/homebridge-verisure/badge.svg)](https://snyk.io/)
4
6
 
5
7
  [![GitHub Actions badge](https://github.com/ptz0n/homebridge-verisure/workflows/Test/badge.svg)](https://github.com/ptz0n/homebridge-verisure/actions?query=workflow%3ATest)
6
8
 
@@ -18,16 +18,19 @@
18
18
  "token": {
19
19
  "title": "Token",
20
20
  "type": "string",
21
+ "placeholder": "vid=topSecretToken",
21
22
  "required": false
22
23
  },
23
24
  "alarmCode": {
24
25
  "title": "Alarm Code",
25
26
  "type": "string",
27
+ "placeholder": "0000",
26
28
  "required": false
27
29
  },
28
30
  "doorCode": {
29
31
  "title": "Door Code",
30
32
  "type": "string",
33
+ "placeholder": "000000",
31
34
  "required": false
32
35
  },
33
36
  "installations": {
@@ -43,9 +46,42 @@
43
46
  "type": "integer",
44
47
  "default": 60,
45
48
  "required": false
49
+ },
50
+ "showAutoLockSwitch": {
51
+ "title": "Show Auto-lock switch",
52
+ "type": "boolean",
53
+ "default": true
54
+ },
55
+ "showAudioSwitch": {
56
+ "title": "Show audio switch",
57
+ "type": "boolean",
58
+ "default": true
59
+ },
60
+ "audioOffValue": {
61
+ "title": "Audio off Value",
62
+ "type": "string",
63
+ "default": "SILENCE",
64
+ "oneOf": [
65
+ { "title": "Silence", "enum": ["SILENCE"] },
66
+ { "title": "Low", "enum": ["LOW"] }
67
+ ],
68
+ "required": true,
69
+ "functionBody": "return model.showAudioSwitch === true;"
70
+ },
71
+ "audioOnValue": {
72
+ "title": "Audio on Value",
73
+ "type": "string",
74
+ "default": "HIGH",
75
+ "oneOf": [
76
+ { "title": "Low", "enum": ["LOW"] },
77
+ { "title": "High", "enum": ["HIGH"] }
78
+ ],
79
+ "required": true,
80
+ "functionBody": "return model.showAudioSwitch === true;"
46
81
  }
47
82
  }
48
83
  },
49
84
  "form": null,
50
85
  "display": null
86
+
51
87
  }
@@ -38,7 +38,7 @@ class Alarm extends VerisureAccessory {
38
38
  }
39
39
 
40
40
  getCurrentAlarmState(callback) {
41
- this.log('Getting current alarm state.');
41
+ this.log('Getting current alarm state.', 'debug');
42
42
 
43
43
  this.installation.getOverview()
44
44
  .then((overview) => {
@@ -15,7 +15,7 @@ class ContactSensor extends VerisureAccessory {
15
15
  }
16
16
 
17
17
  getCurrentSensorState(callback) {
18
- this.log('Getting current sensor state.');
18
+ this.log('Getting current sensor state.', 'debug');
19
19
 
20
20
  this.installation.getOverview()
21
21
  .then((overview) => overview.doorWindow.doorWindowDevice
@@ -8,6 +8,7 @@ class DoorLock extends VerisureAccessory {
8
8
 
9
9
  this.doorCode = this.platformConfig.doorCode;
10
10
  this.switchName = VerisureAccessory.getUniqueAccessoryName(`Auto-lock (${this.config.area})`);
11
+ this.audioName = VerisureAccessory.getUniqueAccessoryName(`Audio (${this.config.area})`);
11
12
  this.configUrl = `/device/${this.serialNumber}/doorlockconfig`;
12
13
  }
13
14
 
@@ -38,7 +39,7 @@ class DoorLock extends VerisureAccessory {
38
39
  }
39
40
 
40
41
  getCurrentLockState(callback) {
41
- this.log('Getting current lock state.');
42
+ this.log('Getting current lock state.', 'debug');
42
43
 
43
44
  // TODO: Use this.cachedValue, if available?
44
45
 
@@ -124,6 +125,36 @@ class DoorLock extends VerisureAccessory {
124
125
  });
125
126
  }
126
127
 
128
+ getAudioState(callback) {
129
+ this.installation.client({ url: this.configUrl })
130
+ .then((config) => {
131
+ this.audioState = config.volume !== this.platformConfig.audioOffValue;
132
+ callback(null, this.audioState);
133
+ })
134
+ .catch(callback);
135
+ }
136
+
137
+ setAudioState(value, callback) {
138
+ this.audioState = value;
139
+
140
+ const volume = value
141
+ ? this.platformConfig.audioOnValue
142
+ : this.platformConfig.audioOffValue;
143
+
144
+ const request = {
145
+ method: 'PUT',
146
+ url: this.configUrl,
147
+ data: { volume },
148
+ };
149
+
150
+ this.installation.client(request)
151
+ .then(() => callback(null))
152
+ .catch((error) => {
153
+ // TODO: Revert config state in this.value?
154
+ callback({ message: error.errorMessage });
155
+ });
156
+ }
157
+
127
158
  getServices() {
128
159
  const { Service, Characteristic } = this.homebridge.hap;
129
160
 
@@ -141,13 +172,25 @@ class DoorLock extends VerisureAccessory {
141
172
 
142
173
  services.push(this.lockService);
143
174
 
144
- this.switchService = new Service.Switch(this.switchName);
145
- this.switchService
146
- .getCharacteristic(Characteristic.On)
147
- .on('get', this.getAutoLockState.bind(this))
148
- .on('set', this.setAutoLockState.bind(this));
175
+ if (this.platformConfig.showAutoLockSwitch) {
176
+ this.autoLockService = new Service.Switch(this.switchName, this.switchName);
177
+ this.autoLockService
178
+ .getCharacteristic(Characteristic.On)
179
+ .on('get', this.getAutoLockState.bind(this))
180
+ .on('set', this.setAutoLockState.bind(this));
181
+
182
+ services.push(this.autoLockService);
183
+ }
184
+
185
+ if (this.platformConfig.showAudioSwitch) {
186
+ this.audioService = new Service.Switch(this.audioName, this.audioName);
187
+ this.audioService
188
+ .getCharacteristic(Characteristic.On)
189
+ .on('get', this.getAudioState.bind(this))
190
+ .on('set', this.setAudioState.bind(this));
149
191
 
150
- services.push(this.switchService);
192
+ services.push(this.audioService);
193
+ }
151
194
 
152
195
  this.pollCharacteristics.push(currentStateCharacteristic);
153
196
 
@@ -53,8 +53,8 @@ class VerisureAccessory {
53
53
  });
54
54
  }
55
55
 
56
- log(message) {
57
- return this.logger('info', `${this.installation.config.alias} ${this.name}: ${message}`);
56
+ log(message, level = 'info') {
57
+ return this.logger[level](`${this.installation.config.alias} ${this.name}: ${message}`);
58
58
  }
59
59
  }
60
60
 
package/lib/platform.js CHANGED
@@ -26,6 +26,10 @@ class VerisurePlatform {
26
26
  password,
27
27
  installations = [],
28
28
  pollInterval = 60,
29
+ showAutoLockSwitch = true,
30
+ showAudioSwitch = true,
31
+ audioOffValue = 'LOW',
32
+ audioOnValue = 'HIGH',
29
33
  } = config;
30
34
 
31
35
  this.config = {
@@ -36,6 +40,10 @@ class VerisurePlatform {
36
40
  token: VERISURE_TOKEN || token,
37
41
  installations,
38
42
  pollInterval,
43
+ showAutoLockSwitch,
44
+ showAudioSwitch,
45
+ audioOffValue,
46
+ audioOnValue,
39
47
  };
40
48
 
41
49
  this.homebridge = homebridge;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homebridge-verisure",
3
- "version": "1.15.0",
3
+ "version": "1.16.0",
4
4
  "description": "Verisure plugin for homebridge: https://github.com/nfarina/homebridge",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -10,6 +10,10 @@
10
10
  "type": "git",
11
11
  "url": "git://github.com/ptz0n/homebridge-verisure.git"
12
12
  },
13
+ "funding": {
14
+ "type": "paypal",
15
+ "url": "https://www.paypal.com/paypalme/ptz0n"
16
+ },
13
17
  "scripts": {
14
18
  "test": "eslint lib && jest --coverage"
15
19
  },
@@ -19,7 +23,7 @@
19
23
  },
20
24
  "engines": {
21
25
  "node": ">=12",
22
- "homebridge": ">=0.2.0"
26
+ "homebridge": ">=1.0.0"
23
27
  },
24
28
  "dependencies": {
25
29
  "enquirer": "^2.3.6",