iobroker.sun2000 0.16.0 → 0.17.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 +7 -1
- package/admin/jsonConfig.json5 +50 -10
- package/io-package.json +14 -14
- package/lib/drivers/driver_inverter.js +0 -3
- package/lib/modbus/modbus_server.js +19 -21
- package/main.js +2 -2
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ Read and write register data from Huawei SUN2000 inverter and LUNA2000 battery u
|
|
|
28
28
|
Feel free to follow the discussions in the german [iobroker forum](https://forum.iobroker.net/topic/71768/test-adapter-sun2000-v0-1-x-huawei-wechselrichter)
|
|
29
29
|
|
|
30
30
|
## Dependencies
|
|
31
|
-
* Node.js 18.
|
|
31
|
+
* Node.js 18.18.0 or higher
|
|
32
32
|
* ioBroker host (js-controller) 5.0.19 or higher
|
|
33
33
|
* ioBroker admin 5.1.13 or higher
|
|
34
34
|
|
|
@@ -65,6 +65,12 @@ browse in the [wiki](https://github.com/bolliy/ioBroker.sun2000/wiki)
|
|
|
65
65
|
Placeholder for the next version (at the beginning of the line):
|
|
66
66
|
### **WORK IN PROGRESS**
|
|
67
67
|
-->
|
|
68
|
+
### 0.17.0 (2024-11-05)
|
|
69
|
+
* adjust for Responsive Design #134
|
|
70
|
+
* migrate to ESLint 9.x
|
|
71
|
+
* node >= v18.18.0
|
|
72
|
+
* modbus-proxy: enabled reading data via input register
|
|
73
|
+
|
|
68
74
|
### 0.16.0 (2024-11-01)
|
|
69
75
|
* dependency and configuration updates
|
|
70
76
|
* read additional register data of Huawei Emma
|
package/admin/jsonConfig.json5
CHANGED
|
@@ -11,7 +11,12 @@
|
|
|
11
11
|
"items": {
|
|
12
12
|
"donateTxt": {
|
|
13
13
|
"type": "staticText",
|
|
14
|
-
"text": "donateTxt"
|
|
14
|
+
"text": "donateTxt",
|
|
15
|
+
"xs": 12,
|
|
16
|
+
"sm": 12,
|
|
17
|
+
"md": 6,
|
|
18
|
+
"lg": 4,
|
|
19
|
+
"xl": 4
|
|
15
20
|
},
|
|
16
21
|
"donateImage": {
|
|
17
22
|
"type": "staticImage",
|
|
@@ -19,8 +24,8 @@
|
|
|
19
24
|
"href" : "https://www.paypal.com/donate/?hosted_button_id=ZTX3VP9LZBDCG",
|
|
20
25
|
"src" : "paypal-button.png",
|
|
21
26
|
"newLine": true,
|
|
22
|
-
"xs":
|
|
23
|
-
"sm":
|
|
27
|
+
"xs": 6,
|
|
28
|
+
"sm": 4,
|
|
24
29
|
"md": 2,
|
|
25
30
|
"lg": 2,
|
|
26
31
|
"xl": 2
|
|
@@ -114,7 +119,12 @@
|
|
|
114
119
|
"chipsTxt": {
|
|
115
120
|
"type": "staticText",
|
|
116
121
|
"text": "Provides the collected data from the SDongle",
|
|
117
|
-
"newLine": true
|
|
122
|
+
"newLine": true,
|
|
123
|
+
"xs": 12,
|
|
124
|
+
"sm": 12,
|
|
125
|
+
"md": 6,
|
|
126
|
+
"lg": 4,
|
|
127
|
+
"xl": 4
|
|
118
128
|
},
|
|
119
129
|
"sd_active": {
|
|
120
130
|
"type": "checkbox",
|
|
@@ -166,7 +176,12 @@
|
|
|
166
176
|
"chipsTxt1": {
|
|
167
177
|
"type": "staticText",
|
|
168
178
|
"text": "Placeholder for future Settings",
|
|
169
|
-
"newLine": true
|
|
179
|
+
"newLine": true,
|
|
180
|
+
"xs": 12,
|
|
181
|
+
"sm": 12,
|
|
182
|
+
"md": 6,
|
|
183
|
+
"lg": 4,
|
|
184
|
+
"xl": 4
|
|
170
185
|
}
|
|
171
186
|
}
|
|
172
187
|
},
|
|
@@ -183,7 +198,12 @@
|
|
|
183
198
|
"chipsTxt": {
|
|
184
199
|
"type": "staticText",
|
|
185
200
|
"text": "Third party device such as wallbox, energy manager etc. can receive and send data even if the modbus interface of inverter is already in use. In addition you can mirror the sun2000 data to another IoBroker instance.",
|
|
186
|
-
"newLine": true
|
|
201
|
+
"newLine": true,
|
|
202
|
+
"xs": 12,
|
|
203
|
+
"sm": 12,
|
|
204
|
+
"md": 6,
|
|
205
|
+
"lg": 4,
|
|
206
|
+
"xl": 4
|
|
187
207
|
},
|
|
188
208
|
"ms_active": {
|
|
189
209
|
"type": "checkbox",
|
|
@@ -244,7 +264,12 @@
|
|
|
244
264
|
"chipsTxt1": {
|
|
245
265
|
"type": "staticText",
|
|
246
266
|
"text": "This control is set in the opject path `sun2000.0.inverter.x.control.battery`",
|
|
247
|
-
"newLine": true
|
|
267
|
+
"newLine": true,
|
|
268
|
+
"xs": 12,
|
|
269
|
+
"sm": 12,
|
|
270
|
+
"md": 6,
|
|
271
|
+
"lg": 4,
|
|
272
|
+
"xl": 4
|
|
248
273
|
},
|
|
249
274
|
"cb_tou": {
|
|
250
275
|
"type": "checkbox",
|
|
@@ -279,7 +304,12 @@
|
|
|
279
304
|
"chipsTxt2": {
|
|
280
305
|
"type": "staticText",
|
|
281
306
|
"text": "This control is set in the opject path `sun2000.0.inverter.x.control.battery`",
|
|
282
|
-
"newLine": true
|
|
307
|
+
"newLine": true,
|
|
308
|
+
"xs": 12,
|
|
309
|
+
"sm": 12,
|
|
310
|
+
"md": 6,
|
|
311
|
+
"lg": 4,
|
|
312
|
+
"xl": 4
|
|
283
313
|
},
|
|
284
314
|
"staticLink2": {
|
|
285
315
|
"type": "staticLink",
|
|
@@ -303,7 +333,12 @@
|
|
|
303
333
|
"chipsTxt3": {
|
|
304
334
|
"type": "staticText",
|
|
305
335
|
"text": "This control is set in the opject path `sun2000.0.inverter.0.control.grid`",
|
|
306
|
-
"newLine": true
|
|
336
|
+
"newLine": true,
|
|
337
|
+
"xs": 12,
|
|
338
|
+
"sm": 12,
|
|
339
|
+
"md": 6,
|
|
340
|
+
"lg": 4,
|
|
341
|
+
"xl": 4
|
|
307
342
|
},
|
|
308
343
|
"staticLink3": {
|
|
309
344
|
"type": "staticLink",
|
|
@@ -429,7 +464,12 @@
|
|
|
429
464
|
"chipsTxt": {
|
|
430
465
|
"type": "staticText",
|
|
431
466
|
"text": "Do you need help? There are multiple ways of getting support. ",
|
|
432
|
-
"newLine": true
|
|
467
|
+
"newLine": true,
|
|
468
|
+
"xs": 12,
|
|
469
|
+
"sm": 12,
|
|
470
|
+
"md": 6,
|
|
471
|
+
"lg": 4,
|
|
472
|
+
"xl": 4
|
|
433
473
|
},
|
|
434
474
|
"staticLink1": {
|
|
435
475
|
"type": "staticLink",
|
package/io-package.json
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"name": "sun2000",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.17.0",
|
|
5
5
|
"news": {
|
|
6
|
+
"0.17.0": {
|
|
7
|
+
"en": "adjust for Responsive Design #134\nmigrate to ESLint 9.x\nnode >= v18.18.0\nmodbus-proxy: enabled reading data via input register",
|
|
8
|
+
"de": "anpassung für Responsive Design #134\nmigration auf ESLint 9.x\nknoten >= v18.18.0\nmodbus-proxy: lesedaten über eingaberegister aktiviert",
|
|
9
|
+
"ru": "#134\nмигрировать в ESLint 9.x\nnode >= v18.18.0\nmodbus-proxy: включено чтение данных через регистр ввода",
|
|
10
|
+
"pt": "ajustar para Design responsivo #134\nmigrar para ESLint 9.x\nnode >= v18.18.0\nmodbus-proxy: dados de leitura habilitados via registro de entrada",
|
|
11
|
+
"nl": "aanpassen voor Responsive Design #134\nmigreren naar ESLint 9.x\nn.v.t\nmodbus-proxy: leesgegevens ingeschakeld via invoerregister",
|
|
12
|
+
"fr": "ajuster pour Responsive Design #134\nmigrer vers ESLint 9.x\nnoeud >= v18.18.0\nmodbus-proxy: activé la lecture des données via le registre d'entrée",
|
|
13
|
+
"it": "regolazione per Responsive Design #134\nmigrare a ESLint 9.x\nnodo >= v18.18.0\nmodbus-proxy: dati di lettura abilitati tramite registro input",
|
|
14
|
+
"es": "ajuste para el diseño responsable #134\nmigrar a ESLint 9.x\nnodo\nmodbus-proxy: datos de lectura habilitados mediante registro de entrada",
|
|
15
|
+
"pl": "dostosowanie dla Responsive Design # 134\nmigrate do ESLint 9.x\nwęzeł > = v18.18.0\nmodbus- proxy: włączone odczytywanie danych poprzez rejestr wejściowy",
|
|
16
|
+
"uk": "конфігурація для відповідального дизайну #134\nmigrate до ESLint 9.x\nвершина >= v18.18.0\nmodbus-proxy: ввімкнено дані читання через вхідний реєстр",
|
|
17
|
+
"zh-cn": "调整响应设计 # 134\n迁移到 ESLint 9.x\n节点 {v18.18.0}\nmodbus- 代理: 启用通过输入寄存器读取数据"
|
|
18
|
+
},
|
|
6
19
|
"0.16.0": {
|
|
7
20
|
"en": "dependency and configuration updates\nread additional register data of Huawei Emma",
|
|
8
21
|
"de": "abhängigkeits- und konfigurationsupdates\nweitere Registrierungsdaten von Huawei Emma lesen",
|
|
@@ -80,19 +93,6 @@
|
|
|
80
93
|
"pl": "poprawić ponowne połączenie Modbus # 116\naktualizacja konfiguracji\nprosta integracja Huawei Emma (Huawei Energy Management Assistant) # 63",
|
|
81
94
|
"uk": "поліпшення відключення Modbus #116\nоновлення конфігурації\nпроста інтеграція Huawei Emma (Huawei Energy Management Assistant) #63",
|
|
82
95
|
"zh-cn": "改进 Modbus 重联 # 116\n配置更新\n简单整合Huawei Emma(Huawei能源管理助理)#63"
|
|
83
|
-
},
|
|
84
|
-
"0.12.1": {
|
|
85
|
-
"en": "no warning from check the valid number during standby: \"no irradiation\"",
|
|
86
|
-
"de": "keine warnung vor der prüfung der gültigen nummer im standby: \"keine bestrahlung\"",
|
|
87
|
-
"ru": "не предупредить проверить действительный номер во время ожидания: «без облучения»",
|
|
88
|
-
"pt": "sem aviso de verificar o número válido durante o standby: \"nenhuma irradiação\"",
|
|
89
|
-
"nl": "geen waarschuwing van controle van het geldige nummer tijdens standby: \"geen bestraling\"",
|
|
90
|
-
"fr": "aucun avertissement de vérifier le nombre valide en attente: \"pas d'irradiation\"",
|
|
91
|
-
"it": "nessun avviso da controllare il numero valido durante la standby: \"nessuna irradiazione\"",
|
|
92
|
-
"es": "no hay advertencia de comprobar el número válido durante la espera: \"no irradiación\"",
|
|
93
|
-
"pl": "brak ostrzeżenia z sprawdzenia poprawnego numeru podczas czuwania: \"brak napromieniowania\"",
|
|
94
|
-
"uk": "без попередження про перевірку дійсного числа під час очікування: \"не опромінення\"",
|
|
95
|
-
"zh-cn": "在待命时不检查有效号码的警告 : “ 不辐射 ”"
|
|
96
96
|
}
|
|
97
97
|
},
|
|
98
98
|
"titleLang": {
|
|
@@ -971,11 +971,8 @@ class InverterSun2000 extends DriverBase{
|
|
|
971
971
|
} else {
|
|
972
972
|
const state = this.stateCache.get(`${this.deviceInfo.path}.battery.unit.${unit}.batteryPack.${pack}.SN`);
|
|
973
973
|
return this.adapter.settings.ds.batteryPacks && state && state.value;
|
|
974
|
-
//return state && state.value;
|
|
975
|
-
//return (state && 'test');
|
|
976
974
|
}
|
|
977
975
|
}
|
|
978
|
-
|
|
979
976
|
}
|
|
980
977
|
|
|
981
978
|
//overload
|
|
@@ -13,19 +13,17 @@ class ModbusServer {
|
|
|
13
13
|
|
|
14
14
|
//https://github.com/yaacov/node-modbus-serial/blob/master/ServerTCP.d.ts
|
|
15
15
|
this.vector = {
|
|
16
|
-
getInputRegister: (addr, unitId, callback) => {
|
|
17
|
-
this.
|
|
18
|
-
callback({ modbusErrorCode: 0x01, msg: 'Illegal function (device does not support this read/write function)' });
|
|
16
|
+
getInputRegister: async (addr, unitId, callback) => {
|
|
17
|
+
await this._handleGetReg('getInputRegister',addr, 1, unitId, callback);
|
|
19
18
|
},
|
|
20
19
|
getHoldingRegister: async (addr, unitId, callback) => {
|
|
21
|
-
await this._handleGetReg(addr, 1, unitId, callback);
|
|
20
|
+
await this._handleGetReg('getHoldingRegister',addr, 1, unitId, callback);
|
|
22
21
|
},
|
|
23
|
-
getMultipleInputRegisters: (startAddr, length,unitId, callback ) => {
|
|
24
|
-
this.
|
|
25
|
-
callback({ modbusErrorCode: 0x01, msg: 'Illegal function (device does not support this read/write function)' });
|
|
22
|
+
getMultipleInputRegisters: async (startAddr, length,unitId, callback ) => {
|
|
23
|
+
await this._handleGetReg('getMultipleInputRegisters',startAddr, length, unitId, callback);
|
|
26
24
|
},
|
|
27
25
|
getMultipleHoldingRegisters: async (startAddr, length, unitId, callback) => {
|
|
28
|
-
await this._handleGetReg(startAddr, length, unitId, callback);
|
|
26
|
+
await this._handleGetReg('getMultipleHoldingRegisters',startAddr, length, unitId, callback);
|
|
29
27
|
},
|
|
30
28
|
getCoil: (addr,unitId, callback) => {
|
|
31
29
|
this._addInfoStat('#getCoil',addr, 1 , unitId);
|
|
@@ -33,10 +31,10 @@ class ModbusServer {
|
|
|
33
31
|
},
|
|
34
32
|
//https://github.com/yaacov/node-modbus-serial/blob/cbd4379bed9672c13ec3a8517d622b728a737a5e/servers/servertcp_handler.js#L925C16-L925C32
|
|
35
33
|
setRegisterArray: async (addr, values, unitId, callback) => {
|
|
36
|
-
await this._handleSetReg(addr,values,unitId, callback);
|
|
34
|
+
await this._handleSetReg('setRegisterArray',addr,values,unitId, callback);
|
|
37
35
|
},
|
|
38
36
|
setRegister: async (addr, value,unitId, callback) => {
|
|
39
|
-
await this._handleSetReg(addr,value,unitId, callback);
|
|
37
|
+
await this._handleSetReg('setRegister',addr,value,unitId, callback);
|
|
40
38
|
},
|
|
41
39
|
setCoil: (addr, value, unitId, callback) => {
|
|
42
40
|
this._addInfoStat('#setCoil',addr, value, unitId);
|
|
@@ -138,7 +136,7 @@ class ModbusServer {
|
|
|
138
136
|
}
|
|
139
137
|
}
|
|
140
138
|
|
|
141
|
-
async _handleGetReg (startAddr, length, unitId, callback) {
|
|
139
|
+
async _handleGetReg (fnName,startAddr, length, unitId, callback) {
|
|
142
140
|
//this.adapter.log.debug('getMultipleHolgingRegisters '+unitId+' '+startAddr+' len '+length+' '+this._isConnected);
|
|
143
141
|
try {
|
|
144
142
|
const device = this.getDeviceInstance(unitId);
|
|
@@ -151,27 +149,27 @@ class ModbusServer {
|
|
|
151
149
|
callback({ modbusErrorCode: 0x05, msg: 'Acknowledge (requested data will be available later)' });
|
|
152
150
|
} else {
|
|
153
151
|
if (values[0] == null) {
|
|
154
|
-
this._addInfoStat('#
|
|
152
|
+
this._addInfoStat('#'+fnName,startAddr, length, unitId);
|
|
155
153
|
await this.wait(200);
|
|
156
154
|
} else {
|
|
157
|
-
this._addInfoStat(
|
|
155
|
+
this._addInfoStat(fnName,startAddr, length, unitId);
|
|
158
156
|
await this.wait(50);
|
|
159
157
|
}
|
|
160
158
|
callback(undefined,values);
|
|
161
159
|
}
|
|
162
160
|
} else {
|
|
163
|
-
this._addInfoStat('#
|
|
161
|
+
this._addInfoStat('#'+fnName,startAddr, length, unitId);
|
|
164
162
|
await this.wait(500);
|
|
165
163
|
callback({ modbusErrorCode: 0x01, msg: 'Illegal function (device does not support this read/write function)' });
|
|
166
164
|
}
|
|
167
|
-
} catch
|
|
168
|
-
this._addInfoStat('#
|
|
165
|
+
} catch {
|
|
166
|
+
this._addInfoStat('#'+fnName,startAddr, length, unitId);
|
|
169
167
|
await this.wait(500);
|
|
170
168
|
callback({ modbusErrorCode: 0x04, msg: 'Slave device failure (device reports internal error)' });
|
|
171
169
|
}
|
|
172
170
|
}
|
|
173
171
|
|
|
174
|
-
async _handleSetReg(address, data, unitId, callback) {
|
|
172
|
+
async _handleSetReg(fnName,address, data, unitId, callback) {
|
|
175
173
|
try {
|
|
176
174
|
this.log.debug('Modbus-proxy: Try to write data to id/address ' + unitId + '/' + address +'/'+ data);
|
|
177
175
|
const device = this.getDeviceInstance(unitId);
|
|
@@ -195,20 +193,20 @@ class ModbusServer {
|
|
|
195
193
|
await this.adapter.modbusClient.writeRegisters(address,data);
|
|
196
194
|
//write also to the read cache
|
|
197
195
|
device.addHoldingRegisters(address,data);
|
|
198
|
-
this._addInfoStat(
|
|
196
|
+
this._addInfoStat(fnName,address,data.length, unitId);
|
|
199
197
|
} else {
|
|
200
198
|
await this.adapter.modbusClient.writeRegister(address,data);
|
|
201
199
|
device.addHoldingRegisters(address,[data]);
|
|
202
|
-
this._addInfoStat(
|
|
200
|
+
this._addInfoStat(fnName,address,1, unitId);
|
|
203
201
|
}
|
|
204
202
|
callback();
|
|
205
203
|
} catch (err) {
|
|
206
204
|
this.log.warn('Modbus-proxy: can not write data to id/address ' + unitId + '/' + address +'/'+ data);
|
|
207
205
|
this.log.warn('Modbus-proxy: '+err?.message);
|
|
208
206
|
if (Array.isArray(data)) {
|
|
209
|
-
this._addInfoStat('#
|
|
207
|
+
this._addInfoStat('#'+fnName,address,data.length, unitId);
|
|
210
208
|
} else {
|
|
211
|
-
this._addInfoStat('#
|
|
209
|
+
this._addInfoStat('#'+fnName,address,1, unitId);
|
|
212
210
|
}
|
|
213
211
|
await this.wait(500);
|
|
214
212
|
callback({ modbusErrorCode: err?.modbusCode, msg: err?.message });
|
package/main.js
CHANGED
|
@@ -320,7 +320,6 @@ class Sun2000 extends utils.Adapter {
|
|
|
320
320
|
this.config.integration = 1;
|
|
321
321
|
this.updateConfig(this.config);
|
|
322
322
|
}
|
|
323
|
-
|
|
324
323
|
await this.setState('info.ip', {val: this.config.address, ack: true});
|
|
325
324
|
await this.setState('info.port', {val: this.config.port, ack: true});
|
|
326
325
|
await this.setState('info.modbusIds', {val: this.config.modbusIds, ack: true});
|
|
@@ -339,6 +338,7 @@ class Sun2000 extends utils.Adapter {
|
|
|
339
338
|
this.settings.modbusIds = this.config.modbusIds.split(',').map((n) => {return Number(n);});
|
|
340
339
|
//SmartDongle
|
|
341
340
|
this.settings.sd.active = this.config.sd_active;
|
|
341
|
+
// eslint-disable-next-line no-constant-binary-expression
|
|
342
342
|
this.settings.sd.sDongleId = Number(this.config.sDongleId) ?? 0;
|
|
343
343
|
if (this.settings.sd.sDongleId < 0 || this.settings.sd.sDongleId >= 255) this.settings.sd.active = false;
|
|
344
344
|
this.settings.highInterval = this.config.updateInterval*1000; //ms
|
|
@@ -527,7 +527,7 @@ class Sun2000 extends utils.Adapter {
|
|
|
527
527
|
this.modbusClient && this.modbusClient.close();
|
|
528
528
|
this.setState('info.connection', false, true);
|
|
529
529
|
callback();
|
|
530
|
-
} catch
|
|
530
|
+
} catch {
|
|
531
531
|
callback();
|
|
532
532
|
}
|
|
533
533
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iobroker.sun2000",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "sun2000",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "bolliy",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"url": "https://github.com/bolliy/ioBroker.sun2000.git"
|
|
25
25
|
},
|
|
26
26
|
"engines": {
|
|
27
|
-
"node": ">= 18"
|
|
27
|
+
"node": ">= 18.18.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@iobroker/adapter-core": "^3.2.2",
|
|
@@ -37,6 +37,8 @@
|
|
|
37
37
|
"@alcalzone/release-script-plugin-iobroker": "^3.7.2",
|
|
38
38
|
"@alcalzone/release-script-plugin-license": "^3.7.0",
|
|
39
39
|
"@alcalzone/release-script-plugin-manual-review": "^3.7.0",
|
|
40
|
+
"@eslint/eslintrc": "^3.1.0",
|
|
41
|
+
"@eslint/js": "^9.14.0",
|
|
40
42
|
"@iobroker/adapter-dev": "^1.3.0",
|
|
41
43
|
"@iobroker/testing": "^5.0.0",
|
|
42
44
|
"@tsconfig/node16": "^16.1.3",
|
|
@@ -49,7 +51,8 @@
|
|
|
49
51
|
"@types/sinon-chai": "^3.2.12",
|
|
50
52
|
"chai": "^4.5.0",
|
|
51
53
|
"chai-as-promised": "^7.1.2",
|
|
52
|
-
"eslint": "^
|
|
54
|
+
"eslint": "^9.14.0",
|
|
55
|
+
"globals": "^15.11.0",
|
|
53
56
|
"mocha": "^10.8.2",
|
|
54
57
|
"proxyquire": "^2.1.3",
|
|
55
58
|
"sinon": "^19.0.2",
|