iobroker.amtronwallbox 0.1.0 → 0.2.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 rg-engineering <info@rg-engineering.eu>
3
+ Copyright (c) 2022-2023 rg-engineering 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
@@ -26,7 +26,13 @@ For more details and for information how to disable the error reporting see [Sen
26
26
 
27
27
  ## Changelog
28
28
 
29
- ### 0.1.0 (in progress)
29
+ ### 0.2.2 (2023-04-07)
30
+ * (René) dependencies updated
31
+
32
+ ### 0.2.0 (2023-01-31)
33
+ * (René) see issue #1: write data to XTRA wallbox (experimentel)
34
+
35
+ ### 0.1.0 (2022-12-18)
30
36
  * (René) see issue #1: support of XTRA
31
37
 
32
38
  ### 0.0.3 (2022-08-18)
@@ -40,7 +46,7 @@ For more details and for information how to disable the error reporting see [Sen
40
46
  ## License
41
47
  MIT License
42
48
 
43
- Copyright (c) 2022 rg-engineering info@rg-engineering.eu
49
+ Copyright (c) 2022-2023 rg-engineering info@rg-engineering.eu
44
50
 
45
51
  Permission is hereby granted, free of charge, to any person obtaining a copy
46
52
  of this software and associated documentation files (the "Software"), to deal
@@ -61,4 +67,3 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
61
67
  SOFTWARE.
62
68
 
63
69
 
64
-
package/io-package.json CHANGED
@@ -1,22 +1,9 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "amtronwallbox",
4
- "version": "0.1.0",
4
+ "version": "0.2.2",
5
5
  "news": {
6
- "0.1.0": {
7
- "en": "support for XTRA added",
8
- "de": "Unterstützung für XTRA hinzugefügt",
9
- "ru": "добавлена ​​поддержка XTRA",
10
- "pt": "suporte para XTRA adicionado",
11
- "nl": "ondersteuning voor XTRA toegevoegd",
12
- "fr": "prise en charge de XTRA ajoutée",
13
- "it": "supporto per XTRA aggiunto",
14
- "es": "soporte para XTRA añadido",
15
- "pl": "dodano obsługę XTRA",
16
- "uk": "додано підтримку XTRA",
17
- "zh-cn": "添加了对 XTRA 的支持"
18
- },
19
- "0.0.3": {
6
+ "0.2.1": {
20
7
  "en": "dependencies updated",
21
8
  "de": "Abhängigkeiten aktualisiert",
22
9
  "ru": "зависимости обновлены",
@@ -25,22 +12,22 @@
25
12
  "fr": "dépendances mises à jour",
26
13
  "it": "dipendenze aggiornate",
27
14
  "es": "dependencias actualizadas",
28
- "pl": "zaktualizowano zależności",
29
- "zh-cn": "已更新依赖项",
30
- "uk": "залежності оновлено"
15
+ "pl": "zaktualizowane zależności",
16
+ "uk": "залежності оновлено",
17
+ "zh-cn": "依赖更新"
31
18
  },
32
- "0.0.1": {
33
- "en": "initial release",
34
- "de": "Erstveröffentlichung",
35
- "ru": "Первый выпуск",
36
- "pt": "lançamento inicial",
37
- "nl": "Eerste uitgave",
38
- "fr": "Première version",
39
- "it": "Versione iniziale",
40
- "es": "Versión inicial",
41
- "pl": "Pierwsze wydanie",
42
- "zh-cn": "初始发行",
43
- "uk": "початковий випуск"
19
+ "0.2.0": {
20
+ "en": "write data to XTRA wallbox",
21
+ "de": "Daten in die XTRA Wallbox schreiben",
22
+ "ru": "записать данные в XTRA Wallbox",
23
+ "pt": "gravar dados na caixa de embutir XTRA",
24
+ "nl": "schrijf gegevens naar XTRA wallbox",
25
+ "fr": "écrire des données sur la wallbox XTRA",
26
+ "it": "scrivere i dati nella wallbox XTRA",
27
+ "es": "escribir datos en la caja de pared XTRA",
28
+ "pl": "zapis danych do stacji ładowania XTRA",
29
+ "uk": "записати дані на XTRA wallbox",
30
+ "zh-cn": "将数据写入 XTRA wallbox"
44
31
  }
45
32
  },
46
33
  "titleLang": {
package/main.js CHANGED
@@ -1,4 +1,4 @@
1
- /*
1
+ /*
2
2
  * AMTRON wallbox adapter für iobroker
3
3
  *
4
4
  * Created: 15.05.2022 18:39:28
@@ -448,22 +448,197 @@ async function HandleStateChange(id, state) {
448
448
 
449
449
  if (state.ack !== true) {
450
450
 
451
- adapter.log.debug("handle state change " + id);
451
+ adapter.log.debug("handle state change " + id + " with " + state.val);
452
452
  const ids = id.split(".");
453
453
 
454
- //just dummy
455
- //if (ids[2] === "cmd") {
456
- // await do_Command();
457
- //}
458
- //else {
454
+ //unhandled state change amtronwallbox.0.Test.info.DevName
455
+ if (ids[3] === "info") {
456
+ await updateInfo(id, state);
457
+ adapter.setForeignState(id, { ack: true });
458
+ }
459
+ else if (ids[3] === "charge") {
460
+ await updateCharge(id, state);
461
+ adapter.setForeignState(id, { ack: true });
462
+ }
463
+ else {
459
464
  adapter.log.warn("unhandled state change " + id);
460
- //}
465
+ }
466
+ }
467
+ }
468
+
469
+ async function updateInfo(id,state) {
470
+
471
+ let systemName = id.split(".")[2];
472
+
473
+ for (const system of adapter.config.WallboxSystems) {
474
+
475
+ if (system.Name == systemName && system.IsActive) {
476
+ if (system.Type === "ChargeControl") {
477
+
478
+ }
479
+ else if (system.Type === "Compact") {
480
+ await write_MHCP_DevInfo(system, id,state);
481
+ }
482
+ else if (system.Type === "Xtra") {
483
+ await write_MHCP_DevInfo(system, id, state);
484
+ }
485
+
486
+ else {
487
+ //system type ChargeControl string not yet implemented
488
+ adapter.log.warn("system type " + system.Type + " " + typeof system.Type + " not yet implemented");
489
+ }
490
+ }
491
+ }
492
+ }
493
+
494
+ async function updateCharge(id, state) {
495
+
496
+ let systemName = id.split(".")[2];
497
+
498
+ for (const system of adapter.config.WallboxSystems) {
499
+
500
+ if (system.Name == systemName && system.IsActive) {
501
+ if (system.Type === "ChargeControl") {
502
+
503
+ }
504
+ else if (system.Type === "Compact") {
505
+ await write_MHCP_ChargeData(system, id, state);
506
+ }
507
+ else if (system.Type === "Xtra") {
508
+ await write_MHCP_ChargeData(system, id, state);
509
+ }
510
+
511
+ else {
512
+ //system type ChargeControl string not yet implemented
513
+ adapter.log.warn("system type " + system.Type + " " + typeof system.Type + " not yet implemented");
514
+ }
515
+ }
516
+ }
517
+ }
518
+
519
+ async function write_MHCP_DevInfo(system, id, state) {
520
+ try {
521
+ let sURL = "http://" + system.IPAddress + ":25000/MHCP/1.0/DevInfo?DevKey=" + system.ApiKey;
522
+
523
+ let config = {
524
+ headers: {
525
+ Accept: 'application/json '
526
+ },
527
+ timeout: 5000
528
+
529
+ }
530
+
531
+ let param = id.split(".")[4];
532
+
533
+ let data = {
534
+ "DevName": param == "DevName" ? state.val : null,
535
+ "LocTime": param == "LocTime" ? state.val : null,
536
+ "Summer": param == "Summer" ? state.val : null,
537
+ "Tz": param == "Tz" ? state.val : null,
538
+ "FixedVehCosts": param == "FixedVehCosts" ? state.val : null,
539
+ "OldVehCosts": param == "OldVehCosts" ? state.val : null,
540
+ "Battery": param == "Battery" ? state.val : null,
541
+ "DevMode": param == "DevMode" ? state.val : null,
542
+ }
543
+
544
+ adapter.log.debug("URL " + sURL.replace(/DevKey=.*/, 'DevKey=******') + " data " + JSON.stringify(data));
545
+
546
+
547
+ let buffer = await axios.post(sURL, data, config);
548
+
549
+ adapter.log.debug("got result " + typeof buffer.data + " " + JSON.stringify(buffer.data));
550
+
551
+
461
552
  }
553
+ catch (e) {
554
+ adapter.log.error("exception in write_MHCP_DevInfo [" + e + "]");
555
+ }
556
+ }
557
+
558
+ async function write_MHCP_ChargeData(system, id, state) {
559
+ try {
560
+ let sURL = "http://" + system.IPAddress + ":25000/MHCP/1.0/ChargeData?DevKey=" + system.ApiKey;
561
+
562
+ let config = {
563
+ headers: {
564
+ Accept: 'application/json '
565
+ },
566
+ timeout: 5000
462
567
 
568
+ }
569
+
570
+ let param = id.split(".")[4];
571
+
572
+ let data = {
573
+ "Permanent": true,
574
+ "RemoteCurr": param == "RemoteCurr" ? state.val : null,
575
+ "AutoChg": param == "AutoChg" ? state.val : null,
576
+ "ChgState": param == "ChgState" ? state.val : null,
577
+ "Uid": param == "Uid" ? state.val : null,
578
+ }
579
+
580
+ adapter.log.debug("URL " + sURL.replace(/DevKey=.*/, 'DevKey=******') + " data " + JSON.stringify(data));
581
+
582
+
583
+ let buffer = await axios.post(sURL, data, config);
584
+
585
+ adapter.log.debug("got result " + typeof buffer.data + " " + JSON.stringify(buffer.data));
586
+
587
+
588
+ }
589
+ catch (e) {
590
+ adapter.log.error("exception in write_MHCP_ChargeData [" + e + "]");
591
+ }
463
592
  }
464
593
 
465
594
  function subscribeVars() {
466
- //adapter.subscribeStates("cmd");
595
+ for (const system of adapter.config.WallboxSystems) {
596
+
597
+ if (system.IsActive) {
598
+ if (system.Type === "ChargeControl") {
599
+
600
+ }
601
+ else if (system.Type === "Compact") {
602
+
603
+ }
604
+ else if (system.Type === "Xtra") {
605
+
606
+ //All parameters can be set to null if no change is intended.
607
+ //https://github.com/lephisto/amtron/blob/master/docs/api/DevInfo/post.md
608
+ adapter.subscribeStates(system.Name + ".info.DevName");
609
+ adapter.subscribeStates(system.Name + ".info.LocTime");
610
+ adapter.subscribeStates(system.Name + ".info.Summer");
611
+ adapter.subscribeStates(system.Name + ".info.Tz");
612
+ adapter.subscribeStates(system.Name + ".info.FixedVehCosts");
613
+ adapter.subscribeStates(system.Name + ".info.OldVehCosts");
614
+ adapter.subscribeStates(system.Name + ".info.Battery");
615
+ adapter.subscribeStates(system.Name + ".info.DevMode");
616
+
617
+ //All parameters except "Permanent" can be set to null if no change is intended.
618
+ //https://github.com/lephisto/amtron/blob/master/docs/api/ChargeData/post.md
619
+ //adapter.subscribeStates(system.Name + ".charge.Permanent");
620
+ adapter.subscribeStates(system.Name + ".charge.RemoteCurr");
621
+ //adapter.subscribeStates(system.Name + ".charge.AutoChg"); //gibt es den DP?
622
+ adapter.subscribeStates(system.Name + ".charge.ChgState");
623
+ adapter.subscribeStates(system.Name + ".charge.Uid");
624
+
625
+ //Solar price can be set to null when no changes have to be made.
626
+ //https://github.com/lephisto/amtron/blob/master/docs/api/HomeManager/post.md
627
+
628
+
629
+ //https://github.com/lephisto/amtron/blob/master/docs/api/Whitelist/post.md
630
+
631
+
632
+ }
633
+
634
+ else {
635
+ //system type ChargeControl string not yet implemented
636
+ adapter.log.warn("system type " + system.Type + " " + typeof system.Type + " not yet implemented");
637
+ }
638
+ }
639
+ }
640
+
641
+
467
642
  }
468
643
 
469
644
 
@@ -1069,7 +1244,7 @@ async function checkVariables_MHCP(system) {
1069
1244
  type: "number",
1070
1245
  role: "value",
1071
1246
  read: true,
1072
- write: false
1247
+ write: true
1073
1248
  }
1074
1249
  }
1075
1250
  await CreateObject(key, obj);
@@ -1095,7 +1270,7 @@ async function checkVariables_MHCP(system) {
1095
1270
  type: "number",
1096
1271
  role: "value",
1097
1272
  read: true,
1098
- write: false
1273
+ write: true
1099
1274
  }
1100
1275
  }
1101
1276
  await CreateObject(key, obj);
@@ -1186,7 +1361,7 @@ async function checkVariables_MHCP(system) {
1186
1361
  type: "number",
1187
1362
  role: "value",
1188
1363
  read: true,
1189
- write: false
1364
+ write: true
1190
1365
  }
1191
1366
  }
1192
1367
  await CreateObject(key, obj);
@@ -1199,7 +1374,7 @@ async function checkVariables_MHCP(system) {
1199
1374
  type: "number",
1200
1375
  role: "value",
1201
1376
  read: true,
1202
- write: false
1377
+ write: true
1203
1378
  }
1204
1379
  }
1205
1380
  await CreateObject(key, obj);
@@ -1225,7 +1400,7 @@ async function checkVariables_MHCP(system) {
1225
1400
  type: "string",
1226
1401
  role: "value",
1227
1402
  read: true,
1228
- write: false
1403
+ write: true
1229
1404
  }
1230
1405
  }
1231
1406
  await CreateObject(key, obj);
@@ -1303,7 +1478,7 @@ async function checkVariables_MHCP(system) {
1303
1478
  type: "number",
1304
1479
  role: "value",
1305
1480
  read: true,
1306
- write: false
1481
+ write: true
1307
1482
  }
1308
1483
  }
1309
1484
  await CreateObject(key, obj);
@@ -1425,7 +1600,7 @@ async function checkVariables_MHCP(system) {
1425
1600
  type: "string",
1426
1601
  role: "value",
1427
1602
  read: true,
1428
- write: false
1603
+ write: true
1429
1604
  }
1430
1605
  }
1431
1606
  await CreateObject(key, obj);
@@ -1464,7 +1639,7 @@ async function checkVariables_MHCP(system) {
1464
1639
  type: "string",
1465
1640
  role: "value",
1466
1641
  read: true,
1467
- write: false
1642
+ write: true
1468
1643
  }
1469
1644
  }
1470
1645
  await CreateObject(key, obj);
@@ -1691,7 +1866,7 @@ async function checkVariables_MHCP(system) {
1691
1866
  unit: "A",
1692
1867
  role: "value",
1693
1868
  read: true,
1694
- write: false
1869
+ write: true
1695
1870
  }
1696
1871
  }
1697
1872
  await CreateObject(key, obj);
@@ -1771,7 +1946,7 @@ async function checkVariables_MHCP_Statistic(system, period) {
1771
1946
  unit:"Wh",
1772
1947
  role: "value",
1773
1948
  read: true,
1774
- write: true
1949
+ write: false
1775
1950
  }
1776
1951
  }
1777
1952
  await CreateObject(key, obj);
@@ -1784,7 +1959,7 @@ async function checkVariables_MHCP_Statistic(system, period) {
1784
1959
  type: "number",
1785
1960
  role: "value",
1786
1961
  read: true,
1787
- write: true
1962
+ write: false
1788
1963
  }
1789
1964
  }
1790
1965
  await CreateObject(key, obj);
@@ -1797,7 +1972,7 @@ async function checkVariables_MHCP_Statistic(system, period) {
1797
1972
  type: "number",
1798
1973
  role: "value",
1799
1974
  read: true,
1800
- write: true
1975
+ write: false
1801
1976
  }
1802
1977
  }
1803
1978
  await CreateObject(key, obj);
@@ -1810,7 +1985,7 @@ async function checkVariables_MHCP_Statistic(system, period) {
1810
1985
  type: "number",
1811
1986
  role: "value",
1812
1987
  read: true,
1813
- write: true
1988
+ write: false
1814
1989
  }
1815
1990
  }
1816
1991
  await CreateObject(key, obj);
@@ -1823,7 +1998,7 @@ async function checkVariables_MHCP_Statistic(system, period) {
1823
1998
  type: "number",
1824
1999
  role: "value",
1825
2000
  read: true,
1826
- write: true
2001
+ write: false
1827
2002
  }
1828
2003
  }
1829
2004
  await CreateObject(key, obj);
@@ -1836,7 +2011,7 @@ async function checkVariables_MHCP_Statistic(system, period) {
1836
2011
  type: "number",
1837
2012
  role: "value",
1838
2013
  read: true,
1839
- write: true
2014
+ write: false
1840
2015
  }
1841
2016
  }
1842
2017
  await CreateObject(key, obj);
@@ -1849,7 +2024,7 @@ async function checkVariables_MHCP_Statistic(system, period) {
1849
2024
  type: "number",
1850
2025
  role: "value",
1851
2026
  read: true,
1852
- write: true
2027
+ write: false
1853
2028
  }
1854
2029
  }
1855
2030
  await CreateObject(key, obj);
@@ -1862,7 +2037,7 @@ async function checkVariables_MHCP_Statistic(system, period) {
1862
2037
  type: "number",
1863
2038
  role: "value",
1864
2039
  read: true,
1865
- write: true
2040
+ write: false
1866
2041
  }
1867
2042
  }
1868
2043
  await CreateObject(key, obj);
@@ -1878,7 +2053,7 @@ async function checkVariables_MHCP_Statistic(system, period) {
1878
2053
  type: "number",
1879
2054
  role: "value",
1880
2055
  read: true,
1881
- write: true
2056
+ write: false
1882
2057
  }
1883
2058
  }
1884
2059
  await CreateObject(key, obj);
@@ -1891,7 +2066,7 @@ async function checkVariables_MHCP_Statistic(system, period) {
1891
2066
  type: "number",
1892
2067
  role: "value",
1893
2068
  read: true,
1894
- write: true
2069
+ write: false
1895
2070
  }
1896
2071
  }
1897
2072
  await CreateObject(key, obj);
@@ -1904,7 +2079,7 @@ async function checkVariables_MHCP_Statistic(system, period) {
1904
2079
  type: "number",
1905
2080
  role: "value",
1906
2081
  read: true,
1907
- write: true
2082
+ write: false
1908
2083
  }
1909
2084
  }
1910
2085
  await CreateObject(key, obj);
@@ -1917,7 +2092,7 @@ async function checkVariables_MHCP_Statistic(system, period) {
1917
2092
  type: "number",
1918
2093
  role: "value",
1919
2094
  read: true,
1920
- write: true
2095
+ write: false
1921
2096
  }
1922
2097
  }
1923
2098
  await CreateObject(key, obj);
@@ -2031,12 +2206,12 @@ function CronStatus() {
2031
2206
  let n = 0;
2032
2207
  let length = 0;
2033
2208
  try {
2034
- if (typeof cronJobs !== undefined && cronJobs != null) {
2209
+ if (cronJobs !== undefined && cronJobs != null) {
2035
2210
 
2036
2211
  length = cronJobs.length;
2037
2212
  //adapter.log.debug("cron jobs");
2038
2213
  for (n = 0; n < length; n++) {
2039
- if (typeof cronJobs[n] !== undefined && cronJobs[n] != null) {
2214
+ if ( cronJobs[n] !== undefined && cronJobs[n] != null) {
2040
2215
  adapter.log.debug("cron status = " + cronJobs[n].running + " next event: " + timeConverter("DE", cronJobs[n].nextDates()));
2041
2216
  }
2042
2217
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.amtronwallbox",
3
- "version": "0.1.0",
3
+ "version": "0.2.2",
4
4
  "description": "ioBroker Adapter for AMTRON wallboxes",
5
5
  "author": {
6
6
  "name": "René G.",
@@ -21,9 +21,9 @@
21
21
  "url": "https://github.com/rg-engineering/ioBroker.amtronwallbox"
22
22
  },
23
23
  "dependencies": {
24
- "@iobroker/adapter-core": "2.6.7",
25
- "axios": "1.2.0",
26
- "cron": "2.1.0"
24
+ "@iobroker/adapter-core": "2.6.8",
25
+ "axios": "0.27.2",
26
+ "cron": "2.3.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@iobroker/adapter-dev": "1.2.0",
@@ -31,20 +31,20 @@
31
31
  "@types/chai": "4.3.4",
32
32
  "@types/chai-as-promised": "7.1.5",
33
33
  "@types/gulp": "4.0.10",
34
- "@types/mocha": "10.0.0",
35
- "@types/node": "18.11.9",
34
+ "@types/mocha": "10.0.1",
35
+ "@types/node": "18.15.11",
36
36
  "@types/proxyquire": "1.3.28",
37
37
  "@types/request-promise-native": "1.0.18",
38
38
  "@types/sinon": "10.0.13",
39
39
  "@types/sinon-chai": "3.2.9",
40
- "axios": "1.2.0",
40
+ "axios": "0.27.2",
41
41
  "chai": "4.3.7",
42
42
  "chai-as-promised": "7.1.1",
43
- "eslint": "8.28.0",
43
+ "eslint": "8.37.0",
44
44
  "gulp": "4.0.2",
45
- "mocha": "10.1.0",
45
+ "mocha": "10.2.0",
46
46
  "proxyquire": "2.1.3",
47
- "sinon": "15.0.0",
47
+ "sinon": "15.0.3",
48
48
  "sinon-chai": "3.7.0"
49
49
  },
50
50
  "main": "main.js",