iobroker.bmw 2.5.5 → 2.5.6
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/README.md +3 -0
- package/io-package.json +4 -1
- package/main.js +18 -26
- package/package.json +15 -15
package/README.md
CHANGED
package/io-package.json
CHANGED
package/main.js
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
// The adapter-core module gives you access to the core ioBroker functions
|
|
8
8
|
// you need to create an adapter
|
|
9
9
|
const utils = require("@iobroker/adapter-core");
|
|
10
|
-
const axios = require("axios");
|
|
10
|
+
const axios = require("axios").default;
|
|
11
11
|
|
|
12
|
-
const { HttpsCookieAgent } = require("http-cookie-agent");
|
|
12
|
+
const { HttpsCookieAgent } = require("http-cookie-agent/http");
|
|
13
13
|
const crypto = require("crypto");
|
|
14
14
|
const qs = require("qs");
|
|
15
15
|
const { extractKeys } = require("./lib/extractKeys");
|
|
@@ -29,6 +29,20 @@ class Bmw extends utils.Adapter {
|
|
|
29
29
|
this.userAgent = "My%20BMW/8932 CFNetwork/978.0.7 Darwin/18.7.0";
|
|
30
30
|
this.userAgentDart = "Dart/2.14 (dart:io)";
|
|
31
31
|
this.xuserAgent = "android(SP1A.210812.016.C1);brand;99.0.0(99999);row";
|
|
32
|
+
this.updateInterval;
|
|
33
|
+
this.reLoginTimeout;
|
|
34
|
+
this.refreshTokenInterval;
|
|
35
|
+
this.extractKeys = extractKeys;
|
|
36
|
+
this.vinArray = [];
|
|
37
|
+
this.session = {};
|
|
38
|
+
this.statusBlock = {};
|
|
39
|
+
this.nonChargingHistory = {};
|
|
40
|
+
this.cookieJar = new tough.CookieJar(null, { ignoreError: true });
|
|
41
|
+
|
|
42
|
+
this.requestClient = axios.create({
|
|
43
|
+
withCredentials: true,
|
|
44
|
+
httpsAgent: new HttpsCookieAgent({ cookies: { jar: this.cookieJar } }),
|
|
45
|
+
});
|
|
32
46
|
}
|
|
33
47
|
|
|
34
48
|
/**
|
|
@@ -41,23 +55,7 @@ class Bmw extends utils.Adapter {
|
|
|
41
55
|
this.log.info("Set interval to minimum 0.5");
|
|
42
56
|
this.config.interval = 0.5;
|
|
43
57
|
}
|
|
44
|
-
this.cookieJar = new tough.CookieJar(null, { ignoreError: true });
|
|
45
58
|
|
|
46
|
-
this.requestClient = axios.create({
|
|
47
|
-
jar: this.cookieJar,
|
|
48
|
-
withCredentials: true,
|
|
49
|
-
httpsAgent: new HttpsCookieAgent({
|
|
50
|
-
jar: this.cookieJar,
|
|
51
|
-
}),
|
|
52
|
-
});
|
|
53
|
-
this.updateInterval = null;
|
|
54
|
-
this.reLoginTimeout = null;
|
|
55
|
-
this.refreshTokenTimeout = null;
|
|
56
|
-
this.extractKeys = extractKeys;
|
|
57
|
-
this.vinArray = [];
|
|
58
|
-
this.session = {};
|
|
59
|
-
this.statusBlock = {};
|
|
60
|
-
this.nonChargingHistory = {};
|
|
61
59
|
this.subscribeStates("*");
|
|
62
60
|
if (!this.config.username || !this.config.password) {
|
|
63
61
|
this.log.error("Please set username and password");
|
|
@@ -104,7 +102,6 @@ class Bmw extends utils.Adapter {
|
|
|
104
102
|
url: "https://customer.bmwgroup.com/gcdm/oauth/authenticate",
|
|
105
103
|
headers: headers,
|
|
106
104
|
data: qs.stringify(data),
|
|
107
|
-
jar: this.cookieJar,
|
|
108
105
|
withCredentials: true,
|
|
109
106
|
})
|
|
110
107
|
.then((res) => {
|
|
@@ -144,7 +141,6 @@ class Bmw extends utils.Adapter {
|
|
|
144
141
|
url: "https://customer.bmwgroup.com/gcdm/oauth/authenticate",
|
|
145
142
|
headers: headers,
|
|
146
143
|
data: qs.stringify(data),
|
|
147
|
-
jar: this.cookieJar,
|
|
148
144
|
withCredentials: true,
|
|
149
145
|
maxRedirects: 0,
|
|
150
146
|
})
|
|
@@ -170,8 +166,6 @@ class Bmw extends utils.Adapter {
|
|
|
170
166
|
await this.requestClient({
|
|
171
167
|
method: "post",
|
|
172
168
|
url: "https://customer.bmwgroup.com/gcdm/oauth/token",
|
|
173
|
-
|
|
174
|
-
jar: this.cookieJar,
|
|
175
169
|
withCredentials: true,
|
|
176
170
|
headers: {
|
|
177
171
|
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
|
@@ -397,8 +391,8 @@ class Bmw extends utils.Adapter {
|
|
|
397
391
|
this.extractKeys(this, vin + element.path + dateFormatted, data);
|
|
398
392
|
})
|
|
399
393
|
.catch((error) => {
|
|
400
|
-
if (error.response
|
|
401
|
-
this.log.info("No charging session available. Ignore " + vin);
|
|
394
|
+
if (error.response) {
|
|
395
|
+
this.log.info("No charging session available. Ignore " + vin + "until restart");
|
|
402
396
|
this.nonChargingHistory[vin] = true;
|
|
403
397
|
return;
|
|
404
398
|
}
|
|
@@ -451,7 +445,6 @@ class Bmw extends utils.Adapter {
|
|
|
451
445
|
await this.requestClient({
|
|
452
446
|
method: "post",
|
|
453
447
|
url: "https://customer.bmwgroup.com/gcdm/oauth/token",
|
|
454
|
-
jar: this.cookieJar,
|
|
455
448
|
withCredentials: true,
|
|
456
449
|
headers: {
|
|
457
450
|
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
|
@@ -486,7 +479,6 @@ class Bmw extends utils.Adapter {
|
|
|
486
479
|
try {
|
|
487
480
|
clearTimeout(this.refreshTimeout);
|
|
488
481
|
clearTimeout(this.reLoginTimeout);
|
|
489
|
-
clearTimeout(this.refreshTokenTimeout);
|
|
490
482
|
clearInterval(this.updateInterval);
|
|
491
483
|
clearInterval(this.refreshTokenInterval);
|
|
492
484
|
callback();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iobroker.bmw",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.6",
|
|
4
4
|
"description": "Adapter for BMW",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TA2k",
|
|
@@ -16,30 +16,30 @@
|
|
|
16
16
|
"url": "https://github.com/TA2k/ioBroker.bmw"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@iobroker/adapter-core": "^2.6.
|
|
20
|
-
"axios": "^0.
|
|
21
|
-
"http-cookie-agent": "^
|
|
19
|
+
"@iobroker/adapter-core": "^2.6.6",
|
|
20
|
+
"axios": "^0.27.2",
|
|
21
|
+
"http-cookie-agent": "^4.0.2",
|
|
22
22
|
"json-bigint": "^1.0.0",
|
|
23
|
-
"qs": "^6.
|
|
24
|
-
"tough-cookie": "^4.
|
|
23
|
+
"qs": "^6.11.0",
|
|
24
|
+
"tough-cookie": "^4.1.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@iobroker/testing": "^
|
|
28
|
-
"@types/chai": "^4.3.
|
|
27
|
+
"@iobroker/testing": "^4.1.0",
|
|
28
|
+
"@types/chai": "^4.3.3",
|
|
29
29
|
"@types/chai-as-promised": "^7.1.5",
|
|
30
|
-
"@types/mocha": "^9.1.
|
|
31
|
-
"@types/node": "^
|
|
30
|
+
"@types/mocha": "^9.1.1",
|
|
31
|
+
"@types/node": "^18.7.18",
|
|
32
32
|
"@types/proxyquire": "^1.3.28",
|
|
33
|
-
"@types/sinon": "^10.0.
|
|
33
|
+
"@types/sinon": "^10.0.13",
|
|
34
34
|
"@types/sinon-chai": "^3.2.8",
|
|
35
35
|
"chai": "^4.3.6",
|
|
36
36
|
"chai-as-promised": "^7.1.1",
|
|
37
|
-
"eslint": "^8.
|
|
38
|
-
"mocha": "^
|
|
37
|
+
"eslint": "^8.23.1",
|
|
38
|
+
"mocha": "^10.0.0",
|
|
39
39
|
"proxyquire": "^2.1.3",
|
|
40
|
-
"sinon": "^
|
|
40
|
+
"sinon": "^14.0.0",
|
|
41
41
|
"sinon-chai": "^3.7.0",
|
|
42
|
-
"typescript": "^4.
|
|
42
|
+
"typescript": "^4.8.3"
|
|
43
43
|
},
|
|
44
44
|
"main": "main.js",
|
|
45
45
|
"scripts": {
|