iobroker.sun2000 0.3.0 → 0.3.1

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
@@ -72,6 +72,9 @@ The development of this adapter was inspired by discussions from the forum threa
72
72
  Placeholder for the next version (at the beginning of the line):
73
73
  ### **WORK IN PROGRESS**
74
74
  -->
75
+ ### 0.3.1 (2024-02-12)
76
+ * state `sun2000.0.collected.chargeDischargePowercharge` is not always refreshed #47
77
+
75
78
  ### 0.3.0 (2024-02-10)
76
79
  * add battery unit information for example temperature #40
77
80
  * modbus timeout, connect delay and delay can be configured #34
@@ -68,8 +68,8 @@
68
68
  "connectDelay": {
69
69
  "type": "number",
70
70
  "label": "connect delay (ms)",
71
- "min" : 1000,
72
- "max" : 15000,
71
+ "min" : 2000,
72
+ "max" : 10000,
73
73
  "newLine": true,
74
74
  "tooltip": "delay after modbus connected"
75
75
  },
package/io-package.json CHANGED
@@ -1,8 +1,21 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "sun2000",
4
- "version": "0.3.0",
4
+ "version": "0.3.1",
5
5
  "news": {
6
+ "0.3.1": {
7
+ "en": "state `sun2000.0.collected.chargeDischargePowercharge` is not always refreshed #47",
8
+ "de": "state `sun2000.0.collected.chargeDischargePowercharge` ist nicht immer erfrischt #47",
9
+ "ru": "состояние `sun2000.0.collected.chargeDischargePowercharge' не всегда обновляется #47",
10
+ "pt": "estado `sun2000.0.collected.chargeDischargePowercharge` nem sempre é atualizado #47",
11
+ "nl": "staat ",
12
+ "fr": "état `sun2000.0.collected.chargeDéchargePowercharge` n'est pas toujours rafraîchi #47",
13
+ "it": "stato `sun2000.0.colletto.chargeDischargePowercharge` non è sempre aggiornato #47",
14
+ "es": "estado `sun2000.0.collected.chargeDischargePowercharge` no siempre se actualiza #47",
15
+ "pl": "state 'sun2000.0.0 collected.chargeDischargePowercharge' nie zawsze jest odświeżona # 47",
16
+ "uk": "#47",
17
+ "zh-cn": "state `sun 2000.00.colled. 充电电源 ' 并不总是刷新47"
18
+ },
6
19
  "0.3.0": {
7
20
  "en": "add battery unit information for example temperature #40\nmodbus timeout, connect delay and delay can be configured #34\ndevice status as plain text `sun2000.0.inverter.x.derived.deviceStatus`\nIntroduction of a driver model. A separate driver can be created for each device #41",
8
21
  "de": "batterieeinheitsinformationen hinzufügen, zum beispiel temperatur #40\nmodbus timeout, verbinden verzögerung und verzögerung kann #34 konfiguriert werden\ngerätestatus als Klartext `sun2000.0.inverter.x.derived.deviceStatus `\nEinführung eines Fahrermodells. Ein separater Treiber kann für jedes Gerät #41 erstellt werden",
package/lib/drivers.js CHANGED
@@ -223,7 +223,8 @@ class DriverSun2000 extends DriverBase{
223
223
  type : deviceType.battery,
224
224
  states : [{
225
225
  state: {id: 'battery.chargeDischargePower', name: 'Charge/Discharge power', desc: '(>0 charging, <0 discharging)', type: 'number', unit: 'kW', role: 'value.power'},
226
- register: {reg: 37765, type: dataType.int32, gain:1000},
226
+ register: {reg: 37765, type: dataType.int32, gain:1000}
227
+ //store : storeType.always
227
228
  }]
228
229
  },
229
230
  {
@@ -79,18 +79,26 @@ class ModbusConnect extends DeviceInterface {
79
79
 
80
80
  close() {
81
81
  return new Promise((resolve) => {
82
- this.client.close(() => {
82
+ if (this.client) {
83
+ this.client.close(() => {
84
+ resolve({});
85
+ });
86
+ } else {
83
87
  resolve({});
84
- } );
88
+ }
85
89
  });
86
90
  }
87
91
 
88
92
  //https://github.com/yaacov/node-modbus-serial/issues/96
89
93
  _destroy() {
90
94
  return new Promise((resolve) => {
91
- this.client.destroy(() => {
95
+ if (this.client) {
96
+ this.client.destroy(() => {
97
+ resolve({});
98
+ });
99
+ } else {
92
100
  resolve({});
93
- });
101
+ }
94
102
  });
95
103
  }
96
104
 
@@ -202,7 +210,7 @@ class ModbusConnect extends DeviceInterface {
202
210
 
203
211
  //### Test ###
204
212
  if (testMode) {
205
- if (this._options.delay < 1500 && successful) successful = false;
213
+ if (this._options.delay < 5000 && successful) successful = false;
206
214
  }
207
215
  //### Test ###
208
216
  if (successful) {
@@ -235,11 +243,12 @@ class ModbusConnect extends DeviceInterface {
235
243
  //Bleibende Regelabweichnung beseitigen
236
244
  if (this._options.delay-50 < this._options.min ) this._options.delay = this._options.min;
237
245
 
238
- if (this._options.timeout > 15000 && this._options.delay*3 < this._options.timeout ) {
239
- this._options.timeout = 15000;
246
+ if (this._options.delay*5 < this._options.timeout ) {
247
+ this._options.timeout = this._options.delay*5;
248
+ if (this._options.timeout < 10000) this._options.timeout = 10000;
240
249
  }
241
250
 
242
- if (this._options.connectDelay > 5000 && this._options.Delay*1.5 < this._options.connectDelay) {
251
+ if (this._options.Delay*1.5 < this._options.connectDelay) {
243
252
  this._options.connectDelay = this._options.Delay*1.5;
244
253
  if (this._options.connectDelay < 2000) this._options.connectDelay = 2000;
245
254
  }
@@ -264,8 +273,8 @@ class ModbusConnect extends DeviceInterface {
264
273
  //increase
265
274
  this._options.delay += getGradient(this.info);
266
275
  }
267
- if (this._options.delay*3 > this._options.timeout) {
268
- this._options.timeout = this._options.delay*3;
276
+ if (this._options.delay*5 > this._options.timeout) {
277
+ this._options.timeout = this._options.delay*5;
269
278
  }
270
279
  if (this._options.delay*1.5 > this._options.connectDelay) {
271
280
  this._options.connectDelay = this._options.delay*1.5;
package/lib/register.js CHANGED
@@ -30,10 +30,10 @@ class Registers {
30
30
  let inPowerEff = 0;
31
31
  let chargeDischarge = 0;
32
32
  for (const inverter of inverters) {
33
- sum += this.stateCache.get(inverter.path+'.activePower')?.value;
34
- inPower += this.stateCache.get(inverter.path+'.inputPower')?.value;
33
+ sum += this.stateCache.get(inverter.path+'.activePower')?.value ?? 0;
34
+ inPower += this.stateCache.get(inverter.path+'.inputPower')?.value ?? 0;
35
35
  inPowerEff += this.stateCache.get(inverter.path+'.derived.inputPowerWithEfficiencyLoss')?.value;
36
- chargeDischarge += this.stateCache.get(inverter.path+'.battery.chargeDischargePower')?.value;
36
+ chargeDischarge += this.stateCache.get(inverter.path+'.battery.chargeDischargePower')?.value ?? 0;
37
37
  }
38
38
  //this.adapter.log.debug('++++ collected.inputPower '+inPower);
39
39
  this.stateCache.set('collected.inputPower',inPower,{type: 'number', renew : true});
@@ -82,11 +82,11 @@ class Registers {
82
82
  inYield += this.stateCache.get(inverter.path+'.derived.dailyInputYield')?.value; //deprecated
83
83
  solarYield += this.stateCache.get(inverter.path+'.derived.dailySolarYield')?.value;
84
84
  enYield += this.stateCache.get(inverter.path+'.accumulatedEnergyYield')?.value;
85
- charge += this.stateCache.get(inverter.path+'.battery.currentDayChargeCapacity')?.value;
86
- disCharge += this.stateCache.get(inverter.path+'.battery.currentDayDischargeCapacity')?.value;
87
- totalCharge += this.stateCache.get(inverter.path+'.battery.totalCharge')?.value;
88
- totalDisCharge += this.stateCache.get(inverter.path+'.battery.totalDischarge')?.value;
89
85
  if (this.stateCache.get(inverter.path+'.battery.ratedCapacity')?.value > 0) {
86
+ charge += this.stateCache.get(inverter.path+'.battery.currentDayChargeCapacity')?.value;
87
+ disCharge += this.stateCache.get(inverter.path+'.battery.currentDayDischargeCapacity')?.value;
88
+ totalCharge += this.stateCache.get(inverter.path+'.battery.totalCharge')?.value;
89
+ totalDisCharge += this.stateCache.get(inverter.path+'.battery.totalDischarge')?.value;
90
90
  load += this.stateCache.get(inverter.path+'.battery.ratedCapacity')?.value * this.stateCache.get(inverter.path+'.battery.SOC')?.value;
91
91
  ratedCap += this.stateCache.get(inverter.path+'.battery.ratedCapacity')?.value;
92
92
  }
@@ -171,7 +171,7 @@ class Registers {
171
171
  const detectedModelId = inverter.device.info?.detectedModelId;
172
172
  if ( detectedModelId > 0) {
173
173
  this.createInverterInstance(inverter,detectedModelId);
174
- this.adapter.log.debug(JSON.stringify(inverter.device.info));
174
+ this.adapter.log.debug('DeviceInfo: '+inverter.index+' '+JSON.stringify(inverter.device.info));
175
175
  if (inverter.device.info?.modelId !== detectedModelId) {
176
176
  this.adapter.log.error('No Huawei device could be assigned for model id '+detectedModelId);
177
177
  this.adapter.log.info('Please create an issue: https://github.com/bolliy/ioBroker.sun2000/issues');
@@ -193,9 +193,9 @@ class Registers {
193
193
  if (!hook.initState) {
194
194
  await this.initState('',state);
195
195
  }
196
- hook.fn(this.adapter.inverters);
197
196
  }
198
197
  hook.initState = true;
198
+ hook.fn(this.adapter.inverters);
199
199
  }
200
200
  }
201
201
  this.storeStates(); //fire and forget
package/main.js CHANGED
@@ -224,13 +224,13 @@ class Sun2000 extends utils.Adapter {
224
224
  this.settings.modbusAdjust = info.modbusAdjust;
225
225
  this.settings.modbusDelay = Math.round(info.delay);
226
226
  //siehe jsonConfig.json
227
- if (this.settings.modbusDelay > 6000) this.settings.modbusDelay = 6000; //siehe jsonConfig.json
228
- this.settings.modbusTimeout = info.timeout;
227
+ if (this.settings.modbusDelay > 6000) this.settings.modbusDelay = 6000;
228
+ this.settings.modbusTimeout = Math.round(info.timeout);
229
229
  if (this.settings.modbusTimeout > 30000) this.settings.modbusTimeout = 30000;
230
230
  if (this.settings.modbusTimeout < 5000) this.settings.modbusTimeout = 5000;
231
- this.settings.modbusConnectDelay = info.connectDelay;
232
- if (this.settings.modbusConnectDelay > 15000) this.settings.modbusConnectDelay = 15000;
233
- if (this.settings.modbusConnectDelay < 1000) this.settings.modbusConnectDelay = 1000;
231
+ this.settings.modbusConnectDelay = Math.round(info.connectDelay);
232
+ if (this.settings.modbusConnectDelay > 10000) this.settings.modbusConnectDelay = 10000;
233
+ if (this.settings.modbusConnectDelay < 2000) this.settings.modbusConnectDelay = 2000;
234
234
  //orignal Interval
235
235
  this.settings.highIntervall = this.config.updateInterval*1000;
236
236
  await this.adjustInverval();
@@ -329,6 +329,7 @@ class Sun2000 extends utils.Adapter {
329
329
  if (left < 0) return 0;
330
330
  return left;
331
331
  }
332
+
332
333
  const start = new Date().getTime();
333
334
  this.log.debug('### DataPolling START '+ Math.round((start-this.lastTimeUpdated)/1000)+' sec ###');
334
335
  if (this.lastTimeUpdated > 0 && (start-this.lastTimeUpdated)/1000 > this.settings.highIntervall/1000 + 1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.sun2000",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "sun2000",
5
5
  "author": {
6
6
  "name": "bolliy",