iobroker.sun2000 1.4.0 → 1.4.1-alpha.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/README.md CHANGED
@@ -64,6 +64,11 @@ browse in the [wiki](https://github.com/bolliy/ioBroker.sun2000/wiki)
64
64
  Placeholder for the next version (at the beginning of the line):
65
65
  ### **WORK IN PROGRESS**
66
66
  -->
67
+ ### 1.4.1-alpha.2 (2025-05-20)
68
+ * update dependencies
69
+ * fix: surplus power during battery discharge
70
+ * control: new control value `sun2000.0.control.usableSurplus.bufferHysteresis`
71
+
67
72
  ### 1.4.0 (2025-04-07)
68
73
  * control: new control state `sun2000.0.control.externalPower` #76
69
74
  * fixed issue detected by repository checker #166
@@ -71,12 +76,6 @@ browse in the [wiki](https://github.com/bolliy/ioBroker.sun2000/wiki)
71
76
  ### 1.3.0 (2025-04-02)
72
77
  * usableSurplusPower: new control state `sun2000.0.control.usableSurplus.allowNegativeValue`
73
78
 
74
- ### 1.2.2 (2025-04-01)
75
- * deploy 1.2
76
-
77
- ### 1.2.1 (2025-04-01)
78
- * dependency update
79
-
80
79
  ### 1.2.0 (2025-04-01)
81
80
  * dependency and configuration updates
82
81
  * fix: Object state sDongle.OSVersion to short
package/io-package.json CHANGED
@@ -1,8 +1,21 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "sun2000",
4
- "version": "1.4.0",
4
+ "version": "1.4.1-alpha.2",
5
5
  "news": {
6
+ "1.4.1-alpha.2": {
7
+ "en": "update dependencies\nfix: surplus power during battery discharge\ncontrol: new control value `sun2000.0.control.usableSurplus.bufferHysteresis`",
8
+ "de": "aktualisierung der abhängigkeiten\nfix: überschussleistung während der batterieentladung\nsteuerung: neuer Steuerwert `sun2000.0.control.usableSurplus.bufferHysteresis`",
9
+ "ru": "обновление зависимостей\nисправление: избыточная мощность во время разрядки батареи\nконтроль: новое значение управления 'sun2000.0.control.usableSurplus.bufferHysteresis'",
10
+ "pt": "dependências\ncorreção: energia excedente durante a descarga da bateria\ncontrol: novo valor de controle `sun2000.0.control.usableSurplus.bufferHysteresis`",
11
+ "nl": "afhankelijkheden bijwerken\nfix: overtollig vermogen tijdens batterijontlading\ncontrole: nieuwe controlewaarde ",
12
+ "fr": "mettre à jour les dépendances\nfix: puissance excédentaire pendant la décharge de la batterie\ncontrôle: nouvelle valeur de contrôle `sun2000.0.control.usableSurplus.bufferHystérésis`",
13
+ "it": "aggiornamento dipendenze\nfix: potenza in eccesso durante la scarica della batteria\ncontrollo: nuovo valore di controllo `sun2000.0.control.usableSurplus.bufferHysteresis`",
14
+ "es": "dependencias de actualización\nfijación: superávit durante la descarga de la batería\ncontrol: nuevo valor de control `sun2000.0.control.usableSurplus.bufferHysteresis`",
15
+ "pl": "aktualizacji zależności\nfix: nadwyżka mocy podczas rozładowania akumulatora\ncontrol: nowa wartość kontrolna 'sun2000.0.control.usableSurplus.buverHysteresis'",
16
+ "uk": "оновлення залежності\nвиправити: надлишок живлення при розряді акумулятора\n`sun2000.0.control.usableSurplus.bufferHysteresis`",
17
+ "zh-cn": "更新依赖关系\n固定:电池放电时的剩余功率\n控制: 新的控制值 `sun2000.control.ulySurplus.bufferHysteresis'"
18
+ },
6
19
  "1.4.0": {
7
20
  "en": "control: new control state `sun2000.0.control.externalPower` #76\nfixed issue detected by repository checker #166",
8
21
  "de": "steuerung: neuer Steuerzustand `sun2000.0.control.externalPower` #76\nbehobenes problem erkannt von repository checker #166",
@@ -90,6 +90,26 @@ class ConfigMap {
90
90
  return true;
91
91
  },
92
92
  },
93
+ {
94
+ state: {
95
+ id: 'usableSurplus.bufferHysteresis',
96
+ name: 'BufferSoc hysteresis',
97
+ type: 'number',
98
+ unit: '%',
99
+ role: 'level',
100
+ desc: 'Hysteresis of the bufferSoc [0..10%]',
101
+ },
102
+ fn: async event => {
103
+ if (event.value > 10) {
104
+ event.value = 10;
105
+ }
106
+ if (event.value < 0) {
107
+ event.value = 0;
108
+ }
109
+ event.value = Math.round(event.value);
110
+ return true;
111
+ },
112
+ },
93
113
  {
94
114
  state: {
95
115
  id: 'usableSurplus.allowNegativeValue',
package/lib/register.js CHANGED
@@ -43,38 +43,67 @@ class Registers {
43
43
  },
44
44
  { id: 'collected.usableSurplusPower', name: 'usable surplus power', type: 'number', unit: 'kW', role: 'value.power' },
45
45
  { id: 'collected.externalPower', name: 'external power', type: 'number', unit: 'kW', role: 'value.power' },
46
+ //{ id: 'collected.ratedPower', name: 'rated power', type: 'number', unit: 'kW', role: 'value.power' },
46
47
  ],
47
48
  fn: inverters => {
48
49
  let actPower = 0;
49
50
  let inPower = 0;
50
51
  let inPowerEff = 0;
51
52
  let chargeDischarge = 0;
53
+ let ratedPower = 0;
52
54
 
53
55
  function calcUsableSurplus() {
54
56
  let surplusPower = 0;
55
57
  if (this.adapter.control) {
56
58
  surplusPower += meterPower;
57
- const minSoc = this.adapter.control.get('usableSurplus.minSoc')?.value ?? 0;
59
+
60
+ let minSoc = this.adapter.control.get('usableSurplus.minSoc')?.value ?? 0;
58
61
  const bufferSoc = this.adapter.control.get('usableSurplus.bufferSoc')?.value ?? 0;
59
62
  const residualPower = this.adapter.control.get('usableSurplus.residualPower')?.value ?? 0;
60
63
  const soc = this.stateCache.get('collected.SOC')?.value ?? 0;
61
64
  const allowNegativeValue = this.adapter.control.get('usableSurplus.allowNegativeValue')?.value ?? false;
65
+ const hysterese = this.adapter.control.get('usableSurplus.bufferHysteresis')?.value ?? 0;
66
+ // chargeDischarge
67
+ if (chargeDischarge < 0) {
68
+ surplusPower += chargeDischarge;
69
+ }
70
+
71
+ if (bufferSoc > 0) {
72
+ let threshold = hysterese / 2;
73
+ if (minSoc > bufferSoc - threshold) {
74
+ minSoc = bufferSoc - threshold;
75
+ }
76
+ if (this.bufferOn) {
77
+ threshold = -threshold;
78
+ }
79
+ if (soc >= bufferSoc + threshold) {
80
+ this.bufferOn = true;
81
+ const bufferPower = this.adapter.control.get('usableSurplus.bufferPower')?.value ?? 0;
82
+ surplusPower += bufferPower / 1000;
83
+ } else {
84
+ this.bufferOn = false;
85
+ }
86
+ } else {
87
+ this.bufferOn = false;
88
+ }
62
89
 
63
90
  if (soc >= minSoc) {
64
- surplusPower += chargeDischarge;
65
- if (soc < bufferSoc || bufferSoc === 0) {
91
+ if (chargeDischarge > 0) surplusPower += chargeDischarge;
92
+ if (!this.bufferOn) {
66
93
  surplusPower -= residualPower / 1000;
67
94
  }
68
95
  }
69
- if (soc >= bufferSoc && bufferSoc > 0) {
70
- const bufferPower = this.adapter.control.get('usableSurplus.bufferPower')?.value ?? 0;
71
- surplusPower += bufferPower / 1000;
72
- }
73
96
 
74
- //this.adapter.log.info(`### TEST usableSurplus.minSoc ${minSoc}`);
97
+ if (surplusPower > ratedPower) {
98
+ surplusPower = ratedPower;
99
+ }
75
100
  if (!allowNegativeValue) {
76
101
  if (surplusPower < 0.1) surplusPower = 0;
77
102
  }
103
+
104
+ this.adapter.log.debug(
105
+ `### Caculate usableSurplus power ${surplusPower} bufferOn ${this.bufferOn} soc ${soc} minSoc ${minSoc} bufferSoc ${bufferSoc} threshold ${hysterese / 2}`,
106
+ );
78
107
  }
79
108
  return surplusPower;
80
109
  }
@@ -87,6 +116,8 @@ class Registers {
87
116
  inPower += this.stateCache.get(`${inverter.path}.inputPower`)?.value ?? 0;
88
117
  inPowerEff += this.stateCache.get(`${inverter.path}.derived.inputPowerWithEfficiencyLoss`)?.value ?? 0;
89
118
  chargeDischarge += this.stateCache.get(`${inverter.path}.battery.chargeDischargePower`)?.value ?? 0;
119
+ ratedPower += this.stateCache.get(`${inverter.path}.info.ratedPower`)?.value ?? 0;
120
+ //maxChargePower = this.stateCache.get(`${inverter.path}.battery.maximumChargingPower`)?.value ?? 0;
90
121
  }
91
122
 
92
123
  const meterPower = this.stateCache.get('meter.activePower')?.value ?? 0;
@@ -110,6 +141,7 @@ class Registers {
110
141
  type: 'number',
111
142
  });
112
143
  this.stateCache.set('collected.externalPower', extPower, { type: 'number' });
144
+ //this.stateCache.set('collected.ratedPower', ratedPower, { type: 'number' });
113
145
  },
114
146
  },
115
147
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.sun2000",
3
- "version": "1.4.0",
3
+ "version": "1.4.1-alpha.2",
4
4
  "description": "sun2000",
5
5
  "author": {
6
6
  "name": "bolliy",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@iobroker/adapter-core": "^3.2.3",
31
- "modbus-serial": "^8.0.20",
31
+ "modbus-serial": "^8.0.21",
32
32
  "suncalc2": "^1.8.1",
33
33
  "tcp-port-used": "^1.0.2"
34
34
  },
@@ -38,26 +38,26 @@
38
38
  "@alcalzone/release-script-plugin-license": "^3.7.0",
39
39
  "@alcalzone/release-script-plugin-manual-review": "^3.7.0",
40
40
  "@eslint/eslintrc": "^3.3.1",
41
- "@eslint/js": "^9.20.0",
41
+ "@eslint/js": "^9.25.0",
42
42
  "@iobroker/adapter-dev": "^1.4.0",
43
- "@iobroker/eslint-config": "^1.0.1",
43
+ "@iobroker/eslint-config": "^2.0.2",
44
44
  "@iobroker/testing": "^5.0.4",
45
45
  "@tsconfig/node20": "^20.1.5",
46
46
  "@types/chai": "^4.3.20",
47
47
  "@types/chai-as-promised": "^7.1.8",
48
48
  "@types/mocha": "^10.0.10",
49
- "@types/node": "^22.14.0",
49
+ "@types/node": "^22.15.24",
50
50
  "@types/proxyquire": "^1.3.31",
51
51
  "@types/sinon": "^17.0.4",
52
52
  "@types/sinon-chai": "^3.2.12",
53
53
  "chai": "^4.5.0",
54
54
  "chai-as-promised": "^7.1.2",
55
- "globals": "^15.15.0",
56
- "mocha": "^11.1.0",
55
+ "globals": "^16.2.0",
56
+ "mocha": "^11.5.0",
57
57
  "proxyquire": "^2.1.3",
58
58
  "sinon": "^19.0.5",
59
59
  "sinon-chai": "^3.7.0",
60
- "typescript": "~5.7.3"
60
+ "typescript": "~5.8.3"
61
61
  },
62
62
  "main": "main.js",
63
63
  "files": [