homebridge-verisure 1.14.1 → 1.14.2

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.14.2 (Jan 4, 2022)
2
+
3
+ ### Plugin
4
+
5
+ * Initiate gracefully, to not affect other plugins.
6
+
1
7
  ## 1.14.1 (Oct 8, 2021)
2
8
 
3
9
  ### Dependencies
package/lib/platform.js CHANGED
@@ -92,31 +92,36 @@ class VerisurePlatform {
92
92
  }
93
93
 
94
94
  async accessories(callback) {
95
- if (!this.verisure.cookies.length) {
96
- await this.verisure.getToken();
97
-
98
- if (!this.verisure.getCookie('vid')) {
99
- this.logger.error('MFA is enabled for user. Please see README.');
100
- return callback([]);
95
+ try {
96
+ if (!this.verisure.cookies.length) {
97
+ await this.verisure.getToken();
98
+
99
+ if (!this.verisure.getCookie('vid')) {
100
+ this.logger.error('MFA is enabled for user. Please see README.');
101
+ return callback([]);
102
+ }
101
103
  }
102
- }
103
104
 
104
- const installations = await this.verisure.getInstallations();
105
+ this.installations = await this.verisure.getInstallations();
106
+ } catch (error) {
107
+ this.logger.error(`Unable to get installations. Please check configured credentials: ${error.message}`);
108
+ return callback([]);
109
+ }
105
110
 
106
- return Promise.all(
107
- installations.map((installation) => Promise.all([
111
+ const overviews = await Promise.all(
112
+ this.installations.map((installation) => Promise.all([
108
113
  installation,
109
114
  installation.getOverview(),
110
115
  ])),
111
- )
112
- .then((overviews) => {
113
- const accessoryLists = overviews.map(this.overviewToAccessories.bind(this));
114
- callback(accessoryLists.reduce((a, b) => [...a, ...b]));
115
- })
116
- .catch((error) => {
117
- this.logger.error((error.response && error.response.data) || error.message);
118
- callback([]);
119
- });
116
+ );
117
+
118
+ try {
119
+ const accessoryLists = overviews.map(this.overviewToAccessories.bind(this));
120
+ return callback(accessoryLists.reduce((a, b) => [...a, ...b]));
121
+ } catch (error) {
122
+ this.logger.error((error.response && error.response.data) || error.message);
123
+ return callback([]);
124
+ }
120
125
  }
121
126
  }
122
127
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homebridge-verisure",
3
- "version": "1.14.1",
3
+ "version": "1.14.2",
4
4
  "description": "Verisure plugin for homebridge: https://github.com/nfarina/homebridge",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -11,7 +11,7 @@
11
11
  "url": "git://github.com/ptz0n/homebridge-verisure.git"
12
12
  },
13
13
  "scripts": {
14
- "test": "eslint lib && jest --env=node --coverage"
14
+ "test": "eslint lib && jest --coverage"
15
15
  },
16
16
  "bin": {
17
17
  "verisure": "bin/verisure"
@@ -20,7 +20,7 @@
20
20
  "url": "http://github.com/ptz0n/homebridge-verisure/issues"
21
21
  },
22
22
  "engines": {
23
- "node": ">=8",
23
+ "node": ">=12",
24
24
  "homebridge": ">=0.2.0"
25
25
  },
26
26
  "dependencies": {
@@ -33,6 +33,10 @@
33
33
  "eslint-plugin-import": "^2.8.0",
34
34
  "eslint-plugin-jest": "^23.1.0",
35
35
  "hap-nodejs": "^0.7.2",
36
+ "homebridge": "^1.3.9",
36
37
  "jest": "^25.0.0"
38
+ },
39
+ "jest": {
40
+ "testEnvironment": "node"
37
41
  }
38
42
  }