iobroker.alpha-ess 1.3.0-beta.0 → 1.3.0
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 +10 -1
- package/io-package.json +13 -39
- package/main.js +126 -27
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -57,13 +57,22 @@ How to find SN and Check code for registration is described here: https://github
|
|
|
57
57
|
- **Interval to read charging settings:** Unit: minutes.
|
|
58
58
|
- **Interval to read discharging settings:** Unit: minutes.
|
|
59
59
|
- **Interval to read summary data:** Unit: minutes.
|
|
60
|
-
- **Interval to read wallbox data:** Unit: minutes.
|
|
60
|
+
- **Interval to read wallbox data:** Unit: minutes. Caution: Currently only one Wallbox is supported.
|
|
61
61
|
|
|
62
62
|
## Disclaimer
|
|
63
63
|
|
|
64
64
|
**All product and company names or logos are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them or any associated subsidiaries! This personal project is maintained in spare time and has no business goal.**
|
|
65
65
|
|
|
66
66
|
## Changelog
|
|
67
|
+
### 1.3.0 (2023-11-22)
|
|
68
|
+
|
|
69
|
+
- (Gaspode) Support wallbox with Open API
|
|
70
|
+
- (Gaspode) Start and stop charging of wallbox with Open API
|
|
71
|
+
|
|
72
|
+
### 1.3.0-beta.1 (2023-11-21)
|
|
73
|
+
|
|
74
|
+
- (Gaspode) Start and stop charging of wallbox with Open API
|
|
75
|
+
|
|
67
76
|
### 1.3.0-beta.0 (2023-11-18)
|
|
68
77
|
|
|
69
78
|
- (Gaspode) Support wallbox with Open API
|
package/io-package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"name": "alpha-ess",
|
|
4
|
-
"version": "1.3.0
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"news": {
|
|
6
|
-
"1.3.0
|
|
7
|
-
"en": "Support wallbox with Open API",
|
|
8
|
-
"de": "Wallbox Unterstützung mit Open API",
|
|
9
|
-
"ru": "Поддержка настенного ящика с Open API",
|
|
10
|
-
"pt": "Suporte wallbox com API aberta",
|
|
11
|
-
"nl": "Steun muur met open API",
|
|
12
|
-
"fr": "Porte-monnaie support avec Open API",
|
|
13
|
-
"it": "Supporto wallbox con Open API",
|
|
14
|
-
"es": "Soporte de pared con Open API",
|
|
15
|
-
"pl": "Współdzielnia z API Open",
|
|
16
|
-
"uk": "Підтримка настінної коробки з відкритим API",
|
|
17
|
-
"zh-cn": "A. 开放式API
|
|
6
|
+
"1.3.0": {
|
|
7
|
+
"en": "Support wallbox with Open API\nStart and stop charging of wallbox with Open API",
|
|
8
|
+
"de": "Wallbox Unterstützung mit Open API\nStarten und stoppen des Ladevorgangs der Wallbox mit Open API",
|
|
9
|
+
"ru": "Поддержка настенного ящика с Open API\nНачните и остановите зарядку настенного ящика с Open API",
|
|
10
|
+
"pt": "Suporte wallbox com API aberta\nIniciar e parar de carregar de wallbox com API aberta",
|
|
11
|
+
"nl": "Steun muur met open API\nBegin en stop met het inladen van een muurkist met open API",
|
|
12
|
+
"fr": "Porte-monnaie support avec Open API\nDémarrer et arrêter le chargement de la boîte murale avec Open API",
|
|
13
|
+
"it": "Supporto wallbox con Open API\nAvviare e interrompere la ricarica di wallbox con Open API",
|
|
14
|
+
"es": "Soporte de pared con Open API\nComience y deje de cargar Wallbox con Open API",
|
|
15
|
+
"pl": "Współdzielnia z API Open\nStart i zatrzymanie ładowania skrzynki z Open API",
|
|
16
|
+
"uk": "Підтримка настінної коробки з відкритим API\nСтарт і зупинка зарядки стінок з відкритим API",
|
|
17
|
+
"zh-cn": "A. 开放式API的支助墙箱\nA. 开端和停止向开放的阿联酋投掷石箱"
|
|
18
18
|
},
|
|
19
19
|
"1.2.1": {
|
|
20
20
|
"en": "Fixed severe error in ClosedAPI",
|
|
@@ -67,32 +67,6 @@
|
|
|
67
67
|
"pl": "Zamknięty API niepełnosprawny (czasowo?) ponieważ interfejs API został zmieniony przez Alpha-ESS\nCzytanie z powrotem zmieniało wartości 2 sekundy po zmianie ich wartości",
|
|
68
68
|
"uk": "Замкнено API вимкнено (попередньо?) тому, що API було змінено Альфа-ESS\nЧитання змінених значень налаштувань 2 секунд після зміни",
|
|
69
69
|
"zh-cn": "由于Alpha-ESS已改变API残疾(有时?)\n阅读后的环境价值观2"
|
|
70
|
-
},
|
|
71
|
-
"1.0.2": {
|
|
72
|
-
"en": "Updated required node version to 16 or newer",
|
|
73
|
-
"de": "Erforderliche Node Version auf 16 oder neuer aktualisiert",
|
|
74
|
-
"ru": "Обновленная необходимая версия узла до 16 или новее",
|
|
75
|
-
"pt": "Versão de nó atualizada necessária para 16 ou mais recente",
|
|
76
|
-
"nl": "Verouderd vereiste node versie van 16 of nieuw",
|
|
77
|
-
"fr": "Mise à jour de la version node requise à 16 ou plus",
|
|
78
|
-
"it": "Versione nodo richiesta aggiornata a 16 o più recente",
|
|
79
|
-
"es": "Versión actualizada de nodos requeridos a 16 o más",
|
|
80
|
-
"pl": "Wymagana wersja węzła do 16 lub nowa",
|
|
81
|
-
"uk": "Оновлено необхідну версію вершини до 16 або нових",
|
|
82
|
-
"zh-cn": "A. 最新要求的无误版本到16个或新成员"
|
|
83
|
-
},
|
|
84
|
-
"1.0.1": {
|
|
85
|
-
"en": "Adapted fetching energy values using 'Closed API' to latest API changes by Alpha-ESS",
|
|
86
|
-
"de": "Closed API: Energiewerte an neueste API-Änderungen von Alpha-ESS angepasst",
|
|
87
|
-
"ru": "Адаптированные выкачивание энергетических ценностей с помощью 'Closed API' для последних изменений API от Alpha-ESS",
|
|
88
|
-
"pt": "Valores de energia de busca adaptados usando ' API fechada' para as últimas alterações de API por Alpha-ESS",
|
|
89
|
-
"nl": "API verandert door Alpha-ESSS",
|
|
90
|
-
"fr": "Récupération des valeurs d'énergie à l'aide de 'API fermée' aux dernières modifications de l'API par Alpha-ESS",
|
|
91
|
-
"it": "Adattato l'ottenimento di valori energetici utilizzando 'API archiviate' alle ultime modifiche API di Alpha-ESS",
|
|
92
|
-
"es": "Valores de energía adaptados de búsqueda usando 'Closed API' para los últimos cambios de API por Alpha-ESS",
|
|
93
|
-
"pl": "Adapted fetching energy values używając 'Closed API' do najnowszych zmian API przez Alpha-ESS",
|
|
94
|
-
"uk": "Адаптивовані коефіцієнти відтікання енергії за допомогою 'Closed API' для останніх змін API від Alpha-ESS",
|
|
95
|
-
"zh-cn": "利用“无能”的能源价值降低到Alpha-ESS新生动的改变"
|
|
96
70
|
}
|
|
97
71
|
},
|
|
98
72
|
"titleLang": {
|
package/main.js
CHANGED
|
@@ -17,7 +17,6 @@ const CA_AUTHSUFFIX = 'ui893ed';
|
|
|
17
17
|
const CA_BaseURI = 'https://www.alphaess-cloud.com/';
|
|
18
18
|
const OA_BaseURI = 'https://openapi.alphaess.com/api';
|
|
19
19
|
|
|
20
|
-
const WriteTimeoutIntervalInS = 5;
|
|
21
20
|
const ReadAfterWriteTimeoutIntervalInS = 2;
|
|
22
21
|
|
|
23
22
|
const REQUEST_TIMEOUT = 10000;
|
|
@@ -305,6 +304,7 @@ class OpenAPI {
|
|
|
305
304
|
Group: 'Settings_Charge'
|
|
306
305
|
, fnct: this.getChargeConfigInfo.bind(this)
|
|
307
306
|
, writeFnct: this.writeConfigInfo.bind(this)
|
|
307
|
+
, writeTimeoutIntervalInS: 5
|
|
308
308
|
, requestName: 'updateChargeConfigInfo'
|
|
309
309
|
, enabledName: 'oAEnableSettingsCharge'
|
|
310
310
|
, intervalName: 'oAIntervalSettingsChargeMins'
|
|
@@ -369,6 +369,7 @@ class OpenAPI {
|
|
|
369
369
|
Group: 'Settings_Discharge'
|
|
370
370
|
, fnct: this.getDisChargeConfigInfo.bind(this)
|
|
371
371
|
, writeFnct: this.writeConfigInfo.bind(this)
|
|
372
|
+
, writeTimeoutIntervalInS: 5
|
|
372
373
|
, requestName: 'updateDisChargeConfigInfo'
|
|
373
374
|
, enabledName: 'oAEnableSettingsDischarge'
|
|
374
375
|
, intervalName: 'oAIntervalSettingsDischargeMins'
|
|
@@ -562,6 +563,9 @@ class OpenAPI {
|
|
|
562
563
|
{
|
|
563
564
|
Group: 'Wallbox'
|
|
564
565
|
, fnct: this.getWallboxData.bind(this)
|
|
566
|
+
, writeFnct: this.writeWallboxChargerControl.bind(this)
|
|
567
|
+
, writeTimeoutIntervalInS: 0
|
|
568
|
+
, requestName: 'remoteControlEvCharger'
|
|
565
569
|
, enabledName: 'oAEnableWallbox'
|
|
566
570
|
, intervalName: 'oAIntervalWallboxMins'
|
|
567
571
|
, intervalFactor: 60
|
|
@@ -584,6 +588,28 @@ class OpenAPI {
|
|
|
584
588
|
, unit: ''
|
|
585
589
|
, isStatic: true
|
|
586
590
|
},
|
|
591
|
+
{
|
|
592
|
+
alphaAttrName: 'remoteControlEvChargerStart'
|
|
593
|
+
, role: 'button.start'
|
|
594
|
+
, id: 'Charging_Start'
|
|
595
|
+
, name: 'Charging Start'
|
|
596
|
+
, type: 'boolean'
|
|
597
|
+
, unit: ''
|
|
598
|
+
, isStatic: true
|
|
599
|
+
, writeable: true
|
|
600
|
+
, readable: false
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
alphaAttrName: 'remoteControlEvChargerStop'
|
|
604
|
+
, role: 'button.stop'
|
|
605
|
+
, id: 'Charging_Stop'
|
|
606
|
+
, name: 'Charging Stop'
|
|
607
|
+
, type: 'boolean'
|
|
608
|
+
, unit: ''
|
|
609
|
+
, isStatic: true
|
|
610
|
+
, writeable: true
|
|
611
|
+
, readable: false
|
|
612
|
+
},
|
|
587
613
|
{
|
|
588
614
|
alphaAttrName: 'evchargerStatus'
|
|
589
615
|
, role: 'value'
|
|
@@ -823,7 +849,6 @@ class OpenAPI {
|
|
|
823
849
|
this.adapter.stopGroupTimeout(group);
|
|
824
850
|
|
|
825
851
|
this.adapter.log.debug('Fetching ' + group + ' data...');
|
|
826
|
-
|
|
827
852
|
// First we need to get SN if not already done:
|
|
828
853
|
let snState = await this.adapter.getStateAsync(`${group}.SN`);
|
|
829
854
|
if (!snState || typeof snState.val === 'string' && snState.val.length == 0) {
|
|
@@ -882,7 +907,7 @@ class OpenAPI {
|
|
|
882
907
|
/**
|
|
883
908
|
* @param {string} group
|
|
884
909
|
*/
|
|
885
|
-
async writeConfigInfo(group) {
|
|
910
|
+
async writeConfigInfo(group, _updState, _updStateInfo) {
|
|
886
911
|
const nextReadTimeout = ReadAfterWriteTimeoutIntervalInS;
|
|
887
912
|
try {
|
|
888
913
|
this.adapter.stopGroupWriteTimeout(group);
|
|
@@ -931,6 +956,60 @@ class OpenAPI {
|
|
|
931
956
|
this.adapter.startGroupTimeout(nextReadTimeout, group);
|
|
932
957
|
}
|
|
933
958
|
|
|
959
|
+
/**
|
|
960
|
+
* @param {string} group
|
|
961
|
+
* @param {ioBroker.State} updState
|
|
962
|
+
* @param {any} updStateInfo
|
|
963
|
+
*/
|
|
964
|
+
async writeWallboxChargerControl(group, updState, updStateInfo) {
|
|
965
|
+
try {
|
|
966
|
+
this.adapter.stopGroupWriteTimeout(group);
|
|
967
|
+
this.adapter.stopGroupTimeout(group);
|
|
968
|
+
|
|
969
|
+
this.adapter.log.debug('Writing ' + group + ' data...');
|
|
970
|
+
|
|
971
|
+
const gidx = this.stateInfoList.findIndex((/** @type {{ Group: string; }} */ i) => i.Group == group);
|
|
972
|
+
if (gidx >= 0) {
|
|
973
|
+
|
|
974
|
+
const chargerSnState = await this.adapter.getStateAsync(group + '.SN');
|
|
975
|
+
|
|
976
|
+
if (chargerSnState) {
|
|
977
|
+
this.adapter.log.debug(`Using Wallbox SN: ${chargerSnState.val}`);
|
|
978
|
+
|
|
979
|
+
const body = {};
|
|
980
|
+
|
|
981
|
+
if (updStateInfo.role == 'button.start') {
|
|
982
|
+
body['controlMode'] = 1;
|
|
983
|
+
}
|
|
984
|
+
else {
|
|
985
|
+
body['controlMode'] = 0;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
body['sysSn'] = this.adapter.config.systemId;
|
|
989
|
+
body['evchargerSn'] = chargerSnState.val;
|
|
990
|
+
|
|
991
|
+
this.adapter.log.debug(`Write group ${group}: ${JSON.stringify(body)}`);
|
|
992
|
+
|
|
993
|
+
const res = await this.postRequest(this.adapter.getStateInfoList()[gidx].requestName, body, {});
|
|
994
|
+
if (res && res['status'] == 200 && res.data) {
|
|
995
|
+
this.adapter.log.info('Written values fror group ' + group);
|
|
996
|
+
}
|
|
997
|
+
else {
|
|
998
|
+
await this.handleError(res, group);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
else {
|
|
1002
|
+
this.adapter.log.error('State ' + group + '.evchargerSn not found!');
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
catch (e) {
|
|
1007
|
+
this.adapter.log.error('Writing data for group ' + group + ': Exception occurred: ' + e);
|
|
1008
|
+
await this.handleError(this.emptyBody, group);
|
|
1009
|
+
}
|
|
1010
|
+
this.adapter.startGroupTimeout(ReadAfterWriteTimeoutIntervalInS, group);
|
|
1011
|
+
}
|
|
1012
|
+
|
|
934
1013
|
/**
|
|
935
1014
|
* @param {string} group
|
|
936
1015
|
*/
|
|
@@ -1174,6 +1253,7 @@ class ClosedAPI {
|
|
|
1174
1253
|
Group: 'Settings'
|
|
1175
1254
|
, fnct: this.fetchSettingsData.bind(this)
|
|
1176
1255
|
, writeFnct: this.writeSettingsData.bind(this)
|
|
1256
|
+
, writeTimeoutIntervalInS: 5
|
|
1177
1257
|
, enabledName: 'enableSettingsdata'
|
|
1178
1258
|
, intervalName: 'intervalSettingsdataMins'
|
|
1179
1259
|
, intervalFactor: 60
|
|
@@ -2047,7 +2127,7 @@ class ClosedAPI {
|
|
|
2047
2127
|
/**
|
|
2048
2128
|
* @param {string} group
|
|
2049
2129
|
*/
|
|
2050
|
-
async writeSettingsData(group) {
|
|
2130
|
+
async writeSettingsData(group, _updState, _updStateInfo) {
|
|
2051
2131
|
try {
|
|
2052
2132
|
this.adapter.stopGroupWriteTimeout(group);
|
|
2053
2133
|
this.adapter.stopGroupTimeout(group);
|
|
@@ -2336,7 +2416,12 @@ class AlphaEss extends utils.Adapter {
|
|
|
2336
2416
|
|
|
2337
2417
|
this.verifyValue(state.val, group, stateInfo);
|
|
2338
2418
|
|
|
2339
|
-
this.
|
|
2419
|
+
const gidx = this.getStateInfoList().findIndex((/** @type {{ Group: string; }} */ i) => i.Group == group);
|
|
2420
|
+
|
|
2421
|
+
if (gidx >= 0) {
|
|
2422
|
+
const writeTimeOut = this.getStateInfoList()[gidx].writeTimeoutIntervalInS;
|
|
2423
|
+
this.startGroupWriteTimeout(writeTimeOut ? writeTimeOut : 0, group, state, stateInfo);
|
|
2424
|
+
}
|
|
2340
2425
|
}
|
|
2341
2426
|
else {
|
|
2342
2427
|
this.log.debug(`Validation already in progress: ${id}`);
|
|
@@ -2471,15 +2556,17 @@ class AlphaEss extends utils.Adapter {
|
|
|
2471
2556
|
* Start a timer for a given group
|
|
2472
2557
|
* @param {number} intervalInS
|
|
2473
2558
|
* @param {string} group
|
|
2559
|
+
* @param {ioBroker.State} updState
|
|
2560
|
+
* @param {{ alphaAttrName: string; role: string; id: string; name: string; type: string; unit: string; dayIndex?: undefined; } | { alphaAttrName: string; role: string; id: string; name: string; type: string; unit: string; dayIndex: boolean; } | { alphaAttrName: string; role: string; id: string; name: string; type: string; unit: string; writeable: boolean; } | { alphaAttrName: string; role: string; id: string; name: string; type: string; unit: string; round: number; factor?: undefined; } | { alphaAttrName: string; role: string; id: string; name: string; type: string; unit: string; factor: number; round: number; } | { alphaAttrName: string; role: string; id: string; name: string; type: string; unit: string; round?: undefined; factor?: undefined; } | { alphaAttrName: string; role: string; id: string; name: string; type: string; unit: string; isStatic: boolean; writeable?: undefined; readable?: undefined; states?: undefined; } | { alphaAttrName: string; role: string; id: string; name: string; type: string; unit: string; states: { 0: string; 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; }; isStatic?: undefined; writeable?: undefined; readable?: undefined; }} updStateInfo
|
|
2474
2561
|
*/
|
|
2475
|
-
startGroupWriteTimeout(intervalInS, group) {
|
|
2562
|
+
startGroupWriteTimeout(intervalInS, group, updState, updStateInfo) {
|
|
2476
2563
|
const gidx = this.getStateInfoList().findIndex((/** @type {{ Group: string; }} */ i) => i.Group == group);
|
|
2477
2564
|
if (!this.getStateInfoList()[gidx].writeTimeoutHandle) {
|
|
2478
2565
|
const interval = intervalInS * 1000;
|
|
2479
2566
|
this.log.debug('Write Timeout with interval ' + interval + ' ms started for group ' + group);
|
|
2480
2567
|
const wf = this.getStateInfoList()[gidx].writeFnct;
|
|
2481
2568
|
if (wf) {
|
|
2482
|
-
this.getStateInfoList()[gidx].writeTimeoutHandle = this.setTimeout(() => { wf(group); }, interval);
|
|
2569
|
+
this.getStateInfoList()[gidx].writeTimeoutHandle = this.setTimeout(() => { wf(group, updState, updStateInfo); }, interval);
|
|
2483
2570
|
}
|
|
2484
2571
|
}
|
|
2485
2572
|
}
|
|
@@ -2511,10 +2598,11 @@ class AlphaEss extends utils.Adapter {
|
|
|
2511
2598
|
/**
|
|
2512
2599
|
* Create states when called the first time, update state values in each call
|
|
2513
2600
|
* @param {string} group
|
|
2514
|
-
* @param {{ [s: string]: any; }} data
|
|
2601
|
+
* @param {{ [s: string]: any; } | null} data
|
|
2515
2602
|
*/
|
|
2516
2603
|
async createAndUpdateStates(group, data) {
|
|
2517
2604
|
try {
|
|
2605
|
+
|
|
2518
2606
|
if (data) {
|
|
2519
2607
|
await this.setStateChangedAsync('info.connection', true, true);
|
|
2520
2608
|
this.errorCount = 0;
|
|
@@ -2523,6 +2611,8 @@ class AlphaEss extends utils.Adapter {
|
|
|
2523
2611
|
|
|
2524
2612
|
if (!this.createdStates[group]) {
|
|
2525
2613
|
|
|
2614
|
+
const setObjectFunc = await this.isMigrationNecessary() ? this.setObjectMigrationAsync : this.setObjectNormalAsync;
|
|
2615
|
+
|
|
2526
2616
|
// Delete no longer supported states for this group
|
|
2527
2617
|
const gidx = this.getStateInfoList().findIndex((/** @type {{ Group: string; }} */ i) => i.Group == group);
|
|
2528
2618
|
if (gidx >= 0) {
|
|
@@ -2538,8 +2628,6 @@ class AlphaEss extends utils.Adapter {
|
|
|
2538
2628
|
}
|
|
2539
2629
|
}
|
|
2540
2630
|
|
|
2541
|
-
const setObjectFunc = await this.isMigrationNecessary() ? this.setObjectMigrationAsync : this.setObjectNormalAsync;
|
|
2542
|
-
|
|
2543
2631
|
// Create the folder for this group
|
|
2544
2632
|
await setObjectFunc(group, {
|
|
2545
2633
|
type: 'folder',
|
|
@@ -2551,22 +2639,34 @@ class AlphaEss extends utils.Adapter {
|
|
|
2551
2639
|
native: {}
|
|
2552
2640
|
});
|
|
2553
2641
|
|
|
2642
|
+
// Create all static states:
|
|
2643
|
+
const groupStateList = this.getStateInfoList()[gidx].states;
|
|
2644
|
+
if (!this.createdStates[group]) {
|
|
2645
|
+
for (const stateInfo of groupStateList) {
|
|
2646
|
+
if (stateInfo.isStatic) {
|
|
2647
|
+
await this.createStateForAttribute(group, data, stateInfo.alphaAttrName, stateInfo, setObjectFunc);
|
|
2648
|
+
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
|
|
2554
2653
|
// Create all states for received elements
|
|
2555
|
-
for (const [alphaAttrName
|
|
2654
|
+
for (const [alphaAttrName] of Object.entries(data)) {
|
|
2556
2655
|
const stateInfo = await this.getStateInfoByAlphaAttrName(group, alphaAttrName);
|
|
2557
2656
|
if (typeof data[alphaAttrName] !== 'object') {
|
|
2558
|
-
await this.createStateForAttribute(group, data,
|
|
2657
|
+
await this.createStateForAttribute(group, data, alphaAttrName, stateInfo, setObjectFunc);
|
|
2559
2658
|
}
|
|
2560
2659
|
else {
|
|
2561
2660
|
// Look for subvalues:
|
|
2562
2661
|
if (data[alphaAttrName]) {
|
|
2563
|
-
for (const [alphaAttrName2
|
|
2662
|
+
for (const [alphaAttrName2] of Object.entries(data[alphaAttrName])) {
|
|
2564
2663
|
const stateInfo2 = await this.getStateInfoByAlphaAttrName(group, alphaAttrName2);
|
|
2565
|
-
await this.createStateForAttribute(group, data[alphaAttrName],
|
|
2664
|
+
await this.createStateForAttribute(group, data[alphaAttrName], alphaAttrName2, stateInfo2, setObjectFunc);
|
|
2566
2665
|
}
|
|
2567
2666
|
}
|
|
2568
2667
|
}
|
|
2569
2668
|
}
|
|
2669
|
+
|
|
2570
2670
|
this.log.info('Initialized states for : ' + group);
|
|
2571
2671
|
this.createdStates[group] = true;
|
|
2572
2672
|
}
|
|
@@ -2598,11 +2698,10 @@ class AlphaEss extends utils.Adapter {
|
|
|
2598
2698
|
*
|
|
2599
2699
|
* create the state for the received element
|
|
2600
2700
|
* @param {string} group
|
|
2601
|
-
* @param {{[x: string]: any;}} data
|
|
2602
|
-
* @param {string} rawValue
|
|
2701
|
+
* @param {{[x: string]: any;} | null} data
|
|
2603
2702
|
* @param {string} alphaAttrName
|
|
2604
2703
|
*/
|
|
2605
|
-
async createStateForAttribute(group, data,
|
|
2704
|
+
async createStateForAttribute(group, data, alphaAttrName, stateInfo, setObjectFunc) {
|
|
2606
2705
|
if (stateInfo) {
|
|
2607
2706
|
// The type checker has a problem with type: stateInfo.type. I have no clue why.
|
|
2608
2707
|
// All possible types are correct and valid. To get rid of the type checker error, we check for valid types:
|
|
@@ -2613,30 +2712,30 @@ class AlphaEss extends utils.Adapter {
|
|
|
2613
2712
|
name: stateInfo.name + ' [' + stateInfo.alphaAttrName + ']'
|
|
2614
2713
|
, type: stateInfo.type
|
|
2615
2714
|
, role: stateInfo.role
|
|
2616
|
-
, read: true
|
|
2715
|
+
, read: stateInfo.readable != null ? stateInfo.readable : true
|
|
2617
2716
|
, write: stateInfo.writeable ? stateInfo.writeable : false
|
|
2618
|
-
, unit: stateInfo.unit === '{money_type}' ? data['money_type'] : stateInfo.unit === '{moneyType}' ? data['moneyType'] : stateInfo.unit
|
|
2717
|
+
, unit: stateInfo.unit === '{money_type}' && data ? data['money_type'] : stateInfo.unit === '{moneyType}' && data ? data['moneyType'] : stateInfo.unit
|
|
2619
2718
|
, desc: stateInfo.alphaAttrName
|
|
2620
2719
|
, states: stateInfo.states
|
|
2621
2720
|
},
|
|
2622
2721
|
native: {},
|
|
2623
2722
|
});
|
|
2624
|
-
this.log.debug('Created object ' + group + '.' + this.osn(stateInfo.alphaAttrName)
|
|
2723
|
+
this.log.debug('Created object ' + group + '.' + this.osn(stateInfo.alphaAttrName));
|
|
2625
2724
|
if (stateInfo.writeable) {
|
|
2626
2725
|
await this.subscribeStatesAsync(`${group}.${stateInfo.id}`);
|
|
2627
2726
|
this.log.debug(`Subscribed State: ${group}.${stateInfo.id}`);
|
|
2628
2727
|
}
|
|
2629
2728
|
}
|
|
2630
2729
|
else {
|
|
2631
|
-
this.log.error('Internal error: Skipped object ' + group + '.' + alphaAttrName + '
|
|
2730
|
+
this.log.error('Internal error: Skipped object ' + group + '.' + alphaAttrName + ' because of invalid type definition!');
|
|
2632
2731
|
}
|
|
2633
2732
|
}
|
|
2634
2733
|
else {
|
|
2635
2734
|
if (alphaAttrName == 'sysSn' || alphaAttrName == 'theDate') {
|
|
2636
|
-
this.log.debug('Skipped object ' + group + '.' + alphaAttrName
|
|
2735
|
+
this.log.debug('Skipped object ' + group + '.' + alphaAttrName);
|
|
2637
2736
|
}
|
|
2638
2737
|
else {
|
|
2639
|
-
this.log.warn('Skipped object ' + group + '.' + alphaAttrName
|
|
2738
|
+
this.log.warn('Skipped object ' + group + '.' + alphaAttrName);
|
|
2640
2739
|
}
|
|
2641
2740
|
}
|
|
2642
2741
|
}
|
|
@@ -2718,12 +2817,12 @@ class AlphaEss extends utils.Adapter {
|
|
|
2718
2817
|
|
|
2719
2818
|
/**
|
|
2720
2819
|
* Answer the state description object for a given group and id
|
|
2721
|
-
* @param {string}
|
|
2820
|
+
* @param {string} group
|
|
2722
2821
|
* @param {string} id
|
|
2723
2822
|
*/
|
|
2724
|
-
getStateInfoById(
|
|
2823
|
+
getStateInfoById(group, id) {
|
|
2725
2824
|
try {
|
|
2726
|
-
const gidx = this.getStateInfoList().findIndex((/** @type {{ Group: string; }} */ i) => i.Group ==
|
|
2825
|
+
const gidx = this.getStateInfoList().findIndex((/** @type {{ Group: string; }} */ i) => i.Group == group);
|
|
2727
2826
|
if (gidx >= 0) {
|
|
2728
2827
|
const currentList = this.getStateInfoList()[gidx].states;
|
|
2729
2828
|
const sidx = currentList.findIndex((/** @type {{ id: string; }} */ i) => i.id == id);
|
|
@@ -2735,7 +2834,7 @@ class AlphaEss extends utils.Adapter {
|
|
|
2735
2834
|
}
|
|
2736
2835
|
catch (e) {
|
|
2737
2836
|
this.log.error('getStateInfo Exception occurred: ' + e);
|
|
2738
|
-
this.log.info('Group: ' +
|
|
2837
|
+
this.log.info('Group: ' + group);
|
|
2739
2838
|
this.log.info('alphaAttrName: ' + id);
|
|
2740
2839
|
return null;
|
|
2741
2840
|
}
|