iobroker.amtronwallbox 0.3.0 → 0.3.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/LICENSE +1 -1
- package/README.md +9 -1
- package/io-package.json +32 -27
- package/lib/support_tools.js +30 -49
- package/lib/tools.js +8 -6
- package/main.js +150 -188
- package/package.json +10 -9
- /package/admin/{jsonConfig.json → jsonConfig.json5} +0 -0
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2022-
|
|
3
|
+
Copyright (c) 2022-2025 René G. <info@rg-engineering.eu>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -54,6 +54,14 @@ Note: Since the boxes have different interfaces, it may be that not all interfac
|
|
|
54
54
|
Placeholder for the next version (at the beginning of the line):
|
|
55
55
|
### **WORK IN PROGRESS**
|
|
56
56
|
-->
|
|
57
|
+
### 0.3.2 (2025-06-28)
|
|
58
|
+
* (René) update dependencies
|
|
59
|
+
* (René) new testing
|
|
60
|
+
|
|
61
|
+
### 0.3.1 (2025-02-27)
|
|
62
|
+
* (René) changes requested by adapter checker
|
|
63
|
+
* (René) dependencies updated
|
|
64
|
+
|
|
57
65
|
### 0.3.0 (2024-12-17)
|
|
58
66
|
* (René) see issue #284: test with nodejs@22
|
|
59
67
|
* (René) update dependencies
|
|
@@ -120,7 +128,7 @@ Note: Since the boxes have different interfaces, it may be that not all interfac
|
|
|
120
128
|
## License
|
|
121
129
|
MIT License
|
|
122
130
|
|
|
123
|
-
Copyright (c) 2022-
|
|
131
|
+
Copyright (c) 2022-2025 René G. <info@rg-engineering.eu>
|
|
124
132
|
|
|
125
133
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
126
134
|
of this software and associated documentation files (the "Software"), to deal
|
package/io-package.json
CHANGED
|
@@ -1,8 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"name": "amtronwallbox",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.2",
|
|
5
5
|
"news": {
|
|
6
|
+
"0.3.2": {
|
|
7
|
+
"en": "update dependencies\nnew testing",
|
|
8
|
+
"de": "aktualisierung der abhängigkeiten\nneue tests",
|
|
9
|
+
"ru": "обновление зависимостей\nновые испытания",
|
|
10
|
+
"pt": "atualizar dependências\nnovos testes",
|
|
11
|
+
"nl": "afhankelijkheden bijwerken\nnieuwe tests",
|
|
12
|
+
"fr": "mettre à jour les dépendances\nnouveaux essais",
|
|
13
|
+
"it": "aggiornamento dipendenze\nnuovi test",
|
|
14
|
+
"es": "dependencias de actualización\nnuevas pruebas",
|
|
15
|
+
"pl": "aktualizacji zależności\nnowe badania",
|
|
16
|
+
"uk": "оновлення залежності\nновий тест",
|
|
17
|
+
"zh-cn": "更新依赖关系\n新测试"
|
|
18
|
+
},
|
|
19
|
+
"0.3.1": {
|
|
20
|
+
"en": "changes requested by adapter checker\ndependencies updated",
|
|
21
|
+
"de": "änderungen, die von adapter checker angefordert werden\naktualisierte abhängigkeiten",
|
|
22
|
+
"ru": "изменения, запрошенные adapter checker\nобновленные зависимости",
|
|
23
|
+
"pt": "alterações solicitadas pelo verificador do adaptador\ndependências atualizadas",
|
|
24
|
+
"nl": "wijzigingen gevraagd door adaptercontrole\nafhankelijkheden bijgewerkt",
|
|
25
|
+
"fr": "modifications demandées par l'adaptateur checker\ndépendances mises à jour",
|
|
26
|
+
"it": "modifiche richieste da adattatore checker\ndipendenze aggiornate",
|
|
27
|
+
"es": "cambios solicitados por el adaptador\ndependencias actualizadas",
|
|
28
|
+
"pl": "zmiany wymagane przez sprawdzacz adaptera\nzaktualizowane zależności",
|
|
29
|
+
"uk": "зміни, які вимагаються перевіркою адаптера\nоновлені залежності",
|
|
30
|
+
"zh-cn": "适配器检查器要求的更改\n更新依赖关系"
|
|
31
|
+
},
|
|
6
32
|
"0.3.0": {
|
|
7
33
|
"en": "see issue #284: test with nodejs@22\nupdate dependencies\nmigration to jsonConfig",
|
|
8
34
|
"de": "siehe ausgabe #284: test mit nodejs@22\naktualisierung der abhängigkeiten\nmigration nach jsonConfig",
|
|
@@ -67,32 +93,6 @@
|
|
|
67
93
|
"pl": "(René) – test sanitarny",
|
|
68
94
|
"uk": "(René) просто відправник",
|
|
69
95
|
"zh-cn": "(René) 只是一个发送的试验"
|
|
70
|
-
},
|
|
71
|
-
"0.2.12": {
|
|
72
|
-
"en": "(René) see issue #162: ignore unused data from wallbox",
|
|
73
|
-
"de": "(René) siehe Ausgabe #162: Nicht genutzte Daten von wallbox ignorieren",
|
|
74
|
-
"ru": "(René) см. номер #162: игнорировать неиспользуемые данные из настенного ящика",
|
|
75
|
-
"pt": "(René) ver número #162: ignorar dados não utilizados da wallbox",
|
|
76
|
-
"nl": "Vertaling:",
|
|
77
|
-
"fr": "(René) voir le numéro #162: ignorer les données inutilisées de la boîte murale",
|
|
78
|
-
"it": "(René) vedi numero #162: ignora i dati inutilizzati dal wallbox",
|
|
79
|
-
"es": "(René) ver el número #162: ignorar los datos no utilizados de wallbox",
|
|
80
|
-
"pl": "(René) ↓, s. 11",
|
|
81
|
-
"uk": "(René) див. питання #162: ігнорувати невикористані дані з скриньки",
|
|
82
|
-
"zh-cn": "(René) 见第162号:无视墙壁数据"
|
|
83
|
-
},
|
|
84
|
-
"0.2.11": {
|
|
85
|
-
"en": "(René) type of adapter changed back to \"energy\"",
|
|
86
|
-
"de": "(René) Typ des Adapters zurück in die Energie",
|
|
87
|
-
"ru": "(René) тип адаптера изменился обратно к энергии",
|
|
88
|
-
"pt": "(René) tipo de adaptador alterado de volta à energia",
|
|
89
|
-
"nl": "Een soort van adapter veranderde terug in energie",
|
|
90
|
-
"fr": "(René) type d'adaptateur changé en énergie",
|
|
91
|
-
"it": "(René) tipo di adattatore cambiato di nuovo in energia",
|
|
92
|
-
"es": "(René) tipo de adaptador cambiado de nuevo a la energía",
|
|
93
|
-
"pl": "(René) rodzaj adaptatora zmieniał się z powrotem do energii",
|
|
94
|
-
"uk": "(René) тип адаптера змінився назад до енергії",
|
|
95
|
-
"zh-cn": "(René) 适应者类型改为能源"
|
|
96
96
|
}
|
|
97
97
|
},
|
|
98
98
|
"titleLang": {
|
|
@@ -146,6 +146,11 @@
|
|
|
146
146
|
"js-controller": ">=5.0.19"
|
|
147
147
|
}
|
|
148
148
|
],
|
|
149
|
+
"globalDependencies": [
|
|
150
|
+
{
|
|
151
|
+
"admin": ">=7.4.10"
|
|
152
|
+
}
|
|
153
|
+
],
|
|
149
154
|
"plugins": {
|
|
150
155
|
"sentry": {
|
|
151
156
|
"dsn": "https://9062b5ac97dc4ee08af43fb2513eb6c8@o390433.ingest.sentry.io/4505104266297344"
|
package/lib/support_tools.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
/* eslint-disable prefer-template */
|
|
1
2
|
"use strict";
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
/**
|
|
6
|
+
* @param {object} adapter
|
|
5
7
|
* @param {string} timeVal
|
|
6
8
|
* @param {string} timeLimit
|
|
7
9
|
*/
|
|
@@ -18,26 +20,24 @@ function IsLater(adapter, timeVal, timeLimit) {
|
|
|
18
20
|
if (valIn.length > 1 && valLimits.length > 1) {
|
|
19
21
|
|
|
20
22
|
if (parseInt(valIn[0]) > parseInt(valLimits[0])
|
|
21
|
-
|
|
23
|
+
|| (parseInt(valIn[0]) == parseInt(valLimits[0]) && parseInt(valIn[1]) > parseInt(valLimits[1]))) {
|
|
22
24
|
ret = true;
|
|
23
25
|
adapter.log.debug("yes, IsLater : " + timeVal + " " + timeLimit);
|
|
24
26
|
}
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
+
} else {
|
|
27
28
|
adapter.log.error("string does not contain : " + timeVal + " " + timeLimit);
|
|
28
29
|
}
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
30
|
+
} else {
|
|
31
31
|
adapter.log.error("not a string " + typeof timeVal + " " + typeof timeLimit);
|
|
32
32
|
}
|
|
33
|
-
}
|
|
34
|
-
catch (e) {
|
|
33
|
+
} catch (e) {
|
|
35
34
|
adapter.log.error("exception in IsLater [" + e + "]");
|
|
36
35
|
}
|
|
37
36
|
return ret;
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
/**
|
|
40
|
+
* @param {object} adapter
|
|
41
41
|
* @param {string } timeVal
|
|
42
42
|
* @param {string } [timeLimit]
|
|
43
43
|
*/
|
|
@@ -54,26 +54,24 @@ function IsEarlier(adapter, timeVal, timeLimit) {
|
|
|
54
54
|
if (valIn.length > 1 && valLimits.length > 1) {
|
|
55
55
|
|
|
56
56
|
if (parseInt(valIn[0]) < parseInt(valLimits[0])
|
|
57
|
-
|
|
57
|
+
|| (parseInt(valIn[0]) == parseInt(valLimits[0]) && parseInt(valIn[1]) < parseInt(valLimits[1]))) {
|
|
58
58
|
ret = true;
|
|
59
59
|
adapter.log.debug("yes, IsEarlier : " + timeVal + " " + timeLimit);
|
|
60
60
|
}
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
61
|
+
} else {
|
|
63
62
|
adapter.log.error("string does not contain : " + timeVal + " " + timeLimit);
|
|
64
63
|
}
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
64
|
+
} else {
|
|
67
65
|
adapter.log.error("not a string " + typeof timeVal + " " + typeof timeLimit);
|
|
68
66
|
}
|
|
69
|
-
}
|
|
70
|
-
catch (e) {
|
|
67
|
+
} catch (e) {
|
|
71
68
|
adapter.log.error("exception in IsEarlier [" + e + "]");
|
|
72
69
|
}
|
|
73
70
|
return ret;
|
|
74
71
|
}
|
|
75
72
|
|
|
76
73
|
/**
|
|
74
|
+
* @param {object} adapter
|
|
77
75
|
* @param {string} timeVal
|
|
78
76
|
* @param {string} timeLimit
|
|
79
77
|
*/
|
|
@@ -93,16 +91,13 @@ function IsEqual(adapter, timeVal, timeLimit) {
|
|
|
93
91
|
ret = true;
|
|
94
92
|
adapter.log.debug("yes, IsEqual : " + timeVal + " " + timeLimit);
|
|
95
93
|
}
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
94
|
+
} else {
|
|
98
95
|
adapter.log.error("string does not contain : " + timeVal + " " + timeLimit);
|
|
99
96
|
}
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
97
|
+
} else {
|
|
102
98
|
adapter.log.error("not a string " + typeof timeVal + " " + typeof timeLimit);
|
|
103
99
|
}
|
|
104
|
-
}
|
|
105
|
-
catch (e) {
|
|
100
|
+
} catch (e) {
|
|
106
101
|
adapter.log.error("exception in IsEqual [" + e + "]");
|
|
107
102
|
}
|
|
108
103
|
return ret;
|
|
@@ -183,25 +178,22 @@ function findObjectsIdByKey(array, key, value) {
|
|
|
183
178
|
}
|
|
184
179
|
|
|
185
180
|
|
|
186
|
-
function timeConverter(SystemLanguage,time, timeonly = false) {
|
|
181
|
+
function timeConverter(SystemLanguage, time, timeonly = false) {
|
|
187
182
|
|
|
188
183
|
let a;
|
|
189
184
|
|
|
190
185
|
if (time != null) {
|
|
191
186
|
a = new Date(time);
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
187
|
+
} else {
|
|
194
188
|
a = new Date();
|
|
195
189
|
}
|
|
196
190
|
let months;
|
|
197
191
|
|
|
198
192
|
if (SystemLanguage === "de") {
|
|
199
193
|
months = ["Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"];
|
|
200
|
-
}
|
|
201
|
-
else if (SystemLanguage === "en") {
|
|
194
|
+
} else if (SystemLanguage === "en") {
|
|
202
195
|
months = ["Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"];
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
196
|
+
} else {
|
|
205
197
|
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
206
198
|
}
|
|
207
199
|
|
|
@@ -219,8 +211,7 @@ function timeConverter(SystemLanguage,time, timeonly = false) {
|
|
|
219
211
|
let sRet = "";
|
|
220
212
|
if (timeonly) {
|
|
221
213
|
sRet = shour + ":" + smin + ":" + ssec;
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
214
|
+
} else {
|
|
224
215
|
sRet = sdate + " " + month + " " + year.toString() + " " + shour + ":" + smin + ":" + ssec;
|
|
225
216
|
}
|
|
226
217
|
|
|
@@ -234,25 +225,20 @@ function CheckValidTime(adapter, id, time) {
|
|
|
234
225
|
if (time === "null" || time === undefined) {
|
|
235
226
|
adapter.log.error("time value not found for " + id);
|
|
236
227
|
|
|
237
|
-
}
|
|
238
|
-
else if (typeof time !== "string") {
|
|
228
|
+
} else if (typeof time !== "string") {
|
|
239
229
|
adapter.log.error("time should be a string but is " + typeof time.val + " for " + id);
|
|
240
230
|
|
|
241
|
-
}
|
|
242
|
-
else if (time.length < 3) {
|
|
231
|
+
} else if (time.length < 3) {
|
|
243
232
|
adapter.log.error("time not long enough for " + id);
|
|
244
233
|
|
|
245
|
-
}
|
|
246
|
-
else if (!time.includes(":")) {
|
|
234
|
+
} else if (!time.includes(":")) {
|
|
247
235
|
adapter.log.error("time ':' missing for " + id);
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
236
|
+
} else {
|
|
250
237
|
const times = time.split(":");
|
|
251
238
|
sRet = "0" + times[0].slice(-2) + ":" + "0" + times[1].slice(-2);
|
|
252
239
|
}
|
|
253
240
|
|
|
254
|
-
}
|
|
255
|
-
catch (e) {
|
|
241
|
+
} catch (e) {
|
|
256
242
|
adapter.log.error("exception in CheckValidTime [" + e + "] for " + id + " " + JSON.stringify(time));
|
|
257
243
|
|
|
258
244
|
}
|
|
@@ -277,13 +263,11 @@ function Check4ValidTemperature(adapter, temperature) {
|
|
|
277
263
|
|
|
278
264
|
adapter.log.debug("try to convert " + temperature + " to a number");
|
|
279
265
|
return Number(temperature);
|
|
280
|
-
}
|
|
281
|
-
else {
|
|
266
|
+
} else {
|
|
282
267
|
return temperature;
|
|
283
268
|
}
|
|
284
269
|
|
|
285
|
-
}
|
|
286
|
-
catch (e) {
|
|
270
|
+
} catch (e) {
|
|
287
271
|
adapter.log.error("exception in Check4ValidTemperature [" + e + "]");
|
|
288
272
|
return 0;
|
|
289
273
|
}
|
|
@@ -322,8 +306,7 @@ function IsSummerTime(adapter, sStartDate, sEndDate) {
|
|
|
322
306
|
//end already past, increase end year
|
|
323
307
|
EndDate.setFullYear(EndDate.getFullYear() + 1);
|
|
324
308
|
adapter.log.debug("corrected End " + EndDate.toDateString());
|
|
325
|
-
}
|
|
326
|
-
else {
|
|
309
|
+
} else {
|
|
327
310
|
//else decrease Start year
|
|
328
311
|
StartDate.setFullYear(StartDate.getFullYear() - 1);
|
|
329
312
|
adapter.log.debug("corrected Start " + StartDate.toDateString());
|
|
@@ -333,15 +316,13 @@ function IsSummerTime(adapter, sStartDate, sEndDate) {
|
|
|
333
316
|
if (now >= StartDate && now <= EndDate) {
|
|
334
317
|
adapter.log.debug("we are in period");
|
|
335
318
|
ret = true;
|
|
336
|
-
}
|
|
337
|
-
else {
|
|
319
|
+
} else {
|
|
338
320
|
adapter.log.debug("we are not in period, after start " + StartDate.toDateString() + " and before end " + EndDate.toDateString());
|
|
339
321
|
ret = false;
|
|
340
322
|
}
|
|
341
323
|
}
|
|
342
324
|
}
|
|
343
|
-
}
|
|
344
|
-
catch (e) {
|
|
325
|
+
} catch (e) {
|
|
345
326
|
adapter.log.error("exception catch in IsSummerTime [" + e + "] ");
|
|
346
327
|
}
|
|
347
328
|
return ret;
|
package/lib/tools.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const axios = require("axios");
|
|
2
2
|
|
|
3
|
+
//Tests whether the given variable is a real object and not an Array
|
|
3
4
|
/**
|
|
4
|
-
* Tests whether the given variable is a real object and not an Array
|
|
5
5
|
* @param {any} it The variable to test
|
|
6
6
|
* @returns {it is Record<string, any>}
|
|
7
7
|
*/
|
|
@@ -13,18 +13,20 @@ function isObject(it) {
|
|
|
13
13
|
return Object.prototype.toString.call(it) === "[object Object]";
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
// Tests whether the given variable is really an Array
|
|
16
17
|
/**
|
|
17
|
-
* Tests whether the given variable is really an Array
|
|
18
18
|
* @param {any} it The variable to test
|
|
19
19
|
* @returns {it is any[]}
|
|
20
20
|
*/
|
|
21
21
|
function isArray(it) {
|
|
22
|
-
if (typeof Array.isArray === "function")
|
|
22
|
+
if (typeof Array.isArray === "function") {
|
|
23
|
+
return Array.isArray(it);
|
|
24
|
+
}
|
|
23
25
|
return Object.prototype.toString.call(it) === "[object Array]";
|
|
24
26
|
}
|
|
25
27
|
|
|
28
|
+
//Translates text to the target language. Automatically chooses the right translation API.
|
|
26
29
|
/**
|
|
27
|
-
* Translates text to the target language. Automatically chooses the right translation API.
|
|
28
30
|
* @param {string} text The text to translate
|
|
29
31
|
* @param {string} targetLang The target languate
|
|
30
32
|
* @param {string} [yandexApiKey] The yandex API key. You can create one for free at https://translate.yandex.com/developers
|
|
@@ -43,8 +45,8 @@ async function translateText(text, targetLang, yandexApiKey) {
|
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
|
|
48
|
+
//Translates text with Yandex API
|
|
46
49
|
/**
|
|
47
|
-
* Translates text with Yandex API
|
|
48
50
|
* @param {string} text The text to translate
|
|
49
51
|
* @param {string} targetLang The target languate
|
|
50
52
|
* @param {string} apiKey The yandex API key. You can create one for free at https://translate.yandex.com/developers
|
|
@@ -66,8 +68,8 @@ async function translateYandex(text, targetLang, apiKey) {
|
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
|
|
71
|
+
//Translates text with Google API
|
|
69
72
|
/**
|
|
70
|
-
* Translates text with Google API
|
|
71
73
|
* @param {string} text The text to translate
|
|
72
74
|
* @param {string} targetLang The target languate
|
|
73
75
|
* @returns {Promise<string>}
|
package/main.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable prefer-template */
|
|
1
2
|
/*
|
|
2
3
|
* AMTRON wallbox adapter für iobroker
|
|
3
4
|
*
|
|
@@ -41,8 +42,7 @@ function startAdapter(options) {
|
|
|
41
42
|
try {
|
|
42
43
|
//adapter.log.debug('start');
|
|
43
44
|
main();
|
|
44
|
-
}
|
|
45
|
-
catch (e) {
|
|
45
|
+
} catch (e) {
|
|
46
46
|
adapter.log.error("exception catch after ready [" + e + "]");
|
|
47
47
|
}
|
|
48
48
|
},
|
|
@@ -56,6 +56,7 @@ function startAdapter(options) {
|
|
|
56
56
|
adapter && adapter.log && adapter.log.info && adapter.log.info("cleaned everything up...");
|
|
57
57
|
callback();
|
|
58
58
|
} catch (e) {
|
|
59
|
+
adapter.log.error("exception catch after unload [" + e + "]");
|
|
59
60
|
callback();
|
|
60
61
|
}
|
|
61
62
|
},
|
|
@@ -89,8 +90,7 @@ async function main() {
|
|
|
89
90
|
let readInterval = 15;
|
|
90
91
|
if (parseInt(adapter.config.readInterval) > 0) {
|
|
91
92
|
readInterval = adapter.config.readInterval;
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
93
|
+
} else {
|
|
94
94
|
adapter.log.warn("read interval not defined");
|
|
95
95
|
}
|
|
96
96
|
adapter.log.debug("read every " + readInterval + " minutes");
|
|
@@ -103,7 +103,7 @@ async function main() {
|
|
|
103
103
|
|
|
104
104
|
async function Do() {
|
|
105
105
|
|
|
106
|
-
adapter.log.debug("starting ... "
|
|
106
|
+
adapter.log.debug("starting ... ");
|
|
107
107
|
|
|
108
108
|
await ReadData();
|
|
109
109
|
|
|
@@ -112,22 +112,18 @@ async function Do() {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
|
|
115
|
-
async function ReadData(){
|
|
115
|
+
async function ReadData() {
|
|
116
116
|
|
|
117
117
|
for (const system of adapter.config.WallboxSystems) {
|
|
118
118
|
|
|
119
119
|
if (system.IsActive) {
|
|
120
120
|
if (system.Type === "ChargeControl") {
|
|
121
121
|
await read_rest(system);
|
|
122
|
-
}
|
|
123
|
-
else if (system.Type === "Compact") {
|
|
122
|
+
} else if (system.Type === "Compact") {
|
|
124
123
|
await read_MHCP(system);
|
|
125
|
-
}
|
|
126
|
-
else if (system.Type === "Xtra") {
|
|
124
|
+
} else if (system.Type === "Xtra") {
|
|
127
125
|
await read_MHCP(system);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
else {
|
|
126
|
+
} else {
|
|
131
127
|
//system type ChargeControl string not yet implemented
|
|
132
128
|
adapter.log.warn("system type " + system.Type + " " + typeof system.Type + " not yet implemented");
|
|
133
129
|
}
|
|
@@ -143,14 +139,14 @@ async function read_MHCP(system) {
|
|
|
143
139
|
|
|
144
140
|
|
|
145
141
|
/*
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
142
|
+
var abfrage_DevInfo = "curl -H 'Accept: application/json' http://10.0.1.28:25000/MHCP/1.0/DevInfo?DevKey=999999";
|
|
143
|
+
var abfrage_ChargeData = "curl -H 'Accept: application/json' http://10.0.1.28:25000/MHCP/1.0/ChargeData?DevKey=999999";
|
|
144
|
+
var abfrage_Statistics_Day = "curl -H 'Accept: application/json' http://10.0.1.28:25000/MHCP/1.0/Statistics/Day?DevKey=999999";
|
|
145
|
+
var abfrage_Statistics_Week = "curl -H 'Accept: application/json' http://10.0.1.28:25000/MHCP/1.0/Statistics/Week?DevKey=999999";
|
|
146
|
+
var abfrage_Statistics_Month = "curl -H 'Accept: application/json' http://10.0.1.28:25000/MHCP/1.0/Statistics/Month?DevKey=999999";
|
|
147
|
+
var abfrage_Statistics_Year = "curl -H 'Accept: application/json' http://10.0.1.28:25000/MHCP/1.0/Statistics/Year?DevKey=999999";
|
|
148
|
+
var abfrage_Statistics_Annual = "curl -H 'Accept: application/json' http://10.0.1.28:25000/MHCP/1.0/Statistics/Annual?DevKey=999999";
|
|
149
|
+
*/
|
|
154
150
|
|
|
155
151
|
await read_MHCP_DevInfo(system);
|
|
156
152
|
|
|
@@ -162,8 +158,7 @@ async function read_MHCP(system) {
|
|
|
162
158
|
await read_MHCP_StatisticData(system, "Year");
|
|
163
159
|
await read_MHCP_StatisticData(system, "Annual");
|
|
164
160
|
|
|
165
|
-
}
|
|
166
|
-
catch (e) {
|
|
161
|
+
} catch (e) {
|
|
167
162
|
adapter.log.error("exception in read_MHCP [" + e + "]");
|
|
168
163
|
}
|
|
169
164
|
}
|
|
@@ -172,8 +167,8 @@ async function read_MHCP_DevInfo(system) {
|
|
|
172
167
|
//Retrieves information about the wallbox.
|
|
173
168
|
try {
|
|
174
169
|
/*
|
|
175
|
-
|
|
176
|
-
|
|
170
|
+
var abfrage_DevInfo = "curl -H 'Accept: application/json' http://10.0.1.28:25000/MHCP/1.0/DevInfo?DevKey=999999";
|
|
171
|
+
*/
|
|
177
172
|
|
|
178
173
|
const sURL = "http://" + system.IPAddress + ":25000/MHCP/1.0/DevInfo?DevKey=" + system.ApiKey;
|
|
179
174
|
|
|
@@ -234,8 +229,7 @@ async function read_MHCP_DevInfo(system) {
|
|
|
234
229
|
await adapter.setStateAsync(SystemName + ".info." + entry, { ack: true, val: buffer.data[entry] });
|
|
235
230
|
}
|
|
236
231
|
}
|
|
237
|
-
}
|
|
238
|
-
catch (e) {
|
|
232
|
+
} catch (e) {
|
|
239
233
|
adapter.log.error("exception in read_MHCP_DevInfo [" + e + "]");
|
|
240
234
|
}
|
|
241
235
|
}
|
|
@@ -244,8 +238,8 @@ async function read_MHCP_ChargeData(system) {
|
|
|
244
238
|
//Retrieves charge information about the wallbox.
|
|
245
239
|
try {
|
|
246
240
|
/*
|
|
247
|
-
|
|
248
|
-
|
|
241
|
+
var abfrage_ChargeData = "curl -H 'Accept: application/json' http://10.0.1.28:25000/MHCP/1.0/ChargeData?DevKey=999999";
|
|
242
|
+
*/
|
|
249
243
|
|
|
250
244
|
const sURL = "http://" + system.IPAddress + ":25000/MHCP/1.0/ChargeData?DevKey=" + system.ApiKey;
|
|
251
245
|
|
|
@@ -328,14 +322,12 @@ async function read_MHCP_ChargeData(system) {
|
|
|
328
322
|
|| entry == "TExcessNrg"
|
|
329
323
|
) {
|
|
330
324
|
//do nothing
|
|
331
|
-
}
|
|
332
|
-
else {
|
|
325
|
+
} else {
|
|
333
326
|
await adapter.setStateAsync(SystemName + ".charge." + entry, { ack: true, val: buffer.data[entry] });
|
|
334
327
|
}
|
|
335
328
|
}
|
|
336
329
|
}
|
|
337
|
-
}
|
|
338
|
-
catch (e) {
|
|
330
|
+
} catch (e) {
|
|
339
331
|
adapter.log.error("exception in read_MHCP_DevInfo [" + e + "]");
|
|
340
332
|
}
|
|
341
333
|
}
|
|
@@ -345,13 +337,13 @@ async function read_MHCP_StatisticData(system, period) {
|
|
|
345
337
|
//Retrieves statistic about the wallbox.
|
|
346
338
|
try {
|
|
347
339
|
/*
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
340
|
+
var abfrage_Statistics_Day = "curl -H 'Accept: application/json' http://10.0.1.28:25000/MHCP/1.0/Statistics/Day?DevKey=999999";
|
|
341
|
+
var abfrage_Statistics_Week = "curl -H 'Accept: application/json' http://10.0.1.28:25000/MHCP/1.0/Statistics/Week?DevKey=999999";
|
|
342
|
+
var abfrage_Statistics_Month = "curl -H 'Accept: application/json' http://10.0.1.28:25000/MHCP/1.0/Statistics/Month?DevKey=999999";
|
|
343
|
+
var abfrage_Statistics_Year = "curl -H 'Accept: application/json' http://10.0.1.28:25000/MHCP/1.0/Statistics/Year?DevKey=999999";
|
|
344
|
+
var abfrage_Statistics_Annual = "curl -H 'Accept: application/json' http://10.0.1.28:25000/MHCP/1.0/Statistics/Annual?DevKey=999999";
|
|
353
345
|
|
|
354
|
-
|
|
346
|
+
*/
|
|
355
347
|
|
|
356
348
|
const sURL = "http://" + system.IPAddress + ":25000/MHCP/1.0/Statistics/" + period + "?DevKey=" + system.ApiKey;
|
|
357
349
|
|
|
@@ -377,32 +369,29 @@ async function read_MHCP_StatisticData(system, period) {
|
|
|
377
369
|
|
|
378
370
|
if (period == "Annual") {
|
|
379
371
|
await adapter.setStateAsync(SystemName + ".Statistics." + period + ".Years", { ack: true, val: JSON.stringify(buffer.data) });
|
|
380
|
-
}
|
|
381
|
-
else {
|
|
372
|
+
} else {
|
|
382
373
|
for (const entry in buffer.data) {
|
|
383
374
|
|
|
384
375
|
if (entry == "TMaxCurrT1"
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
376
|
+
|| entry == "TBeginH_T1"
|
|
377
|
+
|| entry == "TBeginM_T1"
|
|
378
|
+
|| entry == "TPriceT1"
|
|
379
|
+
|| entry == "TMaxCurrT2"
|
|
380
|
+
|| entry == "TBeginH_T2"
|
|
381
|
+
|| entry == "TBeginM_T2"
|
|
382
|
+
|| entry == "TPriceT2"
|
|
383
|
+
|| entry == "TRemoteCurr"
|
|
384
|
+
|| entry == "TSolarPrice"
|
|
385
|
+
|| entry == "TExcessNrg"
|
|
395
386
|
) {
|
|
396
387
|
//do nothing
|
|
397
|
-
}
|
|
398
|
-
else {
|
|
388
|
+
} else {
|
|
399
389
|
await adapter.setStateAsync(SystemName + ".Statistics." + period + "." + entry, { ack: true, val: buffer.data[entry] });
|
|
400
390
|
}
|
|
401
391
|
}
|
|
402
392
|
}
|
|
403
393
|
}
|
|
404
|
-
}
|
|
405
|
-
catch (e) {
|
|
394
|
+
} catch (e) {
|
|
406
395
|
adapter.log.error("exception in read_MHCP_DevInfo [" + e + "]");
|
|
407
396
|
}
|
|
408
397
|
}
|
|
@@ -412,48 +401,48 @@ async function read_rest(system) {
|
|
|
412
401
|
try {
|
|
413
402
|
|
|
414
403
|
/*
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
404
|
+
http://192.168.3.18/rest/full_state
|
|
405
|
+
|
|
406
|
+
conn_state: no_vehicle_connected
|
|
407
|
+
auth_state: not_authorized_for_charging
|
|
408
|
+
auth_uid:
|
|
409
|
+
time_since_charging_start: 0
|
|
410
|
+
meter_wh: 16701
|
|
411
|
+
power_w: 0
|
|
412
|
+
transaction_wh: 0
|
|
413
|
+
cp_id: +49 * 839 * 00000000001
|
|
414
|
+
ocpp_state: available
|
|
415
|
+
type2_state: a
|
|
416
|
+
type2_proximity: cable_attached
|
|
417
|
+
sig_current: 0
|
|
418
|
+
schuko_state: idle
|
|
419
|
+
backend_conn_state: pending
|
|
420
|
+
free_charging: off
|
|
421
|
+
slave_state:
|
|
422
|
+
ocpp_meter_cfg: modbus_meter_nzr
|
|
423
|
+
ocpp_meter_serial: 00202035
|
|
424
|
+
current_a: 0.00, 0.00, 0.00
|
|
425
|
+
energy_man_current: 0
|
|
426
|
+
ambient_temp: +15.00
|
|
427
|
+
firmware_ver: 5.22.1 - 13295
|
|
428
|
+
cc_serial_n: 2202532503 / b94060010me2
|
|
429
|
+
con_cycles_schuko: 0
|
|
430
|
+
con_cycles_type2: 5
|
|
431
|
+
max_current: 16
|
|
432
|
+
rcmb_state: okay
|
|
433
|
+
rcmb_max_values: 0.0, 0.0
|
|
434
|
+
rcmb_current_values: 0.0, 0.0
|
|
435
|
+
cable_attached: on
|
|
436
|
+
schuko_cfg: disable
|
|
437
|
+
rcd_state: disable
|
|
438
|
+
mcb_type2_state: disable
|
|
439
|
+
mcb_schuko_state: disable
|
|
440
|
+
cp_vendor: MENNEKES
|
|
441
|
+
errors: no_errors
|
|
442
|
+
cp_model: CC612_2S0R_CC
|
|
443
|
+
display_text:
|
|
444
|
+
|
|
445
|
+
*/
|
|
457
446
|
|
|
458
447
|
const sURL = "http://" + system.IPAddress + "/rest/full_state";
|
|
459
448
|
|
|
@@ -473,8 +462,8 @@ async function read_rest(system) {
|
|
|
473
462
|
|
|
474
463
|
adapter.log.debug("got data status " + typeof buffer.data + " " + JSON.stringify(buffer.data));
|
|
475
464
|
/*
|
|
476
|
-
|
|
477
|
-
|
|
465
|
+
got data status string "conn_state:no_vehicle_connected\nauth_state:not_authorized_for_charging\nauth_uid:\ntime_since_charging_start:0\nmeter_wh:16701\npower_w:0\ntransaction_wh:0\ncp_id:+49*839*00000000001\nocpp_state:available\ntype2_state:a\ntype2_proximity:cable_attached\nsig_current:0\nschuko_state:idle\nbackend_conn_state:pending\nfree_charging:off\nslave_state:\nocpp_meter_cfg:modbus_meter_nzr\nocpp_meter_serial:00202035\ncurrent_a:0.00,0.00,0.00\nenergy_man_current:0\nambient_temp:+15.00\nfirmware_ver:5.22.1-13295\ncc_serial_n:2202532503/b94060010me2\ncon_cycles_schuko:0\ncon_cycles_type2:5\nmax_current:16\nrcmb_state:okay\nrcmb_max_values: 0.0, 0.0\nrcmb_current_values: 0.0, 0.0\ncable_attached:on\nschuko_cfg:disable\nrcd_state:disable\nmcb_type2_state:disable\nmcb_schuko_state:disable\ncp_vendor:MENNEKES\nerrors:no_errors\ncp_model:CC612_2S0R_CC\ndisplay_text:"
|
|
466
|
+
*/
|
|
478
467
|
|
|
479
468
|
const SystemName = system.Name.replace(adapter.FORBIDDEN_CHARS, "_");
|
|
480
469
|
|
|
@@ -499,7 +488,7 @@ async function read_rest(system) {
|
|
|
499
488
|
await adapter.setStateAsync(SystemName + ".SigCurrent", { ack: true, val: Number(data[11].split(":")[1]) });
|
|
500
489
|
await adapter.setStateAsync(SystemName + ".Schuko.State", { ack: true, val: data[12].split(":")[1] });
|
|
501
490
|
await adapter.setStateAsync(SystemName + ".Backend.ConnectionState", { ack: true, val: data[13].split(":")[1] });
|
|
502
|
-
await adapter.setStateAsync(SystemName + ".FreeCharging", { ack: true, val: Boolean(
|
|
491
|
+
await adapter.setStateAsync(SystemName + ".FreeCharging", { ack: true, val: Boolean(data[14].split(":")[1]) });
|
|
503
492
|
await adapter.setStateAsync(SystemName + ".SlaveState", { ack: true, val: data[15].split(":")[1] });
|
|
504
493
|
await adapter.setStateAsync(SystemName + ".OCPP.MeterConfig", { ack: true, val: data[16].split(":")[1] });
|
|
505
494
|
await adapter.setStateAsync(SystemName + ".OCPP.MeterSerial", { ack: true, val: data[17].split(":")[1] });
|
|
@@ -525,30 +514,28 @@ async function read_rest(system) {
|
|
|
525
514
|
await adapter.setStateAsync(SystemName + ".DisplayText", { ack: true, val: data[37].split(":")[1] });
|
|
526
515
|
|
|
527
516
|
/*
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
517
|
+
amtronwallbox.0 2022-05-20 12:20:53.613 info State value to set for "amtronwallbox.0.Wallbox.CableAttached" has to be type "boolean" but received type "string"
|
|
518
|
+
amtronwallbox.0 2022-05-20 12:20:53.594 info State value to set for "amtronwallbox.0.Wallbox.MaxCurrent" has to be type "number" but received type "string"
|
|
519
|
+
amtronwallbox.0 2022-05-20 12:20:53.545 info State value to set for "amtronwallbox.0.Wallbox.ContactcyclesType2" has to be type "number" but received type "string"
|
|
520
|
+
amtronwallbox.0 2022-05-20 12:20:53.486 info State value to set for "amtronwallbox.0.Wallbox.ContactCyclesSchuko" has to be type "number" but received type "string"
|
|
521
|
+
amtronwallbox.0 2022-05-20 12:20:53.449 info State value to set for "amtronwallbox.0.Wallbox.EnergyManagerCurrent" has to be type "number" but received type "string"
|
|
522
|
+
amtronwallbox.0 2022-05-20 12:20:53.406 info State value to set for "amtronwallbox.0.Wallbox.Current" has to be type "number" but received type "string"
|
|
523
|
+
amtronwallbox.0 2022-05-20 12:20:53.392 info State value to set for "amtronwallbox.0.Wallbox.FreeCharging" has to be type "boolean" but received type "string"
|
|
524
|
+
amtronwallbox.0 2022-05-20 12:20:53.342 info State value to set for "amtronwallbox.0.Wallbox.SigCurrent" has to be type "number" but received type "string"
|
|
525
|
+
amtronwallbox.0 2022-05-20 12:20:53.324 info State value to set for "amtronwallbox.0.Wallbox.Transaction" has to be type "number" but received type "string"
|
|
526
|
+
amtronwallbox.0 2022-05-20 12:20:53.319 info State value to set for "amtronwallbox.0.Wallbox.Power" has to be type "number" but received type "string"
|
|
527
|
+
amtronwallbox.0 2022-05-20 12:20:53.313 info State value to set for "amtronwallbox.0.Wallbox.Meter" has to be type "number" but received type "string"
|
|
528
|
+
amtronwallbox.0 2022-05-20 12:20:53.268 info State value to set for "amtronwallbox.0.Wallbox.TimeSinceChargingStart" has to be type "number" but received type "string"
|
|
540
529
|
|
|
541
|
-
|
|
530
|
+
*/
|
|
542
531
|
|
|
543
532
|
|
|
544
|
-
}
|
|
545
|
-
else {
|
|
533
|
+
} else {
|
|
546
534
|
adapter.log.error("error status: " + JSON.stringify(buffer));
|
|
547
535
|
}
|
|
548
536
|
|
|
549
537
|
|
|
550
|
-
}
|
|
551
|
-
catch (e) {
|
|
538
|
+
} catch (e) {
|
|
552
539
|
adapter.log.error("exception in read_rest [" + e + "]");
|
|
553
540
|
}
|
|
554
541
|
}
|
|
@@ -579,18 +566,16 @@ async function HandleStateChange(id, state) {
|
|
|
579
566
|
if (ids[3] === "info") {
|
|
580
567
|
await updateInfo(id, state);
|
|
581
568
|
adapter.setForeignState(id, { ack: true });
|
|
582
|
-
}
|
|
583
|
-
else if (ids[3] === "charge") {
|
|
569
|
+
} else if (ids[3] === "charge") {
|
|
584
570
|
await updateCharge(id, state);
|
|
585
571
|
adapter.setForeignState(id, { ack: true });
|
|
586
|
-
}
|
|
587
|
-
else {
|
|
572
|
+
} else {
|
|
588
573
|
adapter.log.warn("unhandled state change " + id);
|
|
589
574
|
}
|
|
590
575
|
}
|
|
591
576
|
}
|
|
592
577
|
|
|
593
|
-
async function updateInfo(id,state) {
|
|
578
|
+
async function updateInfo(id, state) {
|
|
594
579
|
|
|
595
580
|
const systemName = id.split(".")[2];
|
|
596
581
|
|
|
@@ -601,15 +586,11 @@ async function updateInfo(id,state) {
|
|
|
601
586
|
if (SystemName == systemName && system.IsActive) {
|
|
602
587
|
if (system.Type === "ChargeControl") {
|
|
603
588
|
//nothing to do
|
|
604
|
-
}
|
|
605
|
-
else if (system.Type === "Compact") {
|
|
606
|
-
await write_MHCP_DevInfo(system, id,state);
|
|
607
|
-
}
|
|
608
|
-
else if (system.Type === "Xtra") {
|
|
589
|
+
} else if (system.Type === "Compact") {
|
|
609
590
|
await write_MHCP_DevInfo(system, id, state);
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
else {
|
|
591
|
+
} else if (system.Type === "Xtra") {
|
|
592
|
+
await write_MHCP_DevInfo(system, id, state);
|
|
593
|
+
} else {
|
|
613
594
|
//system type ChargeControl string not yet implemented
|
|
614
595
|
adapter.log.warn("system type " + system.Type + " " + typeof system.Type + " not yet implemented");
|
|
615
596
|
}
|
|
@@ -628,15 +609,11 @@ async function updateCharge(id, state) {
|
|
|
628
609
|
if (SystemName == systemName && system.IsActive) {
|
|
629
610
|
if (system.Type === "ChargeControl") {
|
|
630
611
|
//nothing to do
|
|
631
|
-
}
|
|
632
|
-
else if (system.Type === "Compact") {
|
|
612
|
+
} else if (system.Type === "Compact") {
|
|
633
613
|
await write_MHCP_ChargeData(system, id, state);
|
|
634
|
-
}
|
|
635
|
-
else if (system.Type === "Xtra") {
|
|
614
|
+
} else if (system.Type === "Xtra") {
|
|
636
615
|
await write_MHCP_ChargeData(system, id, state);
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
else {
|
|
616
|
+
} else {
|
|
640
617
|
//system type ChargeControl string not yet implemented
|
|
641
618
|
adapter.log.warn("system type " + system.Type + " " + typeof system.Type + " not yet implemented");
|
|
642
619
|
}
|
|
@@ -659,14 +636,14 @@ async function write_MHCP_DevInfo(system, id, state) {
|
|
|
659
636
|
const param = id.split(".")[4];
|
|
660
637
|
|
|
661
638
|
const data = {
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
639
|
+
DevName: param == "DevName" ? state.val : null,
|
|
640
|
+
LocTime: param == "LocTime" ? state.val : null,
|
|
641
|
+
Summer: param == "Summer" ? state.val : null,
|
|
642
|
+
Tz: param == "Tz" ? state.val : null,
|
|
643
|
+
FixedVehCosts: param == "FixedVehCosts" ? state.val : null,
|
|
644
|
+
OldVehCosts: param == "OldVehCosts" ? state.val : null,
|
|
645
|
+
Battery: param == "Battery" ? state.val : null,
|
|
646
|
+
DevMode: param == "DevMode" ? state.val : null,
|
|
670
647
|
};
|
|
671
648
|
|
|
672
649
|
adapter.log.debug("URL " + sURL.replace(/DevKey=.*/, "DevKey=******") + " data " + JSON.stringify(data));
|
|
@@ -677,8 +654,7 @@ async function write_MHCP_DevInfo(system, id, state) {
|
|
|
677
654
|
adapter.log.debug("got result " + typeof buffer.data + " " + JSON.stringify(buffer.data));
|
|
678
655
|
|
|
679
656
|
|
|
680
|
-
}
|
|
681
|
-
catch (e) {
|
|
657
|
+
} catch (e) {
|
|
682
658
|
adapter.log.error("exception in write_MHCP_DevInfo [" + e + "]");
|
|
683
659
|
}
|
|
684
660
|
}
|
|
@@ -698,11 +674,11 @@ async function write_MHCP_ChargeData(system, id, state) {
|
|
|
698
674
|
const param = id.split(".")[4];
|
|
699
675
|
|
|
700
676
|
const data = {
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
677
|
+
Permanent: true,
|
|
678
|
+
RemoteCurr: param == "RemoteCurr" ? state.val : null,
|
|
679
|
+
AutoChg: param == "AutoChg" ? state.val : null,
|
|
680
|
+
ChgState: param == "ChgState" ? state.val : null,
|
|
681
|
+
Uid: param == "Uid" ? state.val : null,
|
|
706
682
|
};
|
|
707
683
|
|
|
708
684
|
adapter.log.debug("URL " + sURL.replace(/DevKey=.*/, "DevKey=******") + " data " + JSON.stringify(data));
|
|
@@ -713,8 +689,7 @@ async function write_MHCP_ChargeData(system, id, state) {
|
|
|
713
689
|
adapter.log.debug("got result " + typeof buffer.data + " " + JSON.stringify(buffer.data));
|
|
714
690
|
|
|
715
691
|
|
|
716
|
-
}
|
|
717
|
-
catch (e) {
|
|
692
|
+
} catch (e) {
|
|
718
693
|
adapter.log.error("exception in write_MHCP_ChargeData [" + e + "]");
|
|
719
694
|
}
|
|
720
695
|
}
|
|
@@ -725,11 +700,9 @@ function subscribeVars() {
|
|
|
725
700
|
if (system.IsActive) {
|
|
726
701
|
if (system.Type === "ChargeControl") {
|
|
727
702
|
//nothing to do
|
|
728
|
-
}
|
|
729
|
-
else if (system.Type === "Compact") {
|
|
703
|
+
} else if (system.Type === "Compact") {
|
|
730
704
|
//nothing to do
|
|
731
|
-
}
|
|
732
|
-
else if (system.Type === "Xtra") {
|
|
705
|
+
} else if (system.Type === "Xtra") {
|
|
733
706
|
|
|
734
707
|
const SystemName = system.Name.replace(adapter.FORBIDDEN_CHARS, "_");
|
|
735
708
|
|
|
@@ -759,9 +732,7 @@ function subscribeVars() {
|
|
|
759
732
|
//https://github.com/lephisto/amtron/blob/master/docs/api/Whitelist/post.md
|
|
760
733
|
|
|
761
734
|
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
else {
|
|
735
|
+
} else {
|
|
765
736
|
//system type ChargeControl string not yet implemented
|
|
766
737
|
adapter.log.warn("system type " + system.Type + " " + typeof system.Type + " not yet implemented");
|
|
767
738
|
}
|
|
@@ -781,15 +752,11 @@ async function checkVariables() {
|
|
|
781
752
|
if (system.IsActive) {
|
|
782
753
|
if (system.Type === "ChargeControl") {
|
|
783
754
|
await checkVariables_rest(system);
|
|
784
|
-
}
|
|
785
|
-
else if (system.Type === "Compact") {
|
|
755
|
+
} else if (system.Type === "Compact") {
|
|
786
756
|
//nothing to do
|
|
787
|
-
}
|
|
788
|
-
else if (system.Type === "Xtra") {
|
|
757
|
+
} else if (system.Type === "Xtra") {
|
|
789
758
|
await checkVariables_MHCP(system);
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
else {
|
|
759
|
+
} else {
|
|
793
760
|
//system type ChargeControl string not yet implemented
|
|
794
761
|
adapter.log.warn("system type " + system.Type + " " + typeof system.Type + " not yet implemented");
|
|
795
762
|
}
|
|
@@ -1539,11 +1506,11 @@ async function checkVariables_MHCP(system) {
|
|
|
1539
1506
|
|
|
1540
1507
|
const SystemName = system.Name.replace(adapter.FORBIDDEN_CHARS, "_");
|
|
1541
1508
|
|
|
1542
|
-
key = SystemName
|
|
1509
|
+
key = SystemName;
|
|
1543
1510
|
obj = {
|
|
1544
1511
|
type: "channel",
|
|
1545
1512
|
common: {
|
|
1546
|
-
name: "Wallbox "
|
|
1513
|
+
name: "Wallbox " + SystemName,
|
|
1547
1514
|
role: "",
|
|
1548
1515
|
}
|
|
1549
1516
|
};
|
|
@@ -2335,7 +2302,7 @@ async function checkVariables_MHCP_Statistic(system, period) {
|
|
|
2335
2302
|
common: {
|
|
2336
2303
|
name: "Amount of Wh",
|
|
2337
2304
|
type: "number",
|
|
2338
|
-
unit:"Wh",
|
|
2305
|
+
unit: "Wh",
|
|
2339
2306
|
role: "value.energy",
|
|
2340
2307
|
read: true,
|
|
2341
2308
|
write: false
|
|
@@ -2503,12 +2470,12 @@ async function CreateObject(key, obj) {
|
|
|
2503
2470
|
if (obj_new != null) {
|
|
2504
2471
|
|
|
2505
2472
|
if ((obj_new.common.role != obj.common.role
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2473
|
+
|| obj_new.common.type != obj.common.type
|
|
2474
|
+
|| (obj_new.common.unit != obj.common.unit && obj.common.unit != null)
|
|
2475
|
+
|| obj_new.common.read != obj.common.read
|
|
2476
|
+
|| obj_new.common.write != obj.common.write
|
|
2477
|
+
|| obj_new.common.name != obj.common.name)
|
|
2478
|
+
&& obj.type === "state"
|
|
2512
2479
|
) {
|
|
2513
2480
|
adapter.log.warn("change object " + JSON.stringify(obj) + " " + JSON.stringify(obj_new));
|
|
2514
2481
|
await adapter.extendObject(key, {
|
|
@@ -2522,8 +2489,7 @@ async function CreateObject(key, obj) {
|
|
|
2522
2489
|
}
|
|
2523
2490
|
});
|
|
2524
2491
|
}
|
|
2525
|
-
}
|
|
2526
|
-
else {
|
|
2492
|
+
} else {
|
|
2527
2493
|
await adapter.setObjectNotExistsAsync(key, obj);
|
|
2528
2494
|
}
|
|
2529
2495
|
}
|
|
@@ -2572,8 +2538,7 @@ function CronCreate(Minute, callback) {
|
|
|
2572
2538
|
cronString = "5 23 * * *";
|
|
2573
2539
|
//just for logging
|
|
2574
2540
|
Minute = "late evening";
|
|
2575
|
-
}
|
|
2576
|
-
else {
|
|
2541
|
+
} else {
|
|
2577
2542
|
|
|
2578
2543
|
cronString = "*/" + Minute + " * * * * ";
|
|
2579
2544
|
}
|
|
@@ -2590,8 +2555,7 @@ function CronCreate(Minute, callback) {
|
|
|
2590
2555
|
timezone
|
|
2591
2556
|
);
|
|
2592
2557
|
|
|
2593
|
-
}
|
|
2594
|
-
catch (e) {
|
|
2558
|
+
} catch (e) {
|
|
2595
2559
|
adapter.log.error("exception in CronCreate [" + e + "]");
|
|
2596
2560
|
}
|
|
2597
2561
|
}
|
|
@@ -2605,20 +2569,18 @@ function CronStatus() {
|
|
|
2605
2569
|
length = cronJobs.length;
|
|
2606
2570
|
//adapter.log.debug("cron jobs");
|
|
2607
2571
|
for (n = 0; n < length; n++) {
|
|
2608
|
-
if (
|
|
2572
|
+
if (cronJobs[n] !== undefined && cronJobs[n] != null) {
|
|
2609
2573
|
adapter.log.debug("cron status = " + cronJobs[n].running + " next event: " + timeConverter("DE", cronJobs[n].nextDate()));
|
|
2610
2574
|
}
|
|
2611
2575
|
}
|
|
2612
2576
|
|
|
2613
2577
|
if (length > 500) {
|
|
2614
2578
|
adapter.log.warn("more then 500 cron jobs existing for this adapter, this might be a configuration error! (" + length + ")");
|
|
2615
|
-
}
|
|
2616
|
-
else {
|
|
2579
|
+
} else {
|
|
2617
2580
|
adapter.log.info(length + " cron job(s) created");
|
|
2618
2581
|
}
|
|
2619
2582
|
}
|
|
2620
|
-
}
|
|
2621
|
-
catch (e) {
|
|
2583
|
+
} catch (e) {
|
|
2622
2584
|
adapter.log.error("exception in getCronStat [" + e + "] : " + n + " of " + length);
|
|
2623
2585
|
}
|
|
2624
2586
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iobroker.amtronwallbox",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "ioBroker Adapter for AMTRON wallboxes",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "René G.",
|
|
@@ -21,22 +21,23 @@
|
|
|
21
21
|
"url": "https://github.com/rg-engineering/ioBroker.amtronwallbox"
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
|
-
"node": ">=
|
|
24
|
+
"node": ">= 20"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@iobroker/adapter-core": "^3.2.3",
|
|
28
|
-
"axios": "^1.
|
|
29
|
-
"cron": "^
|
|
28
|
+
"axios": "^1.10.0",
|
|
29
|
+
"cron": "^4.3.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@alcalzone/release-script": "^3.8.0",
|
|
33
33
|
"@alcalzone/release-script-plugin-iobroker": "^3.7.2",
|
|
34
34
|
"@alcalzone/release-script-plugin-license": "^3.7.0",
|
|
35
35
|
"@alcalzone/release-script-plugin-manual-review": "^3.7.0",
|
|
36
|
-
"@iobroker/adapter-dev": "^1.
|
|
37
|
-
"@iobroker/
|
|
38
|
-
"
|
|
39
|
-
"
|
|
36
|
+
"@iobroker/adapter-dev": "^1.4.0",
|
|
37
|
+
"@iobroker/eslint-config": "^2.0.2",
|
|
38
|
+
"@iobroker/testing": "^5.0.4",
|
|
39
|
+
"chai": "^5.2.0",
|
|
40
|
+
"mocha": "^11.7.1"
|
|
40
41
|
},
|
|
41
42
|
"main": "main.js",
|
|
42
43
|
"bugs": {
|
|
@@ -66,7 +67,7 @@
|
|
|
66
67
|
"test:package": "mocha test/package --exit",
|
|
67
68
|
"test:unit": "mocha test/unit --exit",
|
|
68
69
|
"test:integration": "mocha test/integration --exit",
|
|
69
|
-
"lint": "eslint",
|
|
70
|
+
"lint": "eslint -c eslint.config.mjs .",
|
|
70
71
|
"translate": "translate-adapter",
|
|
71
72
|
"release": "release-script"
|
|
72
73
|
}
|
|
File without changes
|