iobroker.sun2000 2.4.3 → 2.4.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
@@ -67,9 +67,16 @@ The sun2000 adapter calculates how much of your self-generated solar energy is a
67
67
  ## Changelog
68
68
  <!--
69
69
  Placeholder for the next version (at the beginning of the line):
70
+ ### **WORK IN PROGRESS**
70
71
  -->
72
+ ### 2.4.4 (2026-05-04)
73
+ * statistics fix: add error handling for waitForValue function
74
+
71
75
  ### 2.4.3 (2026-04-19)
72
76
  * statistics: new state `statistics.jsonToday` — live summary of today's energy values
77
+ * statistics: default chart shows energy flows above/below zero line, SOC (hourly only), self-sufficiency and self-consumption on second Y-axis
78
+ * statistics: computed values `selfSufficiency` and `selfConsumption` calculated automatically in all time-series states
79
+ * statistics: data placeholders (`%%solarYield%%`, `%%selfSufficiency%%` etc.) and negated variants (`%%gridExportNeg%%` etc.) for mirrored chart layouts
73
80
 
74
81
  ### 2.4.2 (2026-04-04)
75
82
  * fix test-and-release: deploy with 24.x
@@ -87,12 +94,6 @@ The sun2000 adapter calculates how much of your self-generated solar energy is a
87
94
  ### 2.3.7 (2026-02-01)
88
95
  * deleted deprecated state `collected.usableSurplusPower`
89
96
 
90
- ### 2.3.6 (2026-01-29)
91
- * dependency and configuration updates
92
- * new state `inverter.x.derived.alarmsJSON` : json array with intverter alarms (id, name, level) [#226](https://github.com/bolliy/ioBroker.sun2000/issues/226)
93
- * add ChargeDischargePower for Battery units [#234](https://github.com/bolliy/ioBroker.sun2000/issues/234)
94
- * add minimum and maximum temperature for battery packs [#236](https://github.com/bolliy/ioBroker.sun2000/issues/236)
95
-
96
97
  ## License
97
98
  MIT License
98
99
 
package/io-package.json CHANGED
@@ -1,8 +1,21 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "sun2000",
4
- "version": "2.4.3",
4
+ "version": "2.4.4",
5
5
  "news": {
6
+ "2.4.4": {
7
+ "en": "statistics fix: add error handling for waitForValue function",
8
+ "de": "statistik fix: Fehlerbehandlung für waitForValue-Funktion hinzufügen",
9
+ "ru": "исправление статистики: добавьте обработку ошибок в функцию WaitForValue",
10
+ "pt": "estatística corrigir: adicionar o tratamento de erro para a função waitForValue",
11
+ "nl": "statistieken fix: voeg fout behandeling voor waitForValue functie",
12
+ "fr": "correction statistique : ajouter la gestion des erreurs pour la fonction waitForValue",
13
+ "it": "statistiche fix: aggiungere la gestione degli errori per la funzione WaitForValue",
14
+ "es": "estadística fijado: añadir error de manejo para waitForValue función",
15
+ "pl": "statystyki naprawić: dodać obsługę błędów dla funkcji waitForValue",
16
+ "uk": "виправлення статистичних даних: Додавання обробки помилок для очікування",
17
+ "zh-cn": "统计修补: 添加waitForValue函数的错误处理"
18
+ },
6
19
  "2.4.3": {
7
20
  "en": "statistics: new state `statistics.jsonToday` — live summary of today's energy values",
8
21
  "de": "statistik: new state `statistics.jsonToday` — Live-Zusammenfassung der heutigen Energiewerte",
@@ -29,19 +42,6 @@
29
42
  "uk": "виправити тест-і-випуск: розгортання з 24.x",
30
43
  "zh-cn": "固定测试和释放:部署24x"
31
44
  },
32
- "2.4.1": {
33
- "en": "statistics: flexcharts integration — built-in Apache ECharts configuration with bar and line chart support\nstatistics: day-break visualization with alternating shaded areas for hourly charts\nstatistics: per chart-type templates (`statistics.flexCharts.template.hourly` etc.) for full ECharts customization including functions\nstatistics: data placeholders (`%%solarYield%%`, `%%gridExport%%` etc.) allow complete chart layout control via template states\nstatistics: chart output states (`statistics.flexCharts.jsonOutput.hourly` etc.) updated automatically each hour",
34
- "de": "statistik: flexcharts integration — integrierte Apache ECharts-Konfiguration mit Bar- und Liniendiagrammunterstützung\nstatistik: tages-früh-visualisierung mit alternierenden schattierten bereichen für stundendiagramme\nstatistiken: pro Diagrammvorlagen (`statistics.flexCharts.template.hourly` etc.) für die vollständige ECharts Anpassung einschließlich Funktionen\nstatistik: Datenplatzhalter (`%%solar%%%%`, `%%gridExport%% ` etc.) ermöglichen vollständige Chart-Layout-Kontrolle über Template-Staaten\nstatistiken: Diagrammausgabezustände (`statistics.flexCharts.jsonOutput.hourly` etc.) automatisch jede Stunde aktualisiert",
35
- "ru": "статистика: интеграция flexcharts — встроенная конфигурация Apache ECharts с поддержкой штрих- и линейных графиков\nстатистика: визуализация на рассвете с чередующимися затененными областями для часовых графиков\nстатистика: на шаблоны типа диаграммы («statistics.flexCharts.template.hourly» и т. д.) для полной настройки EChart, включая функции\nстатистика: держатели данных («%%solarYield%%», «%%gridExport%%» и т.д.) позволяют полностью контролировать макет диаграммы через шаблонные состояния\nстатистика: состояния выхода диаграммы (statistics.flexCharts.jsonOutput.hourly и т. д.) обновляются автоматически каждый час",
36
- "pt": "estatísticas: integração de flexcharts — configuração integrada do Apache ECharts com suporte a barras e gráficos de linha\nestatísticas: visualização diurna com áreas de sombra alternadas para gráficos horários\nestatísticas: por modelos de tipo gráfico (`statistics.flexCharts.template.hourly` etc.) para personalização completa de ECharts, incluindo funções\nestatísticas: placeholders de dados (` %s olarYield%% `, `% gridExport%% ` etc.) permitem o controle completo do layout do gráfico através de estados de modelo\nestatísticas: estados de saída do gráfico (`statistics.flexCharts.jsonOutput.hourly` etc.) atualizados automaticamente a cada hora",
37
- "nl": "statistics: flexcharts integration Ingebouwde Apache ECharts configuratie met ondersteuning voor bar en lijndiagram\nstatistieken: dagvakvisualisatie met afwisselende schaduwgebieden voor uurkaarten\nstatistieken: per grafiek-type sjablonen (\nstatistieken: data placeholders (\nstatistieken: grafiek output states (",
38
- "fr": "statistiques: intégration des flexcharts — configuration Apache ECharts intégrée avec support de la barre et de la ligne\nstatistiques: visualisation de la pause-jour avec zones ombrées alternées pour les graphiques horaires\nstatistiques: par modèle type de graphique (`statistics.flexCharts.template.hourly` etc.) pour la personnalisation complète d'ECharts, y compris les fonctions\nstatistiques : les détenteurs de place de données (`%%solarYield%%`, `%gridExport%%%` etc.) permettent un contrôle complet de la disposition des graphiques via les états de gabarit\nstatistiques: états de sortie du graphique (`statistics.flexCharts.jsonOutput.hourly` etc.) mis à jour automatiquement chaque heure",
39
- "it": "statistiche: integrazione di flexcharts — configurazione integrata di Apache ECharts con supporto grafico a barre e linea\nstatistiche: visualizzazione day-break con aree ombreggiate alternate per grafici orari\nstatistiche: per modelli di tipo grafico (`statistics.flexCharts.template.hourly` ecc.) per la personalizzazione completa di ECharts comprese le funzioni\nstatistiche: i segnaposto dei dati (%solarYield%%, `%gridExport%%` ecc.) permettono il controllo completo del layout del grafico tramite gli stati del modello\nstatistiche: stati di output grafico (`statistics.flexCharts.jsonOutput.hourly` ecc.) aggiornati automaticamente ogni ora",
40
- "es": "estadística: integración de flexcharts — configuración integrada de Apache ECharts con soporte de barras y gráficos\nestadística: visualización del día con áreas alternadas sombreadas para gráficos por hora\nestadística: por plantillas tipo gráfico (`statistics.flexCharts.template.hourly` etc.) para la personalización completa de ECharts incluyendo funciones\nestadística: marcadores de datos ( \"%solarYield%%% \" , \"%gridExport%%% \" , etc.) permiten un control completo de la distribución de gráficos a través de estados de plantilla\nestadística: estados de salida del gráfico (`statistics.flexCharts.jsonOutput.hourly` etc.) actualizados automáticamente cada hora",
41
- "pl": "statystyki: integracja flexcharts - built- w konfiguracji Apache ECharts z obsługą wykresu paska i linii\nstatystyki: wizualizacja z naprzemiennymi zacienionymi obszarami dla wykresów godzinowych\nstatystyki: na szablony typu chart- ('statistics.flexCharts.template.hourly' itp.) dla pełnej personalizacji ECharts, w tym funkcji\nstatystyki: Posiadacze danych ('% %s olarYeld%%', '%% gridExport%%' itd.) pozwalają na pełną kontrolę układu wykresu za pomocą szablonów stanów\nstatystyki: stany wyjściowe wykresu ('statistics.flexCharts.jsonOutput.hourly' itp.) aktualizowane automatycznie co godzinę",
42
- "uk": "статистика: інтеграція флекса — вбудована конфігурація Apache ECharts з підтримкою діаграми бару та лінії\nстатистика: візуалізація денного розриву з чергуванням затінених зон на часових графіках\nстатистика: за шаблони діаграм типу (`statistics.flexCharts.template.hrly` і т.д.) для повної настройки ECharts, включаючи функції\nстатистика: Держателі (`%solarYield%%`, `%gridExport%%` і т.д.) дозволяють повністю контролювати макети за допомогою шаблонних станів\nстатистика: діаграми вихідних станів (`statistics.flexCharts.jsonOutput.hrly` і т.д.) оновлено автоматично за кожну годину",
43
- "zh-cn": "统计:弹性图集成——内置的Apache ECharts配置,并有栏和行图支持\n统计:日间可视化,小时图表可交替显示阴影区域\n统计:每个图表类型的模板(`Statistics.flex Charts.template.hourly'等),用于包括功能在内的全部ECharts定制\n统计:数据占位符(`%%solarYield%%`,`%%gridExport%%`等)允许通过模板状态进行完整的图表布局控制\n统计:图表输出状态(`STATistics.flexCHarts.jsonOutput.hourly'等)"
44
- },
45
45
  "2.4.0": {
46
46
  "en": "fix: the order of bit assignment corrected of alarmsJSON\nnew state `inverter.x.emma.activeAlarmSN` and `inverter.x.emma.HistoricalAlarmSN` : emma alarms [#226](https://github.com/bolliy/ioBroker.sun2000/issues/226)\nstatistics: Aggregates historical collected datapoints into time-based summaries (e.g. hourly, daily, monthly, yearly). The data is stored in the path `statistics` as JSON.",
47
47
  "de": "fix: die Reihenfolge der Bitzuweisung korrigiert von Alarmen JSON\nneuer Zustand `inverter.x.emma.activeAlarmSN` und `inverter.x.emma.HistoricalAlarmSN`: Emma alarms [#226](https://github.com/bolliy/ioBroker.sun2000/issues/226)\nstatistik: Aggregate historische gesammelte Datenpunkte in zeitbasierte Zusammenfassungen (z.B. stündlich, täglich, monatlich, jährlich). Die Daten werden im Pfad `statistics` als JSON gespeichert.",
@@ -147,10 +147,14 @@ class ModbusServer {
147
147
  return new Promise(resolve => {
148
148
  this._isConnected = false;
149
149
  if (this.serverTCP) {
150
- this.serverTCP.close(() => {
151
- this.log.info('Modbus-proxy closed');
152
- resolve({});
153
- });
150
+ try {
151
+ this.serverTCP.close(() => {
152
+ this.log.info('Modbus-proxy closed');
153
+ resolve({});
154
+ });
155
+ } catch (err) {
156
+ this.log.error(`Modbus-proxy couldnt close ${err?.message}`);
157
+ }
154
158
  } else {
155
159
  resolve({});
156
160
  }
package/lib/statistics.js CHANGED
@@ -895,8 +895,13 @@ class statistics {
895
895
 
896
896
  state = await this.adapter.getState('statistics.jsonToday');
897
897
  this.stateCache.set('statistics.jsonToday', state?.val ?? '{}', { type: 'string', stored: true });
898
-
899
- await tools.waitForValue(() => this.stateCache.get('collected.accumulatedEnergyYield')?.value, 60000);
898
+ try {
899
+ await tools.waitForValue(() => this.stateCache.get('collected.accumulatedEnergyYield')?.value, 5 * 60000);
900
+ } catch {
901
+ this.adapter.logger.warn(
902
+ "statistics: waited 5 minutes for state 'collected.accumulatedEnergyYield' to be available but it didn't, computed statistics will not work until this state is present",
903
+ );
904
+ }
900
905
 
901
906
  // Load templates — one per chart type
902
907
  for (const chartType of ['hourly', 'daily', 'weekly', 'monthly', 'annual']) {
package/lib/tools.js CHANGED
@@ -260,15 +260,19 @@ const createAsyncLock = () => {
260
260
  const waitForValue = (func, timeout = 5000) => {
261
261
  return new Promise((resolve, reject) => {
262
262
  const timer = setInterval(() => {
263
- const variable = func();
264
- if (variable !== undefined && variable !== null) {
265
- clearInterval(timer);
266
- resolve(variable);
267
- }
268
- timeout -= 200;
269
- if (timeout <= 0) {
270
- clearInterval(timer);
271
- reject('Timeout: Wert wurde nicht rechtzeitig gesetzt.');
263
+ try {
264
+ const variable = func();
265
+ if (variable !== undefined && variable !== null) {
266
+ clearInterval(timer);
267
+ resolve(variable);
268
+ }
269
+ timeout -= 200;
270
+ if (timeout <= 0) {
271
+ clearInterval(timer);
272
+ reject('waitForValue: Timeout waiting for value');
273
+ }
274
+ } catch (err) {
275
+ this.adapter.logger.warn(`waitForValue ${err?.message}`);
272
276
  }
273
277
  }, 200); // alle 200ms prüfen
274
278
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.sun2000",
3
- "version": "2.4.3",
3
+ "version": "2.4.4",
4
4
  "description": "sun2000",
5
5
  "author": {
6
6
  "name": "bolliy",
@@ -42,7 +42,7 @@
42
42
  "@iobroker/eslint-config": "^2.2.0",
43
43
  "@iobroker/testing": "^5.2.2",
44
44
  "@tsconfig/node22": "^22.0.5",
45
- "@types/node": "^25.5.0",
45
+ "@types/node": "^25.6.0",
46
46
  "globals": "^16.5.0",
47
47
  "typescript": "~5.9.3"
48
48
  },