iobroker.amtronwallbox 0.2.13 → 0.2.15

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022-2023 rg-engineering info@rg-engineering.eu
3
+ Copyright (c) 2022-2024 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,13 @@ 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.2.15 (2024-05-28)
58
+ * (René) change of dependencies
59
+ * (René) show cron job in log after creation
60
+
61
+ ### 0.2.14 (2024-01-12)
62
+ * (René) dependencies updated
63
+
57
64
  ### 0.2.13 (2023-12-23)
58
65
  * (René) just a sentry test
59
66
 
@@ -104,7 +111,7 @@ Note: Since the boxes have different interfaces, it may be that not all interfac
104
111
  ## License
105
112
  MIT License
106
113
 
107
- Copyright (c) 2022-2023 rg-engineering info@rg-engineering.eu
114
+ Copyright (c) 2022-2024 René G. <info@rg-engineering.eu>
108
115
 
109
116
  Permission is hereby granted, free of charge, to any person obtaining a copy
110
117
  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.2.13",
4
+ "version": "0.2.15",
5
5
  "news": {
6
+ "0.2.15": {
7
+ "en": "(René) change of dependencies\n(René) show cron job in log after creation",
8
+ "de": "(René) Veränderung der Abhängigkeiten\n(René) cron job in log nach der Erstellung anzeigen",
9
+ "ru": "(René) изменение зависимостей\n(René) показать работу корона в журнале после создания",
10
+ "pt": "(René) mudança de dependências\n(René) mostrar trabalho cron em log após a criação",
11
+ "nl": "(René) verandering van afhankelijkheden\n(René) cron job tonen in log na aanmaak",
12
+ "fr": "(René) changement de dépendances\n(René) montrer cron emploi dans log après la création",
13
+ "it": "(René) cambiamento delle dipendenze\n(René) mostrare il lavoro di cron nel registro dopo la creazione",
14
+ "es": "(René) cambio de dependencia\n(René) show cron job in log after creation",
15
+ "pl": "(René) zmiana zależności\n(René) show cron job in log after creation",
16
+ "uk": "(Рене) зміна залежностей\n(René) покажуть на роботу в журналі після створення",
17
+ "zh-cn": "(René) 属地变化\n(René) 创建后在日志中显示 cron 工作"
18
+ },
19
+ "0.2.14": {
20
+ "en": "(René) dependencies updated",
21
+ "de": "(René)",
22
+ "ru": "(René)",
23
+ "pt": "(René) dependências atualizadas",
24
+ "nl": "(René) bijgewerkte afhankelijkheden",
25
+ "fr": "(René) dépendances mises à jour",
26
+ "it": "(René) dipendenze aggiornate",
27
+ "es": "(René) dependencies updated",
28
+ "pl": "Aktualizacja zależności (René)",
29
+ "uk": "(René) залежностей оновлено",
30
+ "zh-cn": "(René) 更新的依赖关系"
31
+ },
6
32
  "0.2.13": {
7
33
  "en": "(René) just a sentry test",
8
34
  "de": "(René) nur einen Test",
@@ -67,32 +93,6 @@
67
93
  "pl": "zależności zostały zaktualizowane",
68
94
  "uk": "залежності оновлено",
69
95
  "zh-cn": "依赖项已更新"
70
- },
71
- "0.2.8": {
72
- "en": "role of states overworked",
73
- "de": "Rolle der Zustände überarbeitet",
74
- "ru": "роль государств перегружена работой",
75
- "pt": "papel dos estados sobrecarregados",
76
- "nl": "rol van staten overbelast",
77
- "fr": "rôle des Etats surmenés",
78
- "it": "ruolo degli stati oberati di lavoro",
79
- "es": "papel de los estados sobrecargado",
80
- "pl": "rola państw jest przepracowana",
81
- "uk": "роль держ",
82
- "zh-cn": "国家角色过度劳累"
83
- },
84
- "0.2.7": {
85
- "en": "dependencies updated",
86
- "de": "Abhängigkeiten aktualisiert",
87
- "ru": "зависимости обновлены",
88
- "pt": "dependências atualizadas",
89
- "nl": "afhankelijkheden bijgewerkt",
90
- "fr": "dépendances mises à jour",
91
- "it": "dipendenze aggiornate",
92
- "es": "dependencias actualizadas",
93
- "pl": "zależności zostały zaktualizowane",
94
- "uk": "залежності оновлено",
95
- "zh-cn": "依赖项已更新"
96
96
  }
97
97
  },
98
98
  "titleLang": {
@@ -136,11 +136,15 @@
136
136
  "loglevel": "info",
137
137
  "stopBeforeUpdate": true,
138
138
  "type": "energy",
139
- "license": "MIT",
139
+ "tier": 3,
140
+ "licenseInformation": {
141
+ "license": "MIT",
142
+ "type": "free"
143
+ },
140
144
  "materialize": true,
141
145
  "dependencies": [
142
146
  {
143
- "js-controller": ">=2.0.0"
147
+ "js-controller": ">=5.0.0"
144
148
  }
145
149
  ],
146
150
  "plugins": {
@@ -0,0 +1,367 @@
1
+ "use strict";
2
+
3
+
4
+ /**
5
+ * @param {string} timeVal
6
+ * @param {string} timeLimit
7
+ */
8
+ function IsLater(adapter, timeVal, timeLimit) {
9
+
10
+ let ret = false;
11
+ try {
12
+ adapter.log.debug("check IsLater : " + timeVal + " " + timeLimit);
13
+
14
+ if (typeof timeVal === "string" && typeof timeLimit === "string") {
15
+ const valIn = timeVal.split(":");
16
+ const valLimits = timeLimit.split(":");
17
+
18
+ if (valIn.length > 1 && valLimits.length > 1) {
19
+
20
+ if (parseInt(valIn[0]) > parseInt(valLimits[0])
21
+ || (parseInt(valIn[0]) == parseInt(valLimits[0]) && parseInt(valIn[1]) > parseInt(valLimits[1]))) {
22
+ ret = true;
23
+ adapter.log.debug("yes, IsLater : " + timeVal + " " + timeLimit);
24
+ }
25
+ }
26
+ else {
27
+ adapter.log.error("string does not contain : " + timeVal + " " + timeLimit);
28
+ }
29
+ }
30
+ else {
31
+ adapter.log.error("not a string " + typeof timeVal + " " + typeof timeLimit);
32
+ }
33
+ }
34
+ catch (e) {
35
+ adapter.log.error("exception in IsLater [" + e + "]");
36
+ }
37
+ return ret;
38
+ }
39
+
40
+ /**
41
+ * @param {string } timeVal
42
+ * @param {string } [timeLimit]
43
+ */
44
+ function IsEarlier(adapter, timeVal, timeLimit) {
45
+
46
+ let ret = false;
47
+ try {
48
+ adapter.log.debug("check IsEarlier : " + timeVal + " " + timeLimit);
49
+
50
+ if (typeof timeVal === "string" && typeof timeLimit === "string") {
51
+ const valIn = timeVal.split(":");
52
+ const valLimits = timeLimit.split(":");
53
+
54
+ if (valIn.length > 1 && valLimits.length > 1) {
55
+
56
+ if (parseInt(valIn[0]) < parseInt(valLimits[0])
57
+ || (parseInt(valIn[0]) == parseInt(valLimits[0]) && parseInt(valIn[1]) < parseInt(valLimits[1]))) {
58
+ ret = true;
59
+ adapter.log.debug("yes, IsEarlier : " + timeVal + " " + timeLimit);
60
+ }
61
+ }
62
+ else {
63
+ adapter.log.error("string does not contain : " + timeVal + " " + timeLimit);
64
+ }
65
+ }
66
+ else {
67
+ adapter.log.error("not a string " + typeof timeVal + " " + typeof timeLimit);
68
+ }
69
+ }
70
+ catch (e) {
71
+ adapter.log.error("exception in IsEarlier [" + e + "]");
72
+ }
73
+ return ret;
74
+ }
75
+
76
+ /**
77
+ * @param {string} timeVal
78
+ * @param {string} timeLimit
79
+ */
80
+ function IsEqual(adapter, timeVal, timeLimit) {
81
+
82
+ let ret = false;
83
+ try {
84
+ adapter.log.debug("check IsEqual : " + timeVal + " " + timeLimit);
85
+
86
+ if (typeof timeVal === "string" && typeof timeLimit === "string") {
87
+ const valIn = timeVal.split(":");
88
+ const valLimits = timeLimit.split(":");
89
+
90
+ if (valIn.length > 1 && valLimits.length > 1) {
91
+
92
+ if (parseInt(valIn[0]) === parseInt(valLimits[0]) && parseInt(valIn[1]) === parseInt(valLimits[1])) {
93
+ ret = true;
94
+ adapter.log.debug("yes, IsEqual : " + timeVal + " " + timeLimit);
95
+ }
96
+ }
97
+ else {
98
+ adapter.log.error("string does not contain : " + timeVal + " " + timeLimit);
99
+ }
100
+ }
101
+ else {
102
+ adapter.log.error("not a string " + typeof timeVal + " " + typeof timeLimit);
103
+ }
104
+ }
105
+ catch (e) {
106
+ adapter.log.error("exception in IsEqual [" + e + "]");
107
+ }
108
+ return ret;
109
+ }
110
+
111
+ //*******************************************************************
112
+ //
113
+ // find a object in array by key and value
114
+ // returns the object
115
+ function findObjectByKey(array, key, value) {
116
+ if (array !== null && array !== undefined) {
117
+ for (let i = 0; i < array.length; i++) {
118
+ if (array[i][key] === value) {
119
+ return array[i];
120
+ }
121
+ }
122
+ }
123
+ return null;
124
+ }
125
+
126
+ //*******************************************************************
127
+ //
128
+ // find a object in array by key and value
129
+ // returns the object
130
+ function findObjectsByKey(array, key, value) {
131
+
132
+ const ret = [];
133
+
134
+ if (array !== null && array !== undefined) {
135
+ for (let i = 0; i < array.length; i++) {
136
+ if (array[i][key] === value) {
137
+ ret.push(array[i]);
138
+ }
139
+ }
140
+ }
141
+ return ret;
142
+ }
143
+
144
+
145
+ //*******************************************************************
146
+ //
147
+ // find a object in array by key and value
148
+ // returns index number
149
+ function findObjectIdByKey(array, key, value) {
150
+
151
+
152
+ //array.filter(d => d.key == value);
153
+
154
+ if (array !== null && array !== undefined) {
155
+
156
+ for (let i = 0; i < array.length; i++) {
157
+ if (array[i][key] === value) {
158
+ return i;
159
+ }
160
+ }
161
+ }
162
+ return -1;
163
+ }
164
+
165
+
166
+ //*******************************************************************
167
+ //
168
+ // find all objects in array by key and value
169
+ // returns index number array
170
+ function findObjectsIdByKey(array, key, value) {
171
+
172
+ const ret = [];
173
+
174
+ if (array !== null && array !== undefined) {
175
+
176
+ for (let i = 0; i < array.length; i++) {
177
+ if (array[i][key] === value) {
178
+ ret.push(i);
179
+ }
180
+ }
181
+ }
182
+ return ret;
183
+ }
184
+
185
+
186
+ function timeConverter(SystemLanguage,time, timeonly = false) {
187
+
188
+ let a;
189
+
190
+ if (time != null) {
191
+ a = new Date(time);
192
+ }
193
+ else {
194
+ a = new Date();
195
+ }
196
+ let months;
197
+
198
+ if (SystemLanguage === "de") {
199
+ months = ["Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"];
200
+ }
201
+ else if (SystemLanguage === "en") {
202
+ months = ["Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"];
203
+ }
204
+ else {
205
+ months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
206
+ }
207
+
208
+ const year = a.getFullYear();
209
+ const month = months[a.getMonth()];
210
+ const date = a.getDate();
211
+ const sdate = date < 10 ? " " + date.toString() : date.toString();
212
+ const hour = a.getHours();
213
+ const shour = hour < 10 ? "0" + hour.toString() : hour.toString();
214
+ const min = a.getMinutes();
215
+ const smin = min < 10 ? "0" + min.toString() : min.toString();
216
+ const sec = a.getSeconds();
217
+ const ssec = sec < 10 ? "0" + sec.toString() : sec.toString();
218
+
219
+ let sRet = "";
220
+ if (timeonly) {
221
+ sRet = shour + ":" + smin + ":" + ssec;
222
+ }
223
+ else {
224
+ sRet = sdate + " " + month + " " + year.toString() + " " + shour + ":" + smin + ":" + ssec;
225
+ }
226
+
227
+ return sRet;
228
+ }
229
+
230
+ function CheckValidTime(adapter, id, time) {
231
+
232
+ let sRet = "00:00";
233
+ try {
234
+ if (time === "null" || time === undefined) {
235
+ adapter.log.error("time value not found for " + id);
236
+
237
+ }
238
+ else if (typeof time !== "string") {
239
+ adapter.log.error("time should be a string but is " + typeof time.val + " for " + id);
240
+
241
+ }
242
+ else if (time.length < 3) {
243
+ adapter.log.error("time not long enough for " + id);
244
+
245
+ }
246
+ else if (!time.includes(":")) {
247
+ adapter.log.error("time ':' missing for " + id);
248
+ }
249
+ else {
250
+ const times = time.split(":");
251
+ sRet = "0" + times[0].slice(-2) + ":" + "0" + times[1].slice(-2);
252
+ }
253
+
254
+ }
255
+ catch (e) {
256
+ adapter.log.error("exception in CheckValidTime [" + e + "] for " + id + " " + JSON.stringify(time));
257
+
258
+ }
259
+ return sRet;
260
+
261
+ }
262
+
263
+
264
+ function Check4ValidTemperature(adapter, temperature) {
265
+
266
+ try {
267
+
268
+ if (temperature == null) {
269
+ adapter.log.warn("target temperature is 'null' ");
270
+ }
271
+
272
+ if (typeof temperature == "object") {
273
+ adapter.log.warn("target temperature is an object, value: " + JSON.stringify(temperature));
274
+ }
275
+
276
+ if (isNaN(temperature) || typeof temperature === "string") {
277
+
278
+ adapter.log.debug("try to convert " + temperature + " to a number");
279
+ return Number(temperature);
280
+ }
281
+ else {
282
+ return temperature;
283
+ }
284
+
285
+ }
286
+ catch (e) {
287
+ adapter.log.error("exception in Check4ValidTemperature [" + e + "]");
288
+ return 0;
289
+ }
290
+
291
+ }
292
+
293
+
294
+ function IsSummerTime(adapter, sStartDate, sEndDate) {
295
+
296
+ let ret = false;
297
+ try {
298
+
299
+ adapter.log.debug("check in time " + sStartDate + " " + sEndDate);
300
+
301
+ if (sStartDate.length > 0 && sEndDate.length > 0) {
302
+ const StartPeriod = sStartDate.split(/[.,/ -]/);
303
+ const EndPeriod = sEndDate.split(/[.,/ -]/);
304
+
305
+ if (StartPeriod.length >= 2 && EndPeriod.length >= 2) {
306
+
307
+ const StartDate = new Date();
308
+ StartDate.setDate(parseInt(StartPeriod[0]));
309
+ StartDate.setMonth(parseInt(StartPeriod[1]) - 1);
310
+ adapter.log.debug("Start " + StartDate.toDateString());
311
+
312
+ const EndDate = new Date();
313
+ EndDate.setDate(parseInt(EndPeriod[0]));
314
+ EndDate.setMonth(parseInt(EndPeriod[1]) - 1);
315
+ adapter.log.debug("End " + EndDate.toDateString());
316
+
317
+ const now = new Date();
318
+
319
+ //bei Jahreswechsel
320
+ if (EndDate < StartDate) {
321
+ if (now > EndDate) {
322
+ //end already past, increase end year
323
+ EndDate.setFullYear(EndDate.getFullYear() + 1);
324
+ adapter.log.debug("corrected End " + EndDate.toDateString());
325
+ }
326
+ else {
327
+ //else decrease Start year
328
+ StartDate.setFullYear(StartDate.getFullYear() - 1);
329
+ adapter.log.debug("corrected Start " + StartDate.toDateString());
330
+ }
331
+ }
332
+
333
+ if (now >= StartDate && now <= EndDate) {
334
+ adapter.log.debug("we are in period");
335
+ ret = true;
336
+ }
337
+ else {
338
+ adapter.log.debug("we are not in period, after start " + StartDate.toDateString() + " and before end " + EndDate.toDateString());
339
+ ret = false;
340
+ }
341
+ }
342
+ }
343
+ }
344
+ catch (e) {
345
+ adapter.log.error("exception catch in IsSummerTime [" + e + "] ");
346
+ }
347
+ return ret;
348
+ }
349
+
350
+
351
+
352
+
353
+
354
+
355
+ module.exports = {
356
+ IsLater,
357
+ IsEarlier,
358
+ IsEqual,
359
+ findObjectsIdByKey,
360
+ findObjectIdByKey,
361
+ findObjectsByKey,
362
+ findObjectByKey,
363
+ timeConverter,
364
+ CheckValidTime,
365
+ Check4ValidTemperature,
366
+ IsSummerTime
367
+ };
package/main.js CHANGED
@@ -12,6 +12,8 @@ const axios = require("axios");
12
12
 
13
13
  const CronJob = require("cron").CronJob;
14
14
 
15
+ const timeConverter = require("./lib/support_tools.js").timeConverter;
16
+
15
17
  let cronJobs = [];
16
18
 
17
19
  /*
@@ -95,6 +97,8 @@ async function main() {
95
97
 
96
98
  CronCreate(readInterval, Do);
97
99
 
100
+ CronStatus();
101
+
98
102
  }
99
103
 
100
104
  async function Do() {
@@ -2538,6 +2542,7 @@ function CronStop() {
2538
2542
  }
2539
2543
  }
2540
2544
 
2545
+ /*
2541
2546
  function deleteCronJob(id) {
2542
2547
 
2543
2548
  cronJobs[id].stop();
@@ -2552,6 +2557,7 @@ function deleteCronJob(id) {
2552
2557
 
2553
2558
 
2554
2559
  }
2560
+ */
2555
2561
 
2556
2562
  function CronCreate(Minute, callback) {
2557
2563
 
@@ -2600,7 +2606,7 @@ function CronStatus() {
2600
2606
  //adapter.log.debug("cron jobs");
2601
2607
  for (n = 0; n < length; n++) {
2602
2608
  if ( cronJobs[n] !== undefined && cronJobs[n] != null) {
2603
- adapter.log.debug("cron status = " + cronJobs[n].running + " next event: " + timeConverter("DE", cronJobs[n].nextDates()));
2609
+ adapter.log.debug("cron status = " + cronJobs[n].running + " next event: " + timeConverter("DE", cronJobs[n].nextDate()));
2604
2610
  }
2605
2611
  }
2606
2612
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.amtronwallbox",
3
- "version": "0.2.13",
3
+ "version": "0.2.15",
4
4
  "description": "ioBroker Adapter for AMTRON wallboxes",
5
5
  "author": {
6
6
  "name": "René G.",
@@ -21,37 +21,37 @@
21
21
  "url": "https://github.com/rg-engineering/ioBroker.amtronwallbox"
22
22
  },
23
23
  "engines": {
24
- "node": ">= 16"
24
+ "node": ">= 18"
25
25
  },
26
26
  "dependencies": {
27
- "@iobroker/adapter-core": "3.0.4",
28
- "axios": "1.6.2",
29
- "cron": "3.1.6"
27
+ "@iobroker/adapter-core": "^3.1.4",
28
+ "axios": "^1.7.2",
29
+ "cron": "^3.1.7"
30
30
  },
31
31
  "devDependencies": {
32
- "@alcalzone/release-script": "3.7.0",
33
- "@alcalzone/release-script-plugin-iobroker": "3.7.0",
34
- "@alcalzone/release-script-plugin-license": "3.7.0",
35
- "@iobroker/adapter-dev": "1.2.0",
36
- "@iobroker/testing": "4.1.0",
37
- "@types/chai": "4.3.11",
38
- "@types/chai-as-promised": "7.1.8",
39
- "@types/gulp": "4.0.17",
40
- "@types/mocha": "10.0.4",
41
- "@types/node": "20.10.5",
42
- "@types/proxyquire": "1.3.31",
43
- "@types/request-promise-native": "1.0.21",
44
- "@types/sinon": "17.0.1",
45
- "@types/sinon-chai": "3.2.12",
46
- "axios": "1.6.2",
47
- "chai": "4.3.10",
48
- "chai-as-promised": "7.1.1",
49
- "eslint": "8.56.0",
50
- "gulp": "4.0.2",
51
- "mocha": "10.2.0",
52
- "proxyquire": "2.1.3",
53
- "sinon": "17.0.1",
54
- "sinon-chai": "3.7.0"
32
+ "@alcalzone/release-script": "^3.7.0",
33
+ "@alcalzone/release-script-plugin-iobroker": "^3.7.0",
34
+ "@alcalzone/release-script-plugin-license": "^3.7.0",
35
+ "@iobroker/adapter-dev": "^1.3.0",
36
+ "@iobroker/testing": "^4.1.3",
37
+ "@types/chai": "^4.3.11",
38
+ "@types/chai-as-promised": "^7.1.8",
39
+ "@types/gulp": "^4.0.17",
40
+ "@types/mocha": "^10.0.6",
41
+ "@types/node": "^20.12.12",
42
+ "@types/proxyquire": "^1.3.31",
43
+ "@types/request-promise-native": "^1.0.21",
44
+ "@types/sinon": "^17.0.3",
45
+ "@types/sinon-chai": "^3.2.12",
46
+ "axios": "^1.7.2",
47
+ "chai": "^4.4.1",
48
+ "chai-as-promised": "^7.1.2",
49
+ "eslint": "^9.3.0",
50
+ "gulp": "^5.0.0",
51
+ "mocha": "^10.4.0",
52
+ "proxyquire": "^2.1.3",
53
+ "sinon": "^18.0.0",
54
+ "sinon-chai": "^3.7.0"
55
55
  },
56
56
  "main": "main.js",
57
57
  "bugs": {