homebridge-verisure 1.13.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 +28 -0
- package/README.md +29 -1
- package/bin/verisure +54 -0
- package/config.schema.json +6 -1
- package/lib/platform.js +39 -18
- package/package.json +13 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
## 1.14.2 (Jan 4, 2022)
|
|
2
|
+
|
|
3
|
+
### Plugin
|
|
4
|
+
|
|
5
|
+
* Initiate gracefully, to not affect other plugins.
|
|
6
|
+
|
|
7
|
+
## 1.14.1 (Oct 8, 2021)
|
|
8
|
+
|
|
9
|
+
### Dependencies
|
|
10
|
+
|
|
11
|
+
* Bump `verisure` module.
|
|
12
|
+
|
|
13
|
+
## 1.14.0 (Mar 17, 2021)
|
|
14
|
+
|
|
15
|
+
### Config
|
|
16
|
+
|
|
17
|
+
* Support for Multi-factor authentication (MFA).
|
|
18
|
+
|
|
19
|
+
### Dependencies
|
|
20
|
+
|
|
21
|
+
* Bump `verisure` module.
|
|
22
|
+
|
|
23
|
+
## 1.13.2 (Feb 28, 2021)
|
|
24
|
+
|
|
25
|
+
### Plugin
|
|
26
|
+
|
|
27
|
+
* Return empty list of accessories when initiation fails.
|
|
28
|
+
|
|
1
29
|
## 1.13.1 (Feb 27, 2021)
|
|
2
30
|
|
|
3
31
|
### Plugin
|
package/README.md
CHANGED
|
@@ -48,6 +48,7 @@ your array (list) of enabled platform plugins. Example config:
|
|
|
48
48
|
"name" : "Verisure",
|
|
49
49
|
"email": "your@email.com",
|
|
50
50
|
"password": "yourT0p5ecre7Passw0rd",
|
|
51
|
+
"token": "vid=topSecretToken",
|
|
51
52
|
"alarmCode": "0000",
|
|
52
53
|
"doorCode": "000000",
|
|
53
54
|
"pollInterval": 60
|
|
@@ -56,11 +57,37 @@ your array (list) of enabled platform plugins. Example config:
|
|
|
56
57
|
```
|
|
57
58
|
|
|
58
59
|
* __`email`__ Required string containing your Verisure account email address.
|
|
59
|
-
* __`password`__ Required string containing your Verisure account password.
|
|
60
|
+
* __`password`__ Required string containing your Verisure account password. Not needed if you use a `token`.
|
|
61
|
+
* __`token`__ Required string for accounts with MFA enabled.
|
|
60
62
|
* `alarmCode` Optional string containing your security system alarm code.
|
|
61
63
|
* `doorCode` Optional string containing your door lock code.
|
|
62
64
|
* `pollInterval` Optional integer containing poll interval in seconds. Defaults to `60`.
|
|
63
65
|
|
|
66
|
+
### Multi-factor authentication
|
|
67
|
+
|
|
68
|
+
> [Verisure] MFA is enabled for user. Please see README.
|
|
69
|
+
|
|
70
|
+
In 2021 Verisure started enrolling MFA which requires you to obtain a long lived token. This token is used instead of a `password` in your config and will need to be renewed yearly. After installing the plugin, run `npx verisure` in your terminal and copy the output values into your config.
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
$ npx verisure
|
|
74
|
+
✔ What is your login email? · foo@bar.com
|
|
75
|
+
✔ What is your password? · ********************
|
|
76
|
+
|
|
77
|
+
One-time code sent.
|
|
78
|
+
|
|
79
|
+
✔ What is your one-time code? · FAKE12
|
|
80
|
+
|
|
81
|
+
Your config is ready.
|
|
82
|
+
|
|
83
|
+
{
|
|
84
|
+
"platform": "verisure",
|
|
85
|
+
"name": "Verisure",
|
|
86
|
+
"email": "foo@bar.com",
|
|
87
|
+
"token": "vid=topSecretToken"
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
64
91
|
### Environment variables
|
|
65
92
|
|
|
66
93
|
For convenience, the following environment variables can be used instead of placing secrets in your `config.json`.
|
|
@@ -69,3 +96,4 @@ For convenience, the following environment variables can be used instead of plac
|
|
|
69
96
|
* `VERISURE_DOOR_CODE`
|
|
70
97
|
* `VERISURE_EMAIL`
|
|
71
98
|
* `VERISURE_PASSWORD`
|
|
99
|
+
* `VERISURE_TOKEN`
|
package/bin/verisure
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { prompt, Password } = require('enquirer');
|
|
4
|
+
|
|
5
|
+
const Verisure = require('verisure');
|
|
6
|
+
|
|
7
|
+
const validate = (value) => !!value.length;
|
|
8
|
+
|
|
9
|
+
const run = async () => {
|
|
10
|
+
const { email } = await prompt({
|
|
11
|
+
type: 'input',
|
|
12
|
+
name: 'email',
|
|
13
|
+
message: 'What is your login email?',
|
|
14
|
+
validate,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const password = await new Password({
|
|
18
|
+
name: 'password',
|
|
19
|
+
message: 'What is your password?',
|
|
20
|
+
validate,
|
|
21
|
+
}).run();
|
|
22
|
+
|
|
23
|
+
const verisure = new Verisure(email.trim(), password);
|
|
24
|
+
|
|
25
|
+
await verisure.getToken();
|
|
26
|
+
|
|
27
|
+
if (!verisure.getCookie('vid')) {
|
|
28
|
+
console.log("\n", 'One-time code sent.', "\n");
|
|
29
|
+
|
|
30
|
+
const { code } = await prompt({
|
|
31
|
+
type: 'input',
|
|
32
|
+
name: 'code',
|
|
33
|
+
message: 'What is your one-time code?',
|
|
34
|
+
validate,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
await verisure.getToken(code.trim());
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
console.log("\n", 'Your config is ready.', "\n");
|
|
41
|
+
|
|
42
|
+
console.log(JSON.stringify({
|
|
43
|
+
platform: 'verisure',
|
|
44
|
+
name: 'Verisure',
|
|
45
|
+
email,
|
|
46
|
+
token: verisure.getCookie('vid')
|
|
47
|
+
}, null, 2));
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
run();
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.log(error.message);
|
|
54
|
+
}
|
package/config.schema.json
CHANGED
package/lib/platform.js
CHANGED
|
@@ -15,12 +15,14 @@ class VerisurePlatform {
|
|
|
15
15
|
VERISURE_DOOR_CODE,
|
|
16
16
|
VERISURE_EMAIL,
|
|
17
17
|
VERISURE_PASSWORD,
|
|
18
|
+
VERISURE_TOKEN,
|
|
18
19
|
} = process.env;
|
|
19
20
|
|
|
20
21
|
const {
|
|
21
22
|
alarmCode,
|
|
22
23
|
doorcode, doorCode,
|
|
23
24
|
email,
|
|
25
|
+
token,
|
|
24
26
|
password,
|
|
25
27
|
pollInterval = 60,
|
|
26
28
|
} = config;
|
|
@@ -30,13 +32,18 @@ class VerisurePlatform {
|
|
|
30
32
|
doorCode: VERISURE_DOOR_CODE || doorcode || doorCode,
|
|
31
33
|
email: VERISURE_EMAIL || email,
|
|
32
34
|
password: VERISURE_PASSWORD || password,
|
|
35
|
+
token: VERISURE_TOKEN || token,
|
|
33
36
|
pollInterval,
|
|
34
37
|
};
|
|
35
38
|
|
|
36
39
|
this.homebridge = homebridge;
|
|
37
40
|
this.logger = logger;
|
|
38
41
|
|
|
39
|
-
this.verisure = new Verisure(
|
|
42
|
+
this.verisure = new Verisure(
|
|
43
|
+
this.config.email,
|
|
44
|
+
this.config.password,
|
|
45
|
+
this.config.token && [this.config.token],
|
|
46
|
+
);
|
|
40
47
|
}
|
|
41
48
|
|
|
42
49
|
static init(homebridgeRef) {
|
|
@@ -84,23 +91,37 @@ class VerisurePlatform {
|
|
|
84
91
|
return accessories;
|
|
85
92
|
}
|
|
86
93
|
|
|
87
|
-
accessories(callback) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
94
|
+
async accessories(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
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
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
|
+
}
|
|
110
|
+
|
|
111
|
+
const overviews = await Promise.all(
|
|
112
|
+
this.installations.map((installation) => Promise.all([
|
|
113
|
+
installation,
|
|
114
|
+
installation.getOverview(),
|
|
115
|
+
])),
|
|
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
|
+
}
|
|
104
125
|
}
|
|
105
126
|
}
|
|
106
127
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-verisure",
|
|
3
|
-
"version": "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,24 +11,32 @@
|
|
|
11
11
|
"url": "git://github.com/ptz0n/homebridge-verisure.git"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
|
-
"test": "eslint lib && jest --
|
|
14
|
+
"test": "eslint lib && jest --coverage"
|
|
15
|
+
},
|
|
16
|
+
"bin": {
|
|
17
|
+
"verisure": "bin/verisure"
|
|
15
18
|
},
|
|
16
19
|
"bugs": {
|
|
17
20
|
"url": "http://github.com/ptz0n/homebridge-verisure/issues"
|
|
18
21
|
},
|
|
19
22
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
23
|
+
"node": ">=12",
|
|
21
24
|
"homebridge": ">=0.2.0"
|
|
22
25
|
},
|
|
23
26
|
"dependencies": {
|
|
24
|
-
"
|
|
27
|
+
"enquirer": "^2.3.6",
|
|
28
|
+
"verisure": "^4.1.0"
|
|
25
29
|
},
|
|
26
30
|
"devDependencies": {
|
|
31
|
+
"eslint": "^6.7.2",
|
|
27
32
|
"eslint-config-airbnb-base": "^14.0.0",
|
|
28
33
|
"eslint-plugin-import": "^2.8.0",
|
|
29
34
|
"eslint-plugin-jest": "^23.1.0",
|
|
30
|
-
"eslint": "^6.7.2",
|
|
31
35
|
"hap-nodejs": "^0.7.2",
|
|
36
|
+
"homebridge": "^1.3.9",
|
|
32
37
|
"jest": "^25.0.0"
|
|
38
|
+
},
|
|
39
|
+
"jest": {
|
|
40
|
+
"testEnvironment": "node"
|
|
33
41
|
}
|
|
34
42
|
}
|