iobroker.alpha-ess 1.1.0 → 1.2.0-beta.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 CHANGED
@@ -27,8 +27,6 @@ Staring with version 1.0.0-alpha.5, the quality attribute of each state is set a
27
27
 
28
28
  ## Settings:
29
29
 
30
- <span style="color:red">CAUTION: Currently only Open API is supported because the Closed API was changed by Apha-ESS and cannot be used by third party applications at the moment.</span>
31
-
32
30
  **Used API:** Choose between the inofficial "Closed" API and the official "Open" API
33
31
  Depending on the selected API there are different settings available.
34
32
 
@@ -65,6 +63,14 @@ How to find SN and Check code for registration is described here: https://github
65
63
  **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.**
66
64
 
67
65
  ## Changelog
66
+ ### 1.2.0-beta.0 (2023-11-10)
67
+
68
+ - (Gaspode) Added additional realtime attributes for OpenAPI
69
+
70
+ ### 1.1.1 (2023-11-04)
71
+
72
+ - (Gaspode) Closed API adapted to latest Alpha-ESS changes and enabled again
73
+
68
74
  ### 1.1.0 (2023-11-04)
69
75
 
70
76
  - (Gaspode) Closed API disabled (temporarily?) because API has been changed by Alpha-ESS
@@ -20,21 +20,21 @@
20
20
  "color": "red"
21
21
  },
22
22
  "newLine": true,
23
- "hidden": "data.apiType == 1"
23
+ "hidden": "data.apiType == 1 || data.apiType == 0"
24
24
  },
25
25
  "username": {
26
26
  "sm": 5,
27
27
  "type": "text",
28
28
  "label": "Username",
29
29
  "newLine": true,
30
- "hidden": "data.apiType == 1 || data.apiType == 0"
30
+ "hidden": "data.apiType == 1 || data.apiType == 3"
31
31
  },
32
32
  "password": {
33
33
  "sm": 5,
34
34
  "type": "password",
35
35
  "label": "Password",
36
36
  "newLine": true,
37
- "hidden": "data.apiType == 1 || data.apiType == 0"
37
+ "hidden": "data.apiType == 1 || data.apiType == 3"
38
38
  },
39
39
  "appID": {
40
40
  "sm": 5,
@@ -55,12 +55,12 @@
55
55
  "type": "text",
56
56
  "label": "Alpha ESS System ID",
57
57
  "newLine": true,
58
- "disabled": "data.apiType == 0"
58
+ "disabled": "data.apiType == 3"
59
59
  },
60
60
  "enableRealtimedata": {
61
61
  "type": "checkbox",
62
62
  "newLine": true,
63
- "hidden": "data.apiType == 1 || data.apiType == 0"
63
+ "hidden": "data.apiType == 1 || data.apiType == 3"
64
64
  },
65
65
  "intervalRealtimedata": {
66
66
  "sm": 5,
@@ -69,12 +69,12 @@
69
69
  "label": "Interval to read realtime data",
70
70
  "newLine": false,
71
71
  "disabled": "!data.enableRealtimedata",
72
- "hidden": "data.apiType == 1 || data.apiType == 0"
72
+ "hidden": "data.apiType == 1 || data.apiType == 3"
73
73
  },
74
74
  "enableEnergydata": {
75
75
  "type": "checkbox",
76
76
  "newLine": true,
77
- "hidden": "data.apiType == 1 || data.apiType == 0"
77
+ "hidden": "data.apiType == 1 || data.apiType == 3"
78
78
  },
79
79
  "intervalEnergydataMins": {
80
80
  "sm": 5,
@@ -83,12 +83,12 @@
83
83
  "label": "Interval to read energy data",
84
84
  "newLine": false,
85
85
  "disabled": "!data.enableEnergydata",
86
- "hidden": "data.apiType == 1 || data.apiType == 0"
86
+ "hidden": "data.apiType == 1 || data.apiType == 3"
87
87
  },
88
88
  "enableSettingsdata": {
89
89
  "type": "checkbox",
90
90
  "newLine": true,
91
- "hidden": "data.apiType == 1 || data.apiType == 0"
91
+ "hidden": "data.apiType == 1 || data.apiType == 3"
92
92
  },
93
93
  "enableSettingsCharge": {
94
94
  "type": "checkbox",
@@ -125,12 +125,12 @@
125
125
  "label": "Interval to read settings data",
126
126
  "newLine": false,
127
127
  "disabled": "!data.enableSettingsdata",
128
- "hidden": "data.apiType == 1 || data.apiType == 0"
128
+ "hidden": "data.apiType == 1 || data.apiType == 3"
129
129
  },
130
130
  "enableStatisticalTodaydata": {
131
131
  "type": "checkbox",
132
132
  "newLine": true,
133
- "hidden": "data.apiType == 1 || data.apiType == 0"
133
+ "hidden": "data.apiType == 1 || data.apiType == 3"
134
134
  },
135
135
  "intervalStatisticalTodaydataMins": {
136
136
  "sm": 5,
@@ -139,12 +139,12 @@
139
139
  "label": "Interval to read statistical data (today)",
140
140
  "newLine": false,
141
141
  "disabled": "!data.enableStatisticalTodaydata",
142
- "hidden": "data.apiType == 1 || data.apiType == 0"
142
+ "hidden": "data.apiType == 1 || data.apiType == 3"
143
143
  },
144
144
  "enableSummarydata": {
145
145
  "type": "checkbox",
146
146
  "newLine": true,
147
- "hidden": "data.apiType == 1 || data.apiType == 0"
147
+ "hidden": "data.apiType == 1 || data.apiType == 3"
148
148
  },
149
149
  "intervalSummarydataMins": {
150
150
  "sm": 5,
@@ -153,7 +153,7 @@
153
153
  "label": "Interval to read summary data",
154
154
  "newLine": false,
155
155
  "disabled": "!data.enableSummarydata",
156
- "hidden": "data.apiType == 1 || data.apiType == 0"
156
+ "hidden": "data.apiType == 1 || data.apiType == 3"
157
157
  },
158
158
  "oAEnableRealtime": {
159
159
  "type": "checkbox",
@@ -257,7 +257,7 @@
257
257
  "type": "checkbox",
258
258
  "label": "Update unchanged states",
259
259
  "newLine": true,
260
- "hidden": "data.apiType == 0"
260
+ "hidden": "data.apiType == 3"
261
261
  }
262
262
  }
263
263
  }
package/io-package.json CHANGED
@@ -1,8 +1,34 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "alpha-ess",
4
- "version": "1.1.0",
4
+ "version": "1.2.0-beta.0",
5
5
  "news": {
6
+ "1.2.0-beta.0": {
7
+ "en": "Added additional realtime attributes for OpenAPI",
8
+ "de": "Zusätzliche Echtzeit-Attribute für OpenAPI hinzugefügt",
9
+ "ru": "Добавлены дополнительные атрибуты в реальном времени для OpenAPI",
10
+ "pt": "Adicionado atributos em tempo real adicionais para OpenAPI",
11
+ "nl": "Toegevoegd aanvullingen voor OpenAPI",
12
+ "fr": "Ajout d'autres attributs en temps réel pour OpenAPI",
13
+ "it": "Aggiunto attributi in tempo reale aggiuntivi per OpenAPI",
14
+ "es": "Atributos adicionales en tiempo real para OpenAPI",
15
+ "pl": "Dodać dodatkowe atrybuty dla OpenAPI",
16
+ "uk": "Додано додаткові атрибути в режимі реального часу для OpenAPI",
17
+ "zh-cn": "增加开放协会实时归属"
18
+ },
19
+ "1.1.1": {
20
+ "en": "Closed API adapted to latest Alpha-ESS changes and enabled again",
21
+ "de": "Closed API angepasst an neueste Alpha-ESS-Änderungen und wieder aktiviert",
22
+ "ru": "Закрытый API адаптирован к последним изменениям Alpha-ESS и включен снова",
23
+ "pt": "API fechada adaptada às últimas alterações Alpha-ESS e ativada novamente",
24
+ "nl": "Quality over Quantity (QoQ) Releases Vertaling:",
25
+ "fr": "API fermée adaptée aux derniers changements Alpha-ESS et réactivée",
26
+ "it": "API chiusa adattata alle ultime modifiche Alpha-ESS e abilitata di nuovo",
27
+ "es": "API cerrada adaptada a los últimos cambios de Alpha-ESS y habilitada de nuevo",
28
+ "pl": "Zamknięty interfejs API zaadaptował się do najnowszych zmian Alpha-ESS i umożliwił powtórzenie się",
29
+ "uk": "Закритий API, адаптований до останніх змін Альфа-ESS і знову ввімкнено",
30
+ "zh-cn": "适应最近Alpha-ESS变革的贴近性联谊会再次促成了变革。"
31
+ },
6
32
  "1.1.0": {
7
33
  "en": "Closed API disabled (temporarily?) because API has been changed by Alpha-ESS\nRead back changed settings values 2 seconds after they have been changed",
8
34
  "de": "Closed API deaktiviert (vorläufig?), weil die API von Alpha-ESS geändert wurde\nLesen Sie zurück geänderte Einstellungen Werte 2 Sekunden nachdem sie geändert wurden",
@@ -67,32 +93,6 @@
67
93
  "pl": "Zmienił odstępy dla OpenAPI zgodnie z nowymi specjami Alpha-ESS\nUstalono jakość państwa zgodnie z statusem danych",
68
94
  "uk": "Змінено дозволені інтервали для OpenAPI відповідно до нових специфікацій Альфа-ESS\nВстановити якість держави відповідно до стану даних",
69
95
  "zh-cn": "根据Alpha-ESS的新投机,修改后允许有时间开放性倾向。\n相应地确定数据状况的国家质量"
70
- },
71
- "1.0.0-alpha.4": {
72
- "en": "Writing settings implemented for 'Closed API'",
73
- "de": "Schreiben von Settings für 'Closed API' implementiert",
74
- "ru": "Настройки написания, реализованные для 'Closed API'",
75
- "pt": "Definições de escrita implementadas para ' API fechada'",
76
- "nl": "Schrijf instellingen voor 'Closed API'",
77
- "fr": "Paramètres de rédaction mis en œuvre pour 'API perdue'",
78
- "it": "Impostazioni di scrittura implementate per 'Closed API'",
79
- "es": "Configuración de escritura implementada para 'Closed API'",
80
- "pl": "Scenariusze zaimplementowali \"zniszczone\" API",
81
- "uk": "Написання параметрів, реалізованих для \"Closed API\"",
82
- "zh-cn": "A. 落实的封闭环境"
83
- },
84
- "1.0.0-alpha.3": {
85
- "en": "Slow down requests in case of permanent errors for OpenAPI",
86
- "de": "Verlangsamen von Online-Abfragen bei permanent auftretenden Fehlern (OpenAPI)",
87
- "ru": "Замедлить запросы в случае постоянных ошибок для OpenAPI",
88
- "pt": "Abranda os pedidos em caso de erros permanentes para o OpenAPI",
89
- "nl": "Vertragen verzoeken in geval van permanente fouten voor OpenAPI",
90
- "fr": "Ralentissez les requêtes en cas d'erreurs permanentes pour OpenAPI",
91
- "it": "Rallentare le richieste in caso di errori permanenti per OpenAPI",
92
- "es": "Reduzca las solicitudes en caso de errores permanentes para OpenAPI",
93
- "pl": "Slow down requests as permanent error for OpenAPI",
94
- "uk": "Повільні запити у разі постійних помилок для OpenAPI",
95
- "zh-cn": "对开放式企业投机的长期错误请求下降"
96
96
  }
97
97
  },
98
98
  "titleLang": {
package/main.js CHANGED
@@ -14,7 +14,7 @@ const axios = require('axios').default;
14
14
  const CA_AUTHPREFIX = 'al8e4s';
15
15
  const CA_AUTHCONSTANT = 'LS885ZYDA95JVFQKUIUUUV7PQNODZRDZIS4ERREDS0EED8BCWSS';
16
16
  const CA_AUTHSUFFIX = 'ui893ed';
17
- const CA_BaseURI = 'https://cloud.alphaess.com/';
17
+ const CA_BaseURI = 'https://www.alphaess-cloud.com/';
18
18
  const OA_BaseURI = 'https://openapi.alphaess.com/api';
19
19
 
20
20
  const WriteTimeoutIntervalInS = 5;
@@ -46,6 +46,51 @@ class OpenAPI {
46
46
  , type: 'number'
47
47
  , unit: 'W'
48
48
  },
49
+ {
50
+ alphaAttrName: 'ppv1'
51
+ , role: 'value.power'
52
+ , id: 'PV_power_string_1'
53
+ , name: 'PV power string 1'
54
+ , type: 'number'
55
+ , unit: 'W'
56
+ , dayIndex: false
57
+ },
58
+ {
59
+ alphaAttrName: 'ppv2'
60
+ , role: 'value.power'
61
+ , id: 'PV_power_string_2'
62
+ , name: 'PV power string 2'
63
+ , type: 'number'
64
+ , unit: 'W'
65
+ , dayIndex: false
66
+ },
67
+ {
68
+ alphaAttrName: 'ppv3'
69
+ , role: 'value.power'
70
+ , id: 'PV_power_string_3'
71
+ , name: 'PV power string 3'
72
+ , type: 'number'
73
+ , unit: 'W'
74
+ , dayIndex: false
75
+ },
76
+ {
77
+ alphaAttrName: 'ppv4'
78
+ , role: 'value.power'
79
+ , id: 'PV_power_string_4'
80
+ , name: 'PV power string 4'
81
+ , type: 'number'
82
+ , unit: 'W'
83
+ , dayIndex: false
84
+ },
85
+ {
86
+ alphaAttrName: 'pmeterDc'
87
+ , role: 'value.power'
88
+ , id: 'PV_power_meter'
89
+ , name: 'PV power meter'
90
+ , type: 'number'
91
+ , unit: 'W'
92
+ , dayIndex: false
93
+ },
49
94
  {
50
95
  alphaAttrName: 'pload'
51
96
  , role: 'value.power'
@@ -62,6 +107,30 @@ class OpenAPI {
62
107
  , type: 'number'
63
108
  , unit: '%'
64
109
  },
110
+ {
111
+ alphaAttrName: 'pmeterL1'
112
+ , role: 'value.power'
113
+ , id: 'Grid_power_L1'
114
+ , name: 'Grid power L1'
115
+ , type: 'number'
116
+ , unit: 'W'
117
+ },
118
+ {
119
+ alphaAttrName: 'pmeterL2'
120
+ , role: 'value.power'
121
+ , id: 'Grid_power_L2'
122
+ , name: 'Grid power L2'
123
+ , type: 'number'
124
+ , unit: 'W'
125
+ },
126
+ {
127
+ alphaAttrName: 'pmeterL3'
128
+ , role: 'value.power'
129
+ , id: 'Grid_power_L3'
130
+ , name: 'Grid power L3'
131
+ , type: 'number'
132
+ , unit: 'W'
133
+ },
65
134
  {
66
135
  alphaAttrName: 'pgrid'
67
136
  , role: 'value.power'
@@ -81,10 +150,73 @@ class OpenAPI {
81
150
  {
82
151
  alphaAttrName: 'pev'
83
152
  , role: 'value.power'
84
- , id: 'Charging_pile_total'
85
- , name: 'Charging pile (Wallbox) total'
153
+ , id: 'Charging_pile_power_total'
154
+ , name: 'Charging pile (Wallbox) power total'
86
155
  , type: 'number'
87
156
  , unit: 'W'
157
+ },
158
+ {
159
+ alphaAttrName: 'prealL1'
160
+ , role: 'value.power'
161
+ , id: 'Inverter_power_L1'
162
+ , name: 'Inverter power L1'
163
+ , type: 'number'
164
+ , unit: 'W'
165
+ , dayIndex: false
166
+ },
167
+ {
168
+ alphaAttrName: 'prealL2'
169
+ , role: 'value.power'
170
+ , id: 'Inverter_power_L2'
171
+ , name: 'Inverter power L2'
172
+ , type: 'number'
173
+ , unit: 'W'
174
+ , dayIndex: false
175
+ },
176
+ {
177
+ alphaAttrName: 'prealL3'
178
+ , role: 'value.power'
179
+ , id: 'Inverter_power_L3'
180
+ , name: 'Inverter power L3'
181
+ , type: 'number'
182
+ , unit: 'W'
183
+ , dayIndex: false
184
+ },
185
+ {
186
+ alphaAttrName: 'ev1Power'
187
+ , role: 'value.power'
188
+ , id: 'Charging_pile_power_1'
189
+ , name: 'Charging pile (Wallbox) power 1'
190
+ , type: 'number'
191
+ , unit: 'W'
192
+ , dayIndex: false
193
+ },
194
+ {
195
+ alphaAttrName: 'ev2Power'
196
+ , role: 'value.power'
197
+ , id: 'Charging_pile_power_2'
198
+ , name: 'Charging pile (Wallbox) power 2'
199
+ , type: 'number'
200
+ , unit: 'W'
201
+ , dayIndex: false
202
+ },
203
+ {
204
+ alphaAttrName: 'ev3Power'
205
+ , role: 'value.power'
206
+ , id: 'Charging_pile_power_3'
207
+ , name: 'Charging pile (Wallbox) power 3'
208
+ , type: 'number'
209
+ , unit: 'W'
210
+ , dayIndex: false
211
+ },
212
+ {
213
+ alphaAttrName: 'ev4Power'
214
+ , role: 'value.power'
215
+ , id: 'Charging_pile_power_4'
216
+ , name: 'Charging pile (Wallbox) power 4'
217
+ , type: 'number'
218
+ , unit: 'W'
219
+ , dayIndex: false
88
220
  }]
89
221
  },
90
222
  {
@@ -1967,7 +2099,7 @@ class AlphaEss extends utils.Adapter {
1967
2099
  this.log.info('States will be migrated.');
1968
2100
  }
1969
2101
 
1970
- if (this.config.apiType == 0) {
2102
+ if (this.config.apiType == 3) { // For future possibility to disable Closed API
1971
2103
  this.log.error('Closed API: Sorry, Closed API currently not supported because of changes by Alpha-ESS.');
1972
2104
  }
1973
2105
  else {
@@ -2289,34 +2421,15 @@ class AlphaEss extends utils.Adapter {
2289
2421
  // Create all states for received elements
2290
2422
  for (const [alphaAttrName, rawValue] of Object.entries(data)) {
2291
2423
  const stateInfo = this.getStateInfoByAlphaAttrName(group, alphaAttrName);
2292
- if (stateInfo) {
2293
- // The type checker has a problem with type: stateInfo.type. I have no clue why.
2294
- // All possible types are correct and valid. To get rid of the type checker error, we check for valid types:
2295
- if (stateInfo.type == 'string' || stateInfo.type == 'boolean' || stateInfo.type == 'number') {
2296
- await setObjectFunc(group + '.' + this.osn(stateInfo.id), {
2297
- type: 'state',
2298
- common: {
2299
- name: stateInfo.name + ' [' + stateInfo.alphaAttrName + ']'
2300
- , type: stateInfo.type
2301
- , role: stateInfo.role
2302
- , read: true
2303
- , write: stateInfo.writeable ? stateInfo.writeable : false
2304
- , unit: stateInfo.unit === '{money_type}' ? data['money_type'] : stateInfo.unit === '{moneyType}' ? data['moneyType'] : stateInfo.unit
2305
- , desc: stateInfo.alphaAttrName
2306
- },
2307
- native: {},
2308
- });
2309
- if (stateInfo.writeable) {
2310
- await this.subscribeStatesAsync(`${group}.${stateInfo.id}`);
2311
- this.log.debug(`Subscribed State: ${group}.${stateInfo.id}`);
2312
- }
2313
- }
2314
- else {
2315
- this.log.error('Internal error: Skipped object ' + group + '.' + alphaAttrName + ' with value ' + rawValue + ' because of invalid type definition!');
2316
- }
2424
+ if (typeof data[alphaAttrName] !== 'object') {
2425
+ this.createStateForAttribute(group, data, rawValue, alphaAttrName, stateInfo, setObjectFunc);
2317
2426
  }
2318
2427
  else {
2319
- this.log.debug('Skipped object ' + group + '.' + alphaAttrName + ' with value ' + rawValue);
2428
+ // Look for subvalues:
2429
+ for (const [alphaAttrName2, rawValue2] of Object.entries(data[alphaAttrName])) {
2430
+ const stateInfo2 = this.getStateInfoByAlphaAttrName(group, alphaAttrName2);
2431
+ this.createStateForAttribute(group, data[alphaAttrName], rawValue2, alphaAttrName2, stateInfo2, setObjectFunc);
2432
+ }
2320
2433
  }
2321
2434
  }
2322
2435
  this.log.info('Initialized states for : ' + group);
@@ -2326,48 +2439,15 @@ class AlphaEss extends utils.Adapter {
2326
2439
  // Set values for received states
2327
2440
  for (const [alphaAttrName, rawValue] of Object.entries(data)) {
2328
2441
  const stateInfo = this.getStateInfoByAlphaAttrName(group, alphaAttrName);
2329
- if (stateInfo) {
2330
- let value = '';
2331
- if (stateInfo.dayIndex) {
2332
- value = rawValue[idx];
2333
- }
2334
- else {
2335
- value = rawValue;
2336
- }
2337
- this.log.silly(group + '.' + this.osn(stateInfo.id) + ':' + value);
2338
- let tvalue;
2339
- switch (stateInfo.type) {
2340
- case 'number':
2341
- tvalue = Number.parseFloat(value);
2342
- if (stateInfo.factor) {
2343
- tvalue *= stateInfo.factor;
2344
- }
2345
- if (stateInfo.round) {
2346
- tvalue = (Math.round(tvalue * (10 ** stateInfo.round))) / (10 ** stateInfo.round);
2347
- }
2348
- break;
2349
- case 'boolean':
2350
- if (value.toString().toLowerCase() === 'true') {
2351
- tvalue = true;
2352
- }
2353
- else if (value.toString().toLowerCase() === 'false') {
2354
- tvalue = false;
2355
- }
2356
- else {
2357
- tvalue = Number.parseInt(value) != 0;
2358
- }
2359
- break;
2360
- default:
2361
- tvalue = value;
2362
- }
2363
- if (this.config.updateUnchangedStates) {
2364
- await this.setStateAsync(group + '.' + this.osn(stateInfo.id), { val: tvalue, q: 0 }, true);
2365
- }
2366
- else {
2367
- await this.setStateChangedAsync(group + '.' + this.osn(stateInfo.id), { val: tvalue, q: 0 }, true);
2442
+ if (typeof data[alphaAttrName] !== 'object') {
2443
+ this.setValueForAttribute(group, rawValue, stateInfo, idx);
2444
+ }
2445
+ else {
2446
+ // Look for subvalues:
2447
+ for (const [alphaAttrName2, rawValue2] of Object.entries(data[alphaAttrName])) {
2448
+ const stateInfo2 = this.getStateInfoByAlphaAttrName(group, alphaAttrName2);
2449
+ this.setValueForAttribute(group, rawValue2, stateInfo2, idx);
2368
2450
  }
2369
- stateInfo.lastUpdateTs = Date.now();
2370
- this.log.debug('Received object ' + group + '.' + this.osn(stateInfo.alphaAttrName) + ' with value ' + rawValue);
2371
2451
  }
2372
2452
  }
2373
2453
  }
@@ -2377,6 +2457,101 @@ class AlphaEss extends utils.Adapter {
2377
2457
  }
2378
2458
  }
2379
2459
 
2460
+ /**
2461
+ *
2462
+ * create the state for the received element
2463
+ * @param {string} group
2464
+ * @param {{[x: string]: any;}} data
2465
+ * @param {string} rawValue
2466
+ * @param {string} alphaAttrName
2467
+ */
2468
+ async createStateForAttribute(group, data, rawValue, alphaAttrName, stateInfo, setObjectFunc) {
2469
+ if (stateInfo) {
2470
+ // The type checker has a problem with type: stateInfo.type. I have no clue why.
2471
+ // All possible types are correct and valid. To get rid of the type checker error, we check for valid types:
2472
+ if (stateInfo.type == 'string' || stateInfo.type == 'boolean' || stateInfo.type == 'number') {
2473
+ await setObjectFunc(group + '.' + this.osn(stateInfo.id), {
2474
+ type: 'state',
2475
+ common: {
2476
+ name: stateInfo.name + ' [' + stateInfo.alphaAttrName + ']'
2477
+ , type: stateInfo.type
2478
+ , role: stateInfo.role
2479
+ , read: true
2480
+ , write: stateInfo.writeable ? stateInfo.writeable : false
2481
+ , unit: stateInfo.unit === '{money_type}' ? data['money_type'] : stateInfo.unit === '{moneyType}' ? data['moneyType'] : stateInfo.unit
2482
+ , desc: stateInfo.alphaAttrName
2483
+ },
2484
+ native: {},
2485
+ });
2486
+ if (stateInfo.writeable) {
2487
+ await this.subscribeStatesAsync(`${group}.${stateInfo.id}`);
2488
+ this.log.debug(`Subscribed State: ${group}.${stateInfo.id}`);
2489
+ }
2490
+ }
2491
+ else {
2492
+ this.log.error('Internal error: Skipped object ' + group + '.' + alphaAttrName + ' with value ' + rawValue + ' because of invalid type definition!');
2493
+ }
2494
+ }
2495
+ else {
2496
+ if (alphaAttrName == 'sysSn' || alphaAttrName == 'theDate') {
2497
+ this.log.debug('Skipped object ' + group + '.' + alphaAttrName + ' with value ' + rawValue);
2498
+ }
2499
+ else {
2500
+ this.log.warn('Skipped object ' + group + '.' + alphaAttrName + ' with value ' + rawValue);
2501
+ }
2502
+ }
2503
+ }
2504
+
2505
+ /**
2506
+ * @param {string} group
2507
+ * @param {string} rawValue
2508
+ */
2509
+ async setValueForAttribute(group, rawValue, stateInfo, idx) {
2510
+ if (stateInfo) {
2511
+ let value = '';
2512
+ if (stateInfo.dayIndex) {
2513
+ value = rawValue[idx];
2514
+ }
2515
+ else {
2516
+ value = rawValue;
2517
+ }
2518
+ this.log.silly(group + '.' + this.osn(stateInfo.id) + ':' + value);
2519
+ let tvalue;
2520
+ switch (stateInfo.type) {
2521
+ case 'number':
2522
+ tvalue = Number.parseFloat(value);
2523
+ if (stateInfo.factor) {
2524
+ tvalue *= stateInfo.factor;
2525
+ }
2526
+ if (stateInfo.round) {
2527
+ tvalue = (Math.round(tvalue * (10 ** stateInfo.round))) / (10 ** stateInfo.round);
2528
+ }
2529
+ break;
2530
+ case 'boolean':
2531
+ if (value.toString().toLowerCase() === 'true') {
2532
+ tvalue = true;
2533
+ }
2534
+ else if (value.toString().toLowerCase() === 'false') {
2535
+ tvalue = false;
2536
+ }
2537
+ else {
2538
+ tvalue = Number.parseInt(value) != 0;
2539
+ }
2540
+ break;
2541
+ default:
2542
+ tvalue = value;
2543
+ }
2544
+ if (this.config.updateUnchangedStates) {
2545
+ await this.setStateAsync(group + '.' + this.osn(stateInfo.id), { val: tvalue, q: 0 }, true);
2546
+ }
2547
+ else {
2548
+ await this.setStateChangedAsync(group + '.' + this.osn(stateInfo.id), { val: tvalue, q: 0 }, true);
2549
+ }
2550
+ stateInfo.lastUpdateTs = Date.now();
2551
+ this.log.debug('Received object ' + group + '.' + this.osn(stateInfo.alphaAttrName) + ' with value ' + rawValue);
2552
+ }
2553
+ }
2554
+
2380
2555
  /**
2381
2556
  * Answer the state description object for a given group and alpha-ess attribute name
2382
2557
  * @param {string} Group
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.alpha-ess",
3
- "version": "1.1.0",
3
+ "version": "1.2.0-beta.0",
4
4
  "description": "Read and write data from and to Alpha ESS systems.",
5
5
  "author": {
6
6
  "name": "Gaspode",