iobroker.sun2000 2.3.2 → 2.3.4

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
@@ -65,6 +65,15 @@ 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
+ ### 2.3.4 (2025-11-01)
69
+ * dependency and configuration updates
70
+ * new state `collected.dailyExternalYield` Riemann sum of `collected.externalPower`
71
+
72
+ ### 2.3.3 (2025-10-31)
73
+ * Improved verification of the adapter configuration
74
+ * new state `inverter.x.derived.dailyActiveEnergy` Inverter daily active energy, which is determined via the Riemann sum of `inverter.x.activePower`
75
+ * state `collected.dailyInputYield` was redisigned based on inverter.[0..n-1].derived.dailyActiveEnergy
76
+
68
77
  ### 2.3.2 (2025-10-24)
69
78
  * allows again `control.battery.chargeFromGridFunction` when using the Emma
70
79
 
@@ -263,8 +263,20 @@
263
263
  },
264
264
  "chipsTxt1": {
265
265
  "type": "staticText",
266
- "text": "This control is set in the opject path `sun2000.0.inverter.x.control.battery`",
266
+ "text": "This control states are set in the object path `sun2000.0.inverter.x.control.battery`",
267
+ "newLine": true,
268
+ "hidden": "data.integration === 2",
269
+ "xs": 12,
270
+ "sm": 12,
271
+ "md": 6,
272
+ "lg": 4,
273
+ "xl": 4
274
+ },
275
+ "chipsTxt1_1": {
276
+ "type": "staticText",
277
+ "text": "This control states are set in the object path `sun2000.0.emma.control.battery`",
267
278
  "newLine": true,
279
+ "hidden": "data.integration !== 2",
268
280
  "xs": 12,
269
281
  "sm": 12,
270
282
  "md": 6,
@@ -275,7 +287,7 @@
275
287
  "type": "checkbox",
276
288
  "label": "Create default TOU setting",
277
289
  "newLine": true,
278
- "help": "The `default TOU settings` is interesting for the `force battery charging from the grid` function, which is required for variable energy prices.",
290
+ "help": "The `default TOU settings` is interesting for the `charge from the grid` function, which is required for variable energy prices.",
279
291
  "xs": 12,
280
292
  "sm": 12,
281
293
  "md": 6,
@@ -287,6 +299,7 @@
287
299
  "text": "Description with examples",
288
300
  "href": "https://github.com/bolliy/ioBroker.sun2000/wiki/Battery-control",
289
301
  "button": true,
302
+ "hidden": "data.integration === 2",
290
303
  "icon": "info",
291
304
  "newLine": true,
292
305
  "xs": 12,
@@ -295,6 +308,20 @@
295
308
  "lg": 3,
296
309
  "xl": 3
297
310
  },
311
+ "staticLink1_1": {
312
+ "type": "staticLink",
313
+ "text": "Description with examples",
314
+ "href": "https://github.com/bolliy/ioBroker.sun2000/wiki/Emma:-Battery-control",
315
+ "button": true,
316
+ "hidden": "data.integration !== 2",
317
+ "icon": "info",
318
+ "newLine": true,
319
+ "xs": 12,
320
+ "sm": 12,
321
+ "md": 6,
322
+ "lg": 3,
323
+ "xl": 3
324
+ },
298
325
  "mainHdr2": {
299
326
  "newLine": true,
300
327
  "type": "header",
@@ -328,12 +355,14 @@
328
355
  "newLine": true,
329
356
  "type": "header",
330
357
  "text": "Export control",
358
+ "hidden": "data.integration === 2",
331
359
  "size": 2
332
360
  },
333
361
  "chipsTxt3": {
334
362
  "type": "staticText",
335
363
  "text": "This control is set in the opject path `sun2000.0.inverter.0.control.grid`",
336
364
  "newLine": true,
365
+ "hidden": "data.integration === 2",
337
366
  "xs": 12,
338
367
  "sm": 12,
339
368
  "md": 6,
@@ -344,6 +373,7 @@
344
373
  "type": "staticLink",
345
374
  "text": "Description with examples",
346
375
  "href": "https://github.com/bolliy/ioBroker.sun2000/wiki/Begrenzung-Netzeinspeisung-(Export-Control)",
376
+ "hidden": "data.integration === 2",
347
377
  "button": true,
348
378
  "icon": "info",
349
379
  "newLine": true,
package/io-package.json CHANGED
@@ -1,8 +1,34 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "sun2000",
4
- "version": "2.3.2",
4
+ "version": "2.3.4",
5
5
  "news": {
6
+ "2.3.4": {
7
+ "en": "dependency and configuration updates\nnew state `collected.dailyExternalYield` Riemann sum of `collected.externalPower`",
8
+ "de": "abhängigkeits- und konfigurationsupdates\nneuer Zustand `collect.dailyExternalYield` Riemann Summe von `collected.externalPower `",
9
+ "ru": "обновления зависимостей и конфигурации\nновый государственный «коллектив.dailyExternalYield» Riemann sum of 'collected.externalPower пункт",
10
+ "pt": "atualizações de dependência e configuração\nnovo estado «colected.dailyEnergieYield» Riemann soma de `colected.externalPower `",
11
+ "nl": "afhankelijkheid en configuratie-updates\nnieuwe staat Riemann som van gecollecteerd.externe kracht Wat",
12
+ "fr": "mises à jour de la dépendance et de la configuration\nnouvel état `collected.dailyExternalYield` Riemann somme de `collected.externalPower \"",
13
+ "it": "aggiornamenti di dipendenza e configurazione\nnuovo stato `colletto.dailyExternalYield` Riemann somma di `colletto.Power esterno #",
14
+ "es": "actualizaciones de dependencia y configuración\nnuevo estado `colected.dailyExternalYield` Riemann sum of `collected.externalPower `",
15
+ "pl": "aktualizacje zależności i konfiguracji\nnowy stan \"collected.dailyExternalYield\" Riemann sum of 'collected.externalPower'",
16
+ "uk": "оновлення залежності та конфігурації\nновий стан `collected.dailyExternalYield` Сума Riemann `collected.externalPower й",
17
+ "zh-cn": "依赖和配置更新\n新国家`收集.每日外部耶尔德' 收集的里曼总和。 `"
18
+ },
19
+ "2.3.3": {
20
+ "en": "Improved verification of the adapter configuration\nnew state `inverter.x.derived.dailyActiveEnergy` Inverter daily active energy, which is determined via the Riemann sum of `inverter.x.activePower`\nstate `collected.dailyInputYield` was redisigned based on inverter.[0..n-1].derived.dailyActiveEnergy",
21
+ "de": "Verbesserte Überprüfung der Adapterkonfiguration\n`inverter.x.derived.dailyActiveEnergy` Inverter tägliche aktive Energie, die über die Riemann Summe von `inverter.x.activePower bestimmt wird `\nstate `collected.dailyInputYield` wurde basierend auf Inverter zurückgeteilt. [0.n-1].derived.dailyActiveEnergy",
22
+ "ru": "Улучшенная проверка конфигурации адаптера\nновое состояние «inverter.x.derived.dailyActiveEnergy» Инверторная ежедневная активная энергия, которая определяется через сумму Римана 'inverter.x.activePower пункт\nstate 'collected.dailyInputYield' была переопределена на основе инвертора. [0..n-1].derived.dailyActiveEnergy",
23
+ "pt": "Verificação melhorada da configuração do adaptador\nnovo estado «inverter.x.derived.dailyActiveEnergy» Energia ativa diária do inversor, que é determinada através da soma Riemann de `inverter.x.activePower `\nestado `colleted.dailyInputYield` foi reassinado com base no inversor. [0..n-1].derivado.diárioAtividadeEnergia",
24
+ "nl": "Verbeterde verificatie van de configuratie van de adapter\nnieuwe staat Inverter dagelijkse actieve energie, die wordt bepaald via de Riemann som van Wat\nstaat [0..n-1].afgeleid.dailyActiveEnergy",
25
+ "fr": "Amélioration de la vérification de la configuration de l'adaptateur\nnouvel état `inverter.x.derived.dailyActiveEnergy` Inverter l'énergie active quotidienne, qui est déterminée par la somme Riemann de `inverter.x.activePower \"\nl'état `collected.dailyInputYield` a été résigné sur la base de l'onduleur. Énergie active",
26
+ "it": "Verifica migliorata della configurazione dell'adattatore\nnuovo stato `inverter.x.derived.dailyActiveEnergy` Inverter energia attiva quotidiana, che è determinata tramite la somma Riemann di `inverter.x.activePower #\nstato `collect.dailyInputYield` è stato ridisegnato sulla base di inverter. [0.n-1]",
27
+ "es": "Mejor verificación de la configuración del adaptador\nnuevo estado `inverter.x.derived.dailyActiveEnergy` Inverter energía activa diaria, que se determina a través de la suma Riemann de `inverter.x.activePower `\nestado `colected.dailyInputYield` fue redisigned basado en inverter. [0.n-1].derived.dailyActiveEnergy",
28
+ "pl": "Ulepszona weryfikacja konfiguracji adaptera\nnowy stan 'inverter.x.derived.dailyActiveEnergy' Inwerter dzienna aktywna energia, która jest określana za pomocą sumy Riemann 'inverter.x.activePower'\nstan 'collected.dailyInputYield' został wycofany na podstawie inwertera. [0.. n-1] .derived.dailyActiveEnergy",
29
+ "uk": "Покращена перевірка конфігурації адаптера\nновий стан `inverter.x.derived.dailyActiveEnergy` Інверторна щоденна активна енергія, яка визначається за рахунок `inverter.x.activePower й\n`collected.dailyInputYield` був перерахований на основі інвертора. [0..n-1].derived.dailyActiveEnergy",
30
+ "zh-cn": "改进适配器配置的核查\n新州`反转器.x.衍生的每日能源 ' 每日反转活性能量,通过`反转器.x.activePower的Riemann总和确定 `\ndaily InputYield)根据反差重新签名。 [0.n-1]. 衍生的每日能源"
31
+ },
6
32
  "2.3.2": {
7
33
  "en": "allows again `control.battery.chargeFromGridFunction` when using the Emma",
8
34
  "de": "erlaubt wieder `control.battery.chargeFromGridFunction` bei Verwendung der Emma",
@@ -67,32 +93,6 @@
67
93
  "pl": "aktualizacje zależności i konfiguracji\nnowy stan 'meter.derived.signConventionForPowerFeed- in' znak meter.active Energia zasilana obecnie do sieci energetycznej\nnowy stan 'meter.derived.feed-inPower' energia elektryczna, która jest dostarczana do sieci (\"karmiona w\")",
68
94
  "uk": "оновлення залежності та конфігурації\nновий стан `meter.derived.signConventionForPowerFeed-in` знак лічильника.active Потужність, яка в даний час вдається в електромережу\nновий стан `meter.derived.feed-inPower` електрична потужність, яка подається в сітку (\"fed in\")",
69
95
  "zh-cn": "依赖和配置更新\n新的状态“ 公尺” 。 生成。 签署 Convention ForPowerFeed- in' sign of meter. 活动 目前输入电网的电力\n新状态“ met. entered. feed-inpower” 供电给电网(“ feeded in”)"
70
- },
71
- "2.1.1": {
72
- "en": "dependency and configuration updates\nfix: adjust event value limits based on usableSurplus parameters\nfix: swap register values for power consumption in Emma driver #190\nemma: improve power calculation with exponential moving average in EmmaCharger\nupdate surplus power state definitions and deprecate old identifiers",
73
- "de": "abhängigkeits- und konfigurationsupdates\nfix: Event-Wert-Grenze basierend auf nutzbar Überschüssige Parameter\nfix: Swap-Registerwerte für den Stromverbrauch in Emma Treiber #190\nemma: Leistungsberechnung mit exponentiellem Bewegungsmittel in EmmaCharger verbessern\naktualisierung der überschussstrom-zustandsdefinitionen und abschreibung alter kennungen",
74
- "ru": "обновления зависимостей и конфигурации\nисправление: корректировка предельных значений событий на основе пригодных для использования Дополнительные параметры\nисправление: значения регистра свопов для энергопотребления в драйвере Emma #190\nemma: улучшите расчет мощности с экспоненциальной скользящей средней в EmmaCharger\nобновить определения состояния избыточной мощности и обесценить старые идентификаторы",
75
- "pt": "atualizações de dependência e configuração\ncorreção: ajustar os limites do valor do evento com base no utilizável Parâmetros do excedente\ncorreção: valores de registro de swap para consumo de energia em Emma driver #190\nemma: melhorar o cálculo de potência com média móvel exponencial em EmmaCharger\natualizar definições de estado de potência excedente e depreciar identificadores antigos",
76
- "nl": "afhankelijkheid en configuratie-updates\nfix: aanpassen gebeurtenis waarde limieten op basis van bruikbaar Overschotparameters\nfix: swap register waarden voor energieverbruik in Emma driver #190\nemma: verbeteren van de stroomberekening met exponentieel bewegend gemiddelde in EmmaCharger\nde definitie van overtollige vermogenstoestand bij te werken en oude identificatienummers te schrappen",
77
- "fr": "mises à jour de la dépendance et de la configuration\nfix: ajuster les limites de valeur d'événement en fonction de la valeur utilisable Paramètres excédentaires\nfix: valeurs de registre d'échange pour la consommation d'énergie en Emma driver #190\nemma: améliorer le calcul de la puissance avec la moyenne mobile exponentielle en EmmaCharger\nmettre à jour les définitions de l'état de puissance excédentaire et supprimer les anciens identifiants",
78
- "it": "aggiornamenti di dipendenza e configurazione\ncorrezione: regolare i limiti del valore dell'evento in base all'utilizzabile Parametri in eccesso\ncorrezione: swap valori di registro per il consumo di energia in Emma driver #190\nemma: migliorare il calcolo di potenza con una media mobile esponenziale in EmmaCharger\naggiornare le definizioni di stato di potenza eccedente e deprecare vecchi identificatori",
79
- "es": "actualizaciones de dependencia y configuración\nfijación: ajustar los límites de valor de evento basados en utilizables Parámetros adicionales\nfijado: cambiar los valores de registro para el consumo de energía en el controlador Emma #190\nemma: mejorar el cálculo de potencia con promedio de movimiento exponencial en EmmaCharger\nactualizar las definiciones de estado de excedente de energía y depreparar identificadores antiguos",
80
- "pl": "aktualizacje zależności i konfiguracji\nfix: dostosować wartości graniczne dla zdarzeń w oparciu o wartość użytkową Parametry nadwyżki\nfix: wartości rejestru swap dla zużycia energii w sterowniku Emma # 190\nemma: ulepszenie obliczania mocy przy zastosowaniu wykładniczej średniej ruchomej w EmmaCharger\naktualizacja definicji nadwyżek energii elektrycznej i deprecjacja starych identyfikatorów",
81
- "uk": "оновлення залежності та конфігурації\nвиправити: регулювати ліміти значення події на основі Параметри Surplus\nвиправити: значення swap для споживання енергії в машині Емма #190\nемма: поліпшення розрахунку потужності з постійним рухомим середнім в ЕммаКхаргер\nоновлення надлишок визначення стану живлення та депресувати старі ідентифікатори",
82
- "zh-cn": "依赖和配置更新\n固定:根据可用值调整事件值限制 盈余参数\n修补: Emma 驱动器中用电量的交换记录值 # 190\nemma: 改进电量计算, 以 Emmacourer 中的指数移动平均值\n更新剩余电源状态定义并折旧旧标识符"
83
- },
84
- "2.1.0": {
85
- "en": "emma: system time is being determined [#179](https://github.com/bolliy/ioBroker.sun2000/issues/179)\ncontrol: add grid power scheduling functionality to inverter driver [#176](https://github.com/bolliy/ioBroker.sun2000/issues/176)",
86
- "de": "emma: Die Systemzeit wird bestimmt [#179](https://github.com/bolliy/ioBroker.sun2000/issues/179)\nsteuerung: Netz-Leistungs-Scheduling-Funktionalität zum Wechselrichtertreiber hinzufügen [#176](https://github.com/bolliy/ioBroker.sun2000/issues/176)",
87
- "ru": "emma: системное время определяется [#179] (https://github.com/bolliy/ioBroker.sun2000/issues/179)\nуправление: добавьте функцию планирования мощности сети к драйверу инвертора [#176] (https://github.com/bolliy/ioBroker.sun2000/issues/176)",
88
- "pt": "emma: tempo do sistema está sendo determinado [#179](https://github.com/bolliy/ioBroker.sun2000/issues/179)\ncontrol: add grid power screaming functionality to inverter driver [#176](https://github.com/bolliy/ioBroker.sun2000/issues/176)",
89
- "nl": "emma: de systeemtijd wordt bepaald [#179](https://github.com/bolliy/ioBroker.sun2000/issues/179)\ncontrole: voeg net stroom planning functionaliteit aan omvormer driver [#176](https://github.com/bolliy/ioBroker.sun2000/issues/176)",
90
- "fr": "emma: le temps du système est déterminé [#179](https://github.com/bolliy/ioBroker.sun2000/issues/179)\ncontrôle: ajouter la fonctionnalité de programmation du réseau au pilote d'onduleur [#176](https://github.com/bolliy/ioBroker.sun2000/issues/176)",
91
- "it": "emma: il tempo di sistema viene determinato [#179](https://github.com/bolliy/ioBroker.sun2000/issues/179)\ncontrollo: aggiungere funzionalità di programmazione della griglia al driver inverter [#176](https://github.com/bolliy/ioBroker.sun2000/issues/176)",
92
- "es": "emma: El tiempo del sistema se determina [#179](https://github.com/bolliy/ioBroker.sun2000/issues/179)\ncontrol: añadir funcionalidad de programación de energía de red al controlador inverter [#176](https://github.com/bolliy/ioBroker.sun2000/issues/176)",
93
- "pl": "emma: ustala się czas systemowy [# 179] (https: / / github.com / bolliy / ioBroker.sun2000 / issues / 179)\ncontrol: add grid Power Scheduling Functional to inverter driver [# 176] (https: / / github.com / bolliy / ioBroker.sun2000 / issues / 176)",
94
- "uk": "emma: час системи визначається [#179](https://github.com/bolliy/ioBroker.sun2000/products/179)\ncontrol: add power scheduling features to inverter драйвер [#176](https://github.com/bolliy/ioBroker.sun2000/issues/176)",
95
- "zh-cn": "emma:系统时间正在确定 [# 179] (https://github.com/bolliy/ioBroker.sun2000/issues/179)\n控制:向反向驱动器添加电网电源调度功能[#176](https://github.com/bolliy/ioBroker.sun2000/issues/1976)"
96
96
  }
97
97
  },
98
98
  "titleLang": {
@@ -96,7 +96,13 @@ class InverterSun2000 extends DriverBase {
96
96
  this.solarSum = new RiemannSum();
97
97
  this.adapter.getState(`${this.deviceInfo.path}.derived.dailySolarYield`, (err, state) => {
98
98
  if (!err && state) {
99
- this.solarSum.setStart(state.val, state.ts);
99
+ this.solarSum.setStart(state?.val, state?.ts);
100
+ }
101
+ });
102
+ this.activePowerSum = new RiemannSum();
103
+ this.adapter.getState(`${this.deviceInfo.path}.derived.dailyActiveEnergy`, (err, state) => {
104
+ if (!err && state) {
105
+ this.activePowerSum.setStart(state?.val, state?.ts);
100
106
  }
101
107
  });
102
108
 
@@ -149,7 +155,7 @@ class InverterSun2000 extends DriverBase {
149
155
  postHook: () => {
150
156
  if (!this._testMode) return;
151
157
 
152
- this.log.debug('### PostHook for InverterSun2000');
158
+ this.log.debug('### TEST MODE - PostHook for InverterSun2000 ####');
153
159
  this.identifySubdevices('sun2000', this.modbusId)
154
160
  .then(ret => {
155
161
  this.log.debug(`### PostHook for InverterSun2000 - ret: ${JSON.stringify(ret)}`);
@@ -190,6 +196,11 @@ class InverterSun2000 extends DriverBase {
190
196
  store: storeType.always,
191
197
  },
192
198
  ],
199
+ postHook: path => {
200
+ //calculate daily active energy
201
+ const activePower = this.stateCache.get(`${path}activePower`)?.value ?? 0;
202
+ this.activePowerSum.add(activePower); //riemann Sum
203
+ },
193
204
  },
194
205
  {
195
206
  address: 37765,
@@ -1489,14 +1500,7 @@ class InverterSun2000 extends DriverBase {
1489
1500
  const activePower = this.stateCache.get(`${path}activePower`)?.value ?? 0;
1490
1501
  if (Math.abs(activePower - inputPower + chargePower) > 0) {
1491
1502
  this.log.debug(`activePower ${activePower} !== inputPower ${inputPower}-chargePower ${chargePower}`);
1492
- this.stateCache.set(`${path}activePower`, inputPower - chargePower, { type: 'number' });
1493
- /*
1494
- if (chargePower === 0) {
1495
- this.stateCache.set(`${path}activePower`, inputPower - chargePower, { type: 'number' });
1496
- } else {
1497
- this.stateCache.set(`${path}battery.chargeDischargePower`, inputPower - activePower, { type: 'number' });
1498
- }
1499
- */
1503
+ //this.stateCache.set(`${path}activePower`, inputPower - chargePower, { type: 'number' });
1500
1504
  }
1501
1505
  },
1502
1506
  },
@@ -1508,17 +1512,19 @@ class InverterSun2000 extends DriverBase {
1508
1512
  type: 'number',
1509
1513
  unit: 'kWh',
1510
1514
  role: 'value.power.consumption',
1511
- desc: 'Try to recreate the yield from the portal',
1515
+ desc: 'yield from the portal',
1512
1516
  },
1513
1517
  fn: path => {
1514
- const disCharge = this.stateCache.get(`${path}battery.currentDayDischargeCapacity`)?.value;
1515
- const charge = this.stateCache.get(`${path}battery.currentDayChargeCapacity`)?.value;
1516
- let inputYield = this.stateCache.get(`${path}dailyEnergyYield`)?.value * 0.97 + charge - disCharge;
1517
-
1518
- if (inputYield < 0 || isNaN(inputYield)) {
1519
- inputYield = 0;
1518
+ const disCharge = this.stateCache.get(`${path}battery.currentDayDischargeCapacity`)?.value ?? 0;
1519
+ const charge = this.stateCache.get(`${path}battery.currentDayChargeCapacity`)?.value ?? 0;
1520
+ //let inputYield = this.stateCache.get(`${path}dailyEnergyYield`)?.value ?? 0 * 0.97 + charge - disCharge;
1521
+ const activeEnergy = this.stateCache.get(`${path}derived.dailyActiveEnergy`)?.value ?? 0;
1522
+ //let inYield = activeEnergy + (charge - disCharge) * 0.97; //efficiency loss of battery 3%
1523
+ let inYield = activeEnergy + (charge - disCharge); //efficiency loss of battery 3%
1524
+ if (inYield < 0) {
1525
+ inYield = 0;
1520
1526
  }
1521
- this.stateCache.set(`${path}derived.dailyInputYield`, inputYield, { type: 'number' });
1527
+ this.stateCache.set(`${path}derived.dailyInputYield`, inYield, { type: 'number' });
1522
1528
  },
1523
1529
  },
1524
1530
  {
@@ -1535,6 +1541,20 @@ class InverterSun2000 extends DriverBase {
1535
1541
  this.stateCache.set(`${path}derived.dailySolarYield`, this.solarSum.sum, { type: 'number' });
1536
1542
  },
1537
1543
  },
1544
+ {
1545
+ refresh: dataRefreshRate.low,
1546
+ state: {
1547
+ id: 'derived.dailyActiveEnergy',
1548
+ name: 'Active Energy today',
1549
+ type: 'number',
1550
+ unit: 'kWh',
1551
+ role: 'value.power.consumption',
1552
+ desc: 'Amount of Riemann sum of sum of active power',
1553
+ },
1554
+ fn: path => {
1555
+ this.stateCache.set(`${path}derived.dailyActiveEnergy`, this.activePowerSum.sum, { type: 'number' });
1556
+ },
1557
+ },
1538
1558
  ];
1539
1559
  this.postUpdateHooks.push.apply(this.postUpdateHooks, newHooks);
1540
1560
  }
@@ -1638,6 +1658,7 @@ class InverterSun2000 extends DriverBase {
1638
1658
 
1639
1659
  async mitnightProcess() {
1640
1660
  this.solarSum.reset();
1661
+ this.activePowerSum.reset();
1641
1662
  }
1642
1663
  }
1643
1664
 
package/lib/register.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const { deviceType, driverClasses, dataRefreshRate } = require(`${__dirname}/types.js`);
4
- const { StateMap } = require(`${__dirname}/tools.js`);
4
+ const { RiemannSum, StateMap } = require(`${__dirname}/tools.js`);
5
5
  const getDriverHandler = require(`${__dirname}/drivers/index.js`);
6
6
 
7
7
  class Registers {
@@ -9,6 +9,8 @@ class Registers {
9
9
  this.adapter = adapterInstance;
10
10
  this.stateCache = new StateMap();
11
11
 
12
+ this.externalSum = new RiemannSum();
13
+
12
14
  for (const device of this.adapter.devices) {
13
15
  //DriverInfo Instance or Sdongle
14
16
  const handler = getDriverHandler(device.driverClass);
@@ -31,7 +33,7 @@ class Registers {
31
33
  type: 'number',
32
34
  unit: 'kW',
33
35
  role: 'value.power',
34
- desc: '',
36
+ desc: 'Power from solar with efficiency loss',
35
37
  },
36
38
  {
37
39
  id: 'collected.chargeDischargePower',
@@ -66,7 +68,6 @@ class Registers {
66
68
  desc: 'Power from solar minus house consumption and usable battery power',
67
69
  },
68
70
  { id: 'collected.externalPower', name: 'external power', type: 'number', unit: 'kW', role: 'value.power' },
69
- //{ id: 'collected.ratedPower', name: 'rated power', type: 'number', unit: 'kW', role: 'value.power' },
70
71
  ],
71
72
  fn: inverters => {
72
73
  let actPower = 0;
@@ -99,7 +100,7 @@ class Registers {
99
100
  }
100
101
 
101
102
  if (soc > minSoc) {
102
- // charge power is positive
103
+ // charge power is positive - Battery is charging
103
104
  if (chargeDischarge > 0) surplusPower += chargeDischarge;
104
105
 
105
106
  if (bufferSoc === 0 || soc < bufferSoc + threshold) {
@@ -149,13 +150,12 @@ class Registers {
149
150
  inPowerEff += this.stateCache.get(`${inverter.path}.derived.inputPowerWithEfficiencyLoss`)?.value ?? 0;
150
151
  chargeDischarge += this.stateCache.get(`${inverter.path}.battery.chargeDischargePower`)?.value ?? 0;
151
152
  ratedPower += this.stateCache.get(`${inverter.path}.info.ratedPower`)?.value ?? 0;
152
- //maxChargePower = this.stateCache.get(`${inverter.path}.battery.maximumChargingPower`)?.value ?? 0;
153
153
  }
154
154
 
155
155
  const feedinPower = this.stateCache.get('meter.derived.feed-inPower')?.value ?? 0;
156
156
 
157
157
  const extPower = this.adapter.control.get('externalPower')?.value ?? 0;
158
- //extPower = extPower / 1000;
158
+ this.externalSum.add(extPower); //riemann Sum
159
159
 
160
160
  //Zu geringe Erzeugerenegie
161
161
  let houseConsum = actPower - feedinPower + extPower;
@@ -192,15 +192,15 @@ class Registers {
192
192
  type: 'number',
193
193
  unit: 'kWh',
194
194
  role: 'value.power.consumption',
195
- desc: 'daily output yield of the inverters',
195
+ desc: 'daily energy yield of the inverters',
196
196
  },
197
197
  {
198
198
  id: 'collected.dailyInputYield',
199
- name: 'Daily portal yield',
199
+ name: 'Daily input yield',
200
200
  type: 'number',
201
201
  unit: 'kWh',
202
202
  role: 'value.power.consumption',
203
- desc: 'Try to recreate the yield from the portal',
203
+ desc: 'yield from the portal',
204
204
  },
205
205
  {
206
206
  id: 'collected.dailySolarYield',
@@ -237,12 +237,31 @@ class Registers {
237
237
  },
238
238
  { id: 'collected.SOC', name: 'State of battery capacity', type: 'number', unit: '%', role: 'value.battery', desc: 'SOC' },
239
239
  { id: 'collected.ratedCapacity', name: 'Rated of battery capacity', type: 'number', unit: 'Wh', role: 'value.capacity' },
240
+ {
241
+ id: 'collected.dailyExternalYield',
242
+ name: 'daily external yield',
243
+ type: 'number',
244
+ unit: 'kWh',
245
+ role: 'value.power.consumption',
246
+ desc: 'Riemann sum of external power',
247
+ },
248
+ /*
249
+ {
250
+ id: 'collected.dailyActiveEnergy',
251
+ name: 'Active Energy today',
252
+ type: 'number',
253
+ unit: 'kWh',
254
+ role: 'value.power.consumption',
255
+ desc: 'Amount of Riemann sum of sum of active power',
256
+ },
257
+ */
240
258
  ],
241
259
  fn: inverters => {
242
260
  let inYield = 0;
243
261
  let solarYield = 0;
244
262
  let outYield = 0;
245
263
  let enYield = 0;
264
+ let activeEnergy = 0;
246
265
  let charge = 0;
247
266
  let disCharge = 0;
248
267
  let totalDisCharge = 0;
@@ -256,10 +275,11 @@ class Registers {
256
275
  if (inverter.driverClass != driverClasses.inverter) {
257
276
  continue;
258
277
  }
259
- outYield += this.stateCache.get(`${inverter.path}.dailyEnergyYield`)?.value;
278
+ outYield += this.stateCache.get(`${inverter.path}.dailyEnergyYield`)?.value ?? 0;
260
279
  inYield += this.stateCache.get(`${inverter.path}.derived.dailyInputYield`)?.value;
261
280
  solarYield += this.stateCache.get(`${inverter.path}.derived.dailySolarYield`)?.value;
262
281
  enYield += this.stateCache.get(`${inverter.path}.accumulatedEnergyYield`)?.value;
282
+ activeEnergy += this.stateCache.get(`${inverter.path}.derived.dailyActiveEnergy`)?.value ?? 0;
263
283
  if (this.stateCache.get(`${inverter.path}.battery.ratedCapacity`)?.value > 0) {
264
284
  charge += this.stateCache.get(`${inverter.path}.battery.currentDayChargeCapacity`)?.value ?? 0;
265
285
  disCharge += this.stateCache.get(`${inverter.path}.battery.currentDayDischargeCapacity`)?.value ?? 0;
@@ -271,9 +291,10 @@ class Registers {
271
291
  ratedCap += this.stateCache.get(`${inverter.path}.battery.ratedCapacity`)?.value;
272
292
  }
273
293
  }
274
-
294
+ //this.stateCache.set('collected.dailyActiveEnergy', activeEnergy, { type: 'number' });
295
+ this.stateCache.set('collected.dailyExternalYield', this.externalSum.sum, { type: 'number' }); //of externalPower
275
296
  this.stateCache.set('collected.dailyEnergyYield', outYield, { type: 'number' });
276
- this.stateCache.set('collected.dailyInputYield', inYield, { type: 'number' }); //deprecated
297
+ this.stateCache.set('collected.dailyInputYield', inYield, { type: 'number' });
277
298
  this.stateCache.set('collected.dailySolarYield', solarYield, { type: 'number' });
278
299
  this.stateCache.set('collected.accumulatedEnergyYield', enYield, { type: 'number' });
279
300
  const sign = this.stateCache.get('meter.derived.signConventionForPowerFeed-in')?.value ?? 1;
@@ -286,6 +307,7 @@ class Registers {
286
307
  feedinEnergy = this.stateCache.get('meter.positiveActiveEnergy')?.value ?? 0;
287
308
  supplyFromGrid = this.stateCache.get('meter.reverseActiveEnergy')?.value ?? 0;
288
309
  }
310
+ //stimmt leider nicht genau - bleibt aber erstmal bestehen
289
311
  const conSum = enYield + supplyFromGrid - feedinEnergy;
290
312
  this.stateCache.set('collected.consumptionSum', conSum, { type: 'number' });
291
313
  // compute export and import today
@@ -295,11 +317,22 @@ class Registers {
295
317
  this.stateCache.set('collected.gridImportToday', supplyFromGrid - this.stateCache.get('collected.gridImportStart')?.value, {
296
318
  type: 'number',
297
319
  });
320
+ /* old computation of consumption today
298
321
  this.stateCache.set(
299
322
  'collected.consumptionToday',
300
323
  this.stateCache.get('collected.consumptionSum')?.value - this.stateCache.get('collected.consumptionStart')?.value,
301
324
  { type: 'number' },
302
325
  );
326
+ */
327
+ //new computation of consumption today
328
+ this.stateCache.set(
329
+ 'collected.consumptionToday',
330
+ activeEnergy +
331
+ this.externalSum.sum +
332
+ this.stateCache.get('collected.gridImportToday')?.value -
333
+ this.stateCache.get('collected.gridExportToday')?.value,
334
+ { type: 'number' },
335
+ );
303
336
  //compute battery
304
337
  this.stateCache.set('collected.totalCharge', totalCharge, { type: 'number' });
305
338
  this.stateCache.set('collected.totalDischarge', totalDisCharge, { type: 'number' });
@@ -415,6 +448,9 @@ class Registers {
415
448
  this.stateCache.set('collected.gridImportStart', state?.val, { type: 'number', stored: true });
416
449
  state = await this.adapter.getState('collected.consumptionStart');
417
450
  this.stateCache.set('collected.consumptionStart', state?.val, { type: 'number', stored: true });
451
+ state = await this.adapter.getState('collected.dailyExternalYield');
452
+ this.stateCache.set('collected.dailyExternalYield', state?.val, { type: 'number', stored: true });
453
+ this.externalSum.setStart(state?.val, state?.ts);
418
454
  }
419
455
 
420
456
  //state
@@ -483,6 +519,8 @@ class Registers {
483
519
  this.stateCache.set('collected.gridExportStart', this.stateCache.get('meter.positiveActiveEnergy')?.value ?? 0, { type: 'number' });
484
520
  this.stateCache.set('collected.gridImportStart', this.stateCache.get('meter.reverseActiveEnergy')?.value ?? 0, { type: 'number' });
485
521
  }
522
+ this.externalSum.reset(); //reset for next day
523
+ this.stateCache.set('collected.dailyExternalYield', 0, { type: 'number' });
486
524
  // copy consumption Sum to Start for the next day
487
525
  this.stateCache.set('collected.consumptionStart', this.stateCache.get('collected.consumptionSum')?.value ?? 0, { type: 'number' });
488
526
  for (const device of this.adapter.devices) {
package/lib/tools.js CHANGED
@@ -202,8 +202,12 @@ class RiemannSum {
202
202
  }
203
203
 
204
204
  setStart(sum, ts) {
205
- this._sum = sum;
206
- this._lastDate = new Date(ts);
205
+ if (!isNaN(sum)) {
206
+ this._sum = sum;
207
+ this._lastDate = new Date(ts);
208
+ } else {
209
+ this.reset();
210
+ }
207
211
  }
208
212
  }
209
213
 
package/main.js CHANGED
@@ -379,7 +379,7 @@ class Sun2000 extends utils.Adapter {
379
379
  await this.setState('info.modbusDelay', { val: this.config.delay, ack: true });
380
380
  await this.setState('info.modbusTcpServer', { val: this.config.ms_active, ack: true });
381
381
  // Load user settings
382
- if (this.config.address != '' && this.config.port > 0 && this.config.modbusIds != '' && this.config.updateInterval > 0) {
382
+ if (this.config.address != '' && this.config.port > 0 && this.config.updateInterval > 0) {
383
383
  this.settings.address = this.config.address;
384
384
  this.settings.port = this.config.port;
385
385
  this.settings.modbusTimeout = this.config.timeout; //ms
@@ -421,67 +421,72 @@ class Sun2000 extends utils.Adapter {
421
421
  } else {
422
422
  await this.setState('info.JSONhealth', { val: '{message : "Information is collected"}', ack: true });
423
423
  }
424
-
425
- if (this.settings.modbusIds.length > 0 && this.settings.modbusIds.length < 6) {
426
- //ES6 use a for (const [index, item] of array.entries()) of loop
427
- for (const [i, id] of this.settings.modbusIds.entries()) {
428
- this.devices.push({
429
- index: i,
430
- duration: 5000,
431
- modbusId: id,
432
- driverClass: driverClasses.inverter,
433
- meter: i == 0 && this.settings.integration === 0,
434
- });
435
- }
436
-
437
- //SDongle
438
- if (this.settings.integration === 0 && this.settings.sd.active) {
439
- this.devices.push({
440
- index: 0,
441
- duration: 0,
442
- modbusId: this.settings.sd.sDongleId,
443
- driverClass: driverClasses.sdongle,
444
- });
424
+ //future: if (this.settings.integration !== 2 && (this.settings.modbusIds.length === 0 || this.settings.modbusIds.length > 5)) {
425
+ if (this.settings.modbusIds.length === 0 || this.settings.modbusIds.length > 5) {
426
+ this.adapterDisable(`*** Adapter deactivated, inverter modbus Ids is invalid! ***`);
427
+ return;
428
+ }
429
+ //ES6 use a for (const [index, item] of array.entries()) of loop
430
+ for (const [i, id] of this.settings.modbusIds.entries()) {
431
+ //Inverter
432
+ if (id < 1 || id >= 250) {
433
+ this.adapterDisable(`*** Adapter deactivated, inverter modbus Id ${id} is not permitted! ***`);
434
+ return;
445
435
  }
436
+ this.devices.push({
437
+ index: i,
438
+ duration: 5000,
439
+ modbusId: id,
440
+ driverClass: driverClasses.inverter,
441
+ meter: i == 0 && this.settings.integration === 0,
442
+ });
443
+ }
446
444
 
447
- //SmartLogger
448
- if (this.settings.integration === 1) {
449
- this.devices.push({
450
- index: 0,
451
- duration: 0,
452
- modbusId: 0,
453
- driverClass: driverClasses.logger,
454
- });
455
- if (this.settings.sl.meterId > 0) {
456
- this.devices.push({
457
- index: 0,
458
- duration: 0,
459
- meter: true,
460
- modbusId: this.settings.sl.meterId,
461
- driverClass: driverClasses.loggerMeter,
462
- });
463
- }
464
- }
445
+ //SDongle
446
+ if (this.settings.integration === 0 && this.settings.sd.active) {
447
+ this.devices.push({
448
+ index: 0,
449
+ duration: 0,
450
+ modbusId: this.settings.sd.sDongleId,
451
+ driverClass: driverClasses.sdongle,
452
+ });
453
+ }
465
454
 
466
- //EMMA
467
- if (this.settings.integration === 2) {
455
+ //SmartLogger
456
+ if (this.settings.integration === 1) {
457
+ this.devices.push({
458
+ index: 0,
459
+ duration: 0,
460
+ modbusId: 0,
461
+ driverClass: driverClasses.logger,
462
+ });
463
+ if (this.settings.sl.meterId > 0) {
468
464
  this.devices.push({
469
465
  index: 0,
470
466
  duration: 0,
471
- //modbusId: 1, --> testMode
472
- modbusId: 0,
473
467
  meter: true,
474
- driverClass: driverClasses.emma,
468
+ modbusId: this.settings.sl.meterId,
469
+ driverClass: driverClasses.loggerMeter,
475
470
  });
476
471
  }
472
+ }
477
473
 
478
- await this.adjustInverval();
479
- await this.StartProcess();
480
- } else {
481
- this.adapterDisable("*** Adapter deactivated, can't parse modbusIds! ***");
474
+ //EMMA with TestMode
475
+ if (this.settings.integration === 2) {
476
+ this.devices.push({
477
+ index: 0,
478
+ duration: 0,
479
+ //modbusId: 1, --> testMode
480
+ modbusId: 0,
481
+ meter: true,
482
+ driverClass: driverClasses.emma,
483
+ });
482
484
  }
485
+
486
+ await this.adjustInverval();
487
+ await this.StartProcess();
483
488
  } else {
484
- this.adapterDisable('*** Adapter deactivated, Adapter Settings incomplete! ***');
489
+ this.adapterDisable(`*** Adapter deactivated, Adapter Settings incomplete! ***`);
485
490
  }
486
491
  }
487
492
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.sun2000",
3
- "version": "2.3.2",
3
+ "version": "2.3.4",
4
4
  "description": "sun2000",
5
5
  "author": {
6
6
  "name": "bolliy",
@@ -33,18 +33,18 @@
33
33
  "tcp-port-used": "^1.0.2"
34
34
  },
35
35
  "devDependencies": {
36
- "@alcalzone/release-script": "^3.8.0",
37
- "@alcalzone/release-script-plugin-iobroker": "^3.7.2",
38
- "@alcalzone/release-script-plugin-license": "^3.7.0",
39
- "@alcalzone/release-script-plugin-manual-review": "^3.7.0",
36
+ "@alcalzone/release-script": "^5.0.0",
37
+ "@alcalzone/release-script-plugin-iobroker": "^4.0.0",
38
+ "@alcalzone/release-script-plugin-license": "^4.0.0",
39
+ "@alcalzone/release-script-plugin-manual-review": "^4.0.0",
40
40
  "@eslint/eslintrc": "^3.3.1",
41
- "@eslint/js": "^9.36.0",
41
+ "@eslint/js": "^9.39.0",
42
42
  "@iobroker/adapter-dev": "^1.5.0",
43
43
  "@iobroker/eslint-config": "^2.2.0",
44
44
  "@iobroker/testing": "^5.1.1",
45
45
  "@tsconfig/node20": "^20.1.6",
46
- "@types/node": "^24.6.2",
47
- "globals": "^16.4.0",
46
+ "@types/node": "^24.9.2",
47
+ "globals": "^16.5.0",
48
48
  "typescript": "~5.9.3"
49
49
  },
50
50
  "main": "main.js",