iobroker.nexowatt-ui 0.7.42 → 0.7.44
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/ems/modules/ai-advisor.js +118 -3
- package/io-package.json +18 -2
- package/package.json +1 -1
- package/www/manifest.webmanifest +1 -1
- package/www/sw.js +1 -1
|
@@ -137,6 +137,32 @@ function evcsPhrase(hasEvcs, withArticle = true) {
|
|
|
137
137
|
return hasEvcs ? (withArticle ? 'EV-Laden, Heizstab und andere flexible Lasten' : 'EV-Laden, Heizstab und andere flexible Verbraucher') : (withArticle ? 'Heizstab und andere flexible Lasten' : 'Heizstab und andere flexible Verbraucher');
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
function storageRowHasMapping(row) {
|
|
141
|
+
const r = (row && typeof row === 'object') ? row : {};
|
|
142
|
+
const keys = [
|
|
143
|
+
'socId', 'socPctId', 'socStateId', 'powerId', 'powerWId', 'chargePowerId', 'dischargePowerId',
|
|
144
|
+
'setPowerId', 'setChargePowerId', 'setDischargePowerId', 'onlineId', 'enabledId', 'pvPowerId',
|
|
145
|
+
];
|
|
146
|
+
return keys.some((key) => String(r[key] === null || r[key] === undefined ? '' : r[key]).trim().length > 0);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function configuredStorageFarmRows(adapter) {
|
|
150
|
+
const cfg = (adapter && adapter.config && typeof adapter.config === 'object') ? adapter.config : {};
|
|
151
|
+
const sf = (cfg.storageFarm && typeof cfg.storageFarm === 'object') ? cfg.storageFarm : {};
|
|
152
|
+
const lists = [];
|
|
153
|
+
if (Array.isArray(sf.storages)) lists.push(sf.storages);
|
|
154
|
+
if (Array.isArray(sf.batteries)) lists.push(sf.batteries);
|
|
155
|
+
if (Array.isArray(cfg.storageFarmStorages)) lists.push(cfg.storageFarmStorages);
|
|
156
|
+
return lists.reduce((acc, list) => acc.concat(list.filter((row) => row && row.enabled !== false && storageRowHasMapping(row))), []);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function storageSocLooksPlausible(v) {
|
|
160
|
+
if (v === null || v === undefined) return false;
|
|
161
|
+
if (typeof v === 'string' && v.trim() === '') return false;
|
|
162
|
+
const n = Number(v);
|
|
163
|
+
return Number.isFinite(n) && n >= 0 && n <= 100;
|
|
164
|
+
}
|
|
165
|
+
|
|
140
166
|
function buildPeakStateText(s, limitW, usagePct) {
|
|
141
167
|
const statusRaw = String(s && s.peakStatus || '').trim();
|
|
142
168
|
const suffix = statusRaw ? ` · Status ${statusRaw}` : '';
|
|
@@ -454,6 +480,8 @@ class AiAdvisorModule extends BaseModule {
|
|
|
454
480
|
await mk('aiAdvisor.gridConnectionLimitW', 'Netzanschlusslimit', 'number', 'value.power', 'W');
|
|
455
481
|
await mk('aiAdvisor.peakWarnThresholdW', 'Peak-Vorwarnschwelle', 'number', 'value.power', 'W');
|
|
456
482
|
await mk('aiAdvisor.weatherSummary', 'Wetter-Prognose Zusammenfassung', 'string', 'text');
|
|
483
|
+
await mk('aiAdvisor.storageSocPct', 'Speicher-SoC für KI-Beratung', 'number', 'value.battery', '%');
|
|
484
|
+
await mk('aiAdvisor.storageSocSource', 'Speicher-SoC Quelle für KI-Beratung', 'string', 'text');
|
|
457
485
|
await mk('aiAdvisor.dailyPlanText', 'KI-Tagesfahrplan Text', 'string', 'text');
|
|
458
486
|
await mk('aiAdvisor.dailyPlanJson', 'KI-Tagesfahrplan JSON', 'string', 'json');
|
|
459
487
|
await mk('aiAdvisor.evPlanText', 'EV-Zielplanung Text', 'string', 'text');
|
|
@@ -510,6 +538,84 @@ class AiAdvisorModule extends BaseModule {
|
|
|
510
538
|
return fallback;
|
|
511
539
|
}
|
|
512
540
|
|
|
541
|
+
_dpNumberFresh(key, maxAgeMs, fallback = null) {
|
|
542
|
+
try {
|
|
543
|
+
if (this.dp && typeof this.dp.getNumberFresh === 'function') {
|
|
544
|
+
const v = this.dp.getNumberFresh(key, maxAgeMs, null);
|
|
545
|
+
if (Number.isFinite(Number(v))) return Number(v);
|
|
546
|
+
}
|
|
547
|
+
} catch (_e) {}
|
|
548
|
+
try {
|
|
549
|
+
if (this.dp && typeof this.dp.getNumber === 'function') {
|
|
550
|
+
const v = this.dp.getNumber(key, null);
|
|
551
|
+
if (Number.isFinite(Number(v))) return Number(v);
|
|
552
|
+
}
|
|
553
|
+
} catch (_e2) {}
|
|
554
|
+
return fallback;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
async _isStorageFarmActive() {
|
|
558
|
+
try {
|
|
559
|
+
const cfg = (this.adapter && this.adapter.config && typeof this.adapter.config === 'object') ? this.adapter.config : {};
|
|
560
|
+
const rows = configuredStorageFarmRows(this.adapter);
|
|
561
|
+
if (cfg.enableStorageFarm === true && rows.length > 0) return true;
|
|
562
|
+
const enabled = await this._readBool(['storageFarm.enabled'], false);
|
|
563
|
+
const total = await this._readNumber(['storageFarm.storagesTotal'], 0);
|
|
564
|
+
return enabled === true && Number.isFinite(Number(total)) && Number(total) > 0;
|
|
565
|
+
} catch (_e) {
|
|
566
|
+
return false;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
async _readStorageSocPct(staleTimeoutSec = 300) {
|
|
571
|
+
const staleMs = Math.max(30000, Number(staleTimeoutSec || 300) * 1000);
|
|
572
|
+
const regularCandidates = [
|
|
573
|
+
// storageSoc ist der generische, im Kunden-Frontend sichtbare Speicher-SoC.
|
|
574
|
+
// Dieser Wert muss für die KI Vorrang haben, damit Dashboard und Beratung dieselbe Quelle nutzen.
|
|
575
|
+
{ key: 'storageSoc', type: 'state' },
|
|
576
|
+
{ key: 'speicher.regelung.socPct', type: 'state' },
|
|
577
|
+
{ key: 'speicher.socPct', type: 'state' },
|
|
578
|
+
{ key: 'batterySOC', type: 'state' },
|
|
579
|
+
{ key: 'batterySoc', type: 'state' },
|
|
580
|
+
{ key: 'batterySocPct', type: 'state' },
|
|
581
|
+
{ key: 'st.socPct', type: 'dp' },
|
|
582
|
+
];
|
|
583
|
+
const farmCandidatesOnlineFirst = [
|
|
584
|
+
{ key: 'storageFarm.totalSocOnline', type: 'state' },
|
|
585
|
+
{ key: 'storageFarm.totalSoc', type: 'state' },
|
|
586
|
+
{ key: 'storageFarm.medianSoc', type: 'state' },
|
|
587
|
+
];
|
|
588
|
+
const farmCandidatesTotalFirst = [
|
|
589
|
+
{ key: 'storageFarm.totalSoc', type: 'state' },
|
|
590
|
+
{ key: 'storageFarm.medianSoc', type: 'state' },
|
|
591
|
+
{ key: 'storageFarm.totalSocOnline', type: 'state' },
|
|
592
|
+
];
|
|
593
|
+
const readCandidate = async (entry) => {
|
|
594
|
+
const raw = entry.type === 'dp' ? this._dpNumberFresh(entry.key, staleMs, null) : await this._readNumber([entry.key], null);
|
|
595
|
+
return storageSocLooksPlausible(raw) ? Number(raw) : null;
|
|
596
|
+
};
|
|
597
|
+
const readFirst = async (list) => {
|
|
598
|
+
for (const entry of list) {
|
|
599
|
+
const value = await readCandidate(entry);
|
|
600
|
+
if (value !== null) return { value, source: entry.key };
|
|
601
|
+
}
|
|
602
|
+
return { value: null, source: '' };
|
|
603
|
+
};
|
|
604
|
+
|
|
605
|
+
const farmActive = await this._isStorageFarmActive();
|
|
606
|
+
const regular = await readFirst(regularCandidates);
|
|
607
|
+
if (farmActive) {
|
|
608
|
+
const socSourcesTotal = await this._readNumber(['storageFarm.socSourcesTotal'], 0);
|
|
609
|
+
const socSourcesOnline = await this._readNumber(['storageFarm.socSourcesOnline'], 0);
|
|
610
|
+
const farm = await readFirst(Number(socSourcesOnline) > 0 ? farmCandidatesOnlineFirst : farmCandidatesTotalFirst);
|
|
611
|
+
// Farm-Summen nur verwenden, wenn die Farm wirklich aktiv ist UND mindestens eine echte
|
|
612
|
+
// SoC-Quelle vorhanden ist. Sonst würde der Defaultwert storageFarm.totalSoc=0 den realen
|
|
613
|
+
// Einzel-Speicher-SoC überdecken. Genau das führte zur falschen KI-Meldung „Speicher liegt bei 0 %“.
|
|
614
|
+
if (farm.value !== null && Number(socSourcesTotal) > 0) return { value: farm.value, source: farm.source, farmActive };
|
|
615
|
+
}
|
|
616
|
+
return { value: regular.value, source: regular.source || (farmActive ? 'storageFarm:no-soc-source' : ''), farmActive };
|
|
617
|
+
}
|
|
618
|
+
|
|
513
619
|
async _readString(keys, fallback = '') {
|
|
514
620
|
const arr = Array.isArray(keys) ? keys : [keys];
|
|
515
621
|
for (const k of arr) {
|
|
@@ -597,9 +703,12 @@ class AiAdvisorModule extends BaseModule {
|
|
|
597
703
|
const gridImportLimitEffectiveW = await this._readNumber(['ems.core.gridImportLimitW_effective', 'chargingManagement.control.gridImportLimitW_effective'], null);
|
|
598
704
|
const gridImportLimitSource = await this._readString(['ems.core.gridImportLimitW_source'], '');
|
|
599
705
|
|
|
600
|
-
const
|
|
601
|
-
const
|
|
602
|
-
const
|
|
706
|
+
const storageSocInfo = await this._readStorageSocPct((this._cfg && this._cfg().staleTimeoutSec) || 300);
|
|
707
|
+
const storageSocPct = storageSocInfo.value;
|
|
708
|
+
const storageFarmActive = !!storageSocInfo.farmActive;
|
|
709
|
+
const storageSocSource = storageSocInfo.source || '';
|
|
710
|
+
const storageChargeW = await this._readNumber(storageFarmActive ? ['storageFarm.totalChargePowerW', 'ems.budget.storageChargeW', 'storageChargePower'] : ['ems.budget.storageChargeW', 'storageChargePower', 'storageFarm.totalChargePowerW'], 0);
|
|
711
|
+
const storageDischargeW = await this._readNumber(storageFarmActive ? ['storageFarm.totalDischargePowerW', 'ems.budget.storageDischargeW', 'storageDischargePower'] : ['ems.budget.storageDischargeW', 'storageDischargePower', 'storageFarm.totalDischargePowerW'], 0);
|
|
603
712
|
|
|
604
713
|
let evcsUsedW = await this._readNumber(['chargingManagement.control.usedW', 'evcs.totalPowerW', 'consumptionEvcs'], 0);
|
|
605
714
|
const thermalUsedW = await this._readNumber(['thermal.summary.budgetUsedW'], 0);
|
|
@@ -696,6 +805,8 @@ class AiAdvisorModule extends BaseModule {
|
|
|
696
805
|
consumptionTotalW: finiteNumber(consumptionTotalW) ? Math.max(0, num(consumptionTotalW, 0)) : null,
|
|
697
806
|
productionEnergyKwh: finiteNumber(productionEnergyKwh) ? productionEnergyKwh : null,
|
|
698
807
|
storageSocPct: finiteNumber(storageSocPct) ? storageSocPct : null,
|
|
808
|
+
storageSocSource,
|
|
809
|
+
storageFarmActive,
|
|
699
810
|
storageChargeW: Math.max(0, num(storageChargeW, 0)),
|
|
700
811
|
storageDischargeW: Math.max(0, num(storageDischargeW, 0)),
|
|
701
812
|
evcsAvailable,
|
|
@@ -1111,6 +1222,8 @@ class AiAdvisorModule extends BaseModule {
|
|
|
1111
1222
|
await this._set('aiAdvisor.gridConnectionLimitW', 0);
|
|
1112
1223
|
await this._set('aiAdvisor.peakWarnThresholdW', 0);
|
|
1113
1224
|
await this._set('aiAdvisor.weatherSummary', '');
|
|
1225
|
+
await this._set('aiAdvisor.storageSocPct', 0);
|
|
1226
|
+
await this._set('aiAdvisor.storageSocSource', '');
|
|
1114
1227
|
await this._set('aiAdvisor.dailyPlanText', '');
|
|
1115
1228
|
await this._set('aiAdvisor.dailyPlanJson', '[]');
|
|
1116
1229
|
await this._set('aiAdvisor.evPlanText', '');
|
|
@@ -1203,6 +1316,8 @@ class AiAdvisorModule extends BaseModule {
|
|
|
1203
1316
|
await this._set('aiAdvisor.gridConnectionLimitW', peakReferenceLimitW || 0);
|
|
1204
1317
|
await this._set('aiAdvisor.peakWarnThresholdW', round(peakWarnThresholdW, 0) || 0);
|
|
1205
1318
|
await this._set('aiAdvisor.weatherSummary', weatherSummary);
|
|
1319
|
+
await this._set('aiAdvisor.storageSocPct', round(snapshot.storageSocPct, 1) || 0);
|
|
1320
|
+
await this._set('aiAdvisor.storageSocSource', snapshot.storageSocSource || '');
|
|
1206
1321
|
await this._set('aiAdvisor.dailyPlanText', dailyPlan.text || '');
|
|
1207
1322
|
await this._set('aiAdvisor.dailyPlanJson', safeJson(dailyPlan.items || [], '[]'));
|
|
1208
1323
|
await this._set('aiAdvisor.evPlanText', evPlanText);
|
package/io-package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"name": "nexowatt-ui",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.44",
|
|
5
5
|
"news": {
|
|
6
6
|
"0.7.42": {
|
|
7
7
|
"en": "Feature-dependent visibility fixed: EVCS/charging station and storage farm are only shown in the customer frontend when they are actually configured. Default/legacy placeholders no longer enable wallbox UI; AI Advisor suppresses EV/wallbox hints when no wallbox is available.",
|
|
@@ -1759,6 +1759,14 @@
|
|
|
1759
1759
|
"0.7.33": {
|
|
1760
1760
|
"en": "Applied the new responsive cockpit design across all frontend subpages including history, settings, EVCS, SmartHome, App-Center, logic, simulation and reports.",
|
|
1761
1761
|
"de": "Neues responsives Cockpit-Design auf alle Frontend-Unterseiten angewendet: History, Einstellungen, EVCS, SmartHome, App-Center, Logik, Simulation und Reports."
|
|
1762
|
+
},
|
|
1763
|
+
"0.7.43": {
|
|
1764
|
+
"en": "AI Advisor storage SoC source fixed: storage farm default values no longer override the real single-storage SoC. The advisor now publishes its SoC source for diagnostics and avoids false low-reserve warnings when storageFarm is not configured.",
|
|
1765
|
+
"de": "KI-Energieberater Speicher-SoC korrigiert: Defaultwerte der Speicherfarm überdecken den echten Einzel-Speicher-SoC nicht mehr. Der Berater veröffentlicht jetzt die verwendete SoC-Quelle zur Diagnose und vermeidet falsche Niedrigreserve-Meldungen, wenn keine Speicherfarm konfiguriert ist."
|
|
1766
|
+
},
|
|
1767
|
+
"0.7.44": {
|
|
1768
|
+
"en": "Publish hotfix: package metadata cleaned and conflict-marker checks hardened so npm publish no longer fails on unresolved package.json merge markers.",
|
|
1769
|
+
"de": "Publish-Hotfix: Paket-Metadaten bereinigt und Konfliktmarker-Prüfung gehärtet, damit npm publish nicht mehr an ungelösten package.json-Merge-Markern scheitert."
|
|
1762
1770
|
}
|
|
1763
1771
|
},
|
|
1764
1772
|
"title": "NexoWatt UI",
|
|
@@ -1979,7 +1987,7 @@
|
|
|
1979
1987
|
}
|
|
1980
1988
|
},
|
|
1981
1989
|
"instanceObjects": [],
|
|
1982
|
-
"version": "0.7.
|
|
1990
|
+
"version": "0.7.44",
|
|
1983
1991
|
"news": {
|
|
1984
1992
|
"0.7.42": {
|
|
1985
1993
|
"en": "Feature-dependent visibility fixed: EVCS/charging station and storage farm are only shown in the customer frontend when they are actually configured. Default/legacy placeholders no longer enable wallbox UI; AI Advisor suppresses EV/wallbox hints when no wallbox is available.",
|
|
@@ -3687,6 +3695,14 @@
|
|
|
3687
3695
|
"0.7.33": {
|
|
3688
3696
|
"en": "Applied the new responsive cockpit design across all frontend subpages including history, settings, EVCS, SmartHome, App-Center, logic, simulation and reports.",
|
|
3689
3697
|
"de": "Neues responsives Cockpit-Design auf alle Frontend-Unterseiten angewendet: History, Einstellungen, EVCS, SmartHome, App-Center, Logik, Simulation und Reports."
|
|
3698
|
+
},
|
|
3699
|
+
"0.7.43": {
|
|
3700
|
+
"en": "AI Advisor storage SoC source fixed: storage farm default values no longer override the real single-storage SoC. The advisor now publishes its SoC source for diagnostics and avoids false low-reserve warnings when storageFarm is not configured.",
|
|
3701
|
+
"de": "KI-Energieberater Speicher-SoC korrigiert: Defaultwerte der Speicherfarm überdecken den echten Einzel-Speicher-SoC nicht mehr. Der Berater veröffentlicht jetzt die verwendete SoC-Quelle zur Diagnose und vermeidet falsche Niedrigreserve-Meldungen, wenn keine Speicherfarm konfiguriert ist."
|
|
3702
|
+
},
|
|
3703
|
+
"0.7.44": {
|
|
3704
|
+
"en": "Publish hotfix: package metadata cleaned and conflict-marker checks hardened so npm publish no longer fails on unresolved package.json merge markers.",
|
|
3705
|
+
"de": "Publish-Hotfix: Paket-Metadaten bereinigt und Konfliktmarker-Prüfung gehärtet, damit npm publish nicht mehr an ungelösten package.json-Merge-Markern scheitert."
|
|
3690
3706
|
}
|
|
3691
3707
|
}
|
|
3692
3708
|
}
|
package/package.json
CHANGED
package/www/manifest.webmanifest
CHANGED
package/www/sw.js
CHANGED