iobroker.nexowatt-ui 0.7.41 → 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.
@@ -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 storageSocPct = await this._readNumber(['storageFarm.totalSoc', 'speicher.regelung.socPct', 'storageSoc'], null);
601
- const storageChargeW = await this._readNumber(['ems.budget.storageChargeW', 'storageFarm.totalChargePowerW', 'storageChargePower'], 0);
602
- const storageDischargeW = await this._readNumber(['ems.budget.storageDischargeW', 'storageFarm.totalDischargePowerW', 'storageDischargePower'], 0);
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,9 +1,9 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "nexowatt-ui",
4
- "version": "0.7.41",
4
+ "version": "0.7.44",
5
5
  "news": {
6
- "0.7.41": {
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.",
8
8
  "de": "Anlagenabhängige Sichtbarkeit korrigiert: EVCS/Ladestation und Speicherfarm erscheinen im Kunden-Frontend nur noch, wenn sie wirklich konfiguriert sind. Default-/Legacy-Placeholder aktivieren keine Wallbox-Anzeige mehr; KI-Empfehlungen verzichten ohne Wallbox auf EV-/Wallbox-Hinweise."
9
9
  },
@@ -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,9 +1987,9 @@
1979
1987
  }
1980
1988
  },
1981
1989
  "instanceObjects": [],
1982
- "version": "0.7.41",
1990
+ "version": "0.7.44",
1983
1991
  "news": {
1984
- "0.7.41": {
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.",
1986
1994
  "de": "Anlagenabhängige Sichtbarkeit korrigiert: EVCS/Ladestation und Speicherfarm erscheinen im Kunden-Frontend nur noch, wenn sie wirklich konfiguriert sind. Default-/Legacy-Placeholder aktivieren keine Wallbox-Anzeige mehr; KI-Empfehlungen verzichten ohne Wallbox auf EV-/Wallbox-Hinweise."
1987
1995
  },
@@ -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/main.js CHANGED
@@ -17662,6 +17662,83 @@ Technische Details: system.adapter.${c.inst}.alive=false`,
17662
17662
  };
17663
17663
  };
17664
17664
 
17665
+ const fromBalance = () => {
17666
+ try {
17667
+ const balanceDeadbandW = Math.max(180, deadbandW);
17668
+ if (this.stateCache && this.stateCache['storageFarm.enabled'] && this.stateCache['storageFarm.enabled'].value) return null;
17669
+
17670
+ const soc = this._nwGetNumberFromCache('storageSoc');
17671
+ if (!Number.isFinite(Number(soc))) return null;
17672
+
17673
+ // Nur mit direkt gemessenem Hausverbrauch ableiten. Ohne Direktmessung wäre
17674
+ // consumptionTotal evtl. schon aus derselben Bilanz berechnet und damit zirkulär.
17675
+ const hasDirectLoad = this._nwHasMappedDatapoint('consumptionTotal') || this._nwHasMappedDatapoint('housePower');
17676
+ if (!hasDirectLoad) return null;
17677
+
17678
+ let load = this._nwGetNumberFromCache('consumptionTotal');
17679
+ if (load === null || !Number.isFinite(Number(load))) load = this._nwGetNumberFromCache('housePower');
17680
+ if (load === null || !Number.isFinite(Number(load))) return null;
17681
+
17682
+ const grid = this._nwResolveGridImportExportFromCache ? this._nwResolveGridImportExportFromCache() : null;
17683
+ if (!grid || !grid.hasGrid) return null;
17684
+
17685
+ let pv = this._nwGetNumberFromCache('pvPower');
17686
+ if ((pv === null || !Number.isFinite(Number(pv))) && this._nwHasMappedDatapoint('productionTotal')) {
17687
+ pv = this._nwGetNumberFromCache('productionTotal');
17688
+ }
17689
+ if (pv === null || !Number.isFinite(Number(pv))) return null;
17690
+
17691
+ let production = Math.max(0, Math.abs(Number(pv) || 0));
17692
+ for (let i = 1; i <= 5; i++) {
17693
+ const extra = this._nwGetNumberFromCache(`producer${i}Power`);
17694
+ if (Number.isFinite(Number(extra))) production += Math.max(0, Math.abs(Number(extra)));
17695
+ }
17696
+
17697
+ const buy = Math.max(0, Number(grid.gridBuyW) || 0);
17698
+ const sell = Math.max(0, Number(grid.gridSellW) || 0);
17699
+ const signed = Math.round(Math.max(0, Number(load) || 0) - production - buy + sell);
17700
+ if (!Number.isFinite(signed) || Math.abs(signed) <= balanceDeadbandW) return null;
17701
+
17702
+ const activity = production + Math.max(0, Number(load) || 0) + buy + sell;
17703
+ if (activity < 500) return null;
17704
+ if (Math.abs(signed) > Math.max(3000, activity * 1.15)) return null;
17705
+ if (signed < 0 && Number(soc) >= 99.5) return null;
17706
+ if (signed > 0 && Number(soc) <= 0.5) return null;
17707
+
17708
+ return {
17709
+ chargeW: signed < 0 ? Math.abs(signed) : 0,
17710
+ dischargeW: signed > 0 ? signed : 0,
17711
+ signedW: signed,
17712
+ src: 'balanceDerived',
17713
+ inverted: false,
17714
+ fromSigned: false,
17715
+ mirror: true,
17716
+ staleMs: {
17717
+ balance: 0,
17718
+ batteryPower: this._nwGetCacheAgeMs('batteryPower', now),
17719
+ storageChargePower: this._nwGetCacheAgeMs('storageChargePower', now),
17720
+ storageDischargePower: this._nwGetCacheAgeMs('storageDischargePower', now),
17721
+ },
17722
+ };
17723
+ } catch (_eBalance) {
17724
+ return null;
17725
+ }
17726
+ };
17727
+
17728
+ const preferBalance = (current) => {
17729
+ try {
17730
+ const measured = Math.max(0, Math.abs(Number(current && current.chargeW) || 0) + Math.abs(Number(current && current.dischargeW) || 0));
17731
+ const srcCur = String(current && current.src || '');
17732
+ const missingLike = !current || srcCur === 'missing' || srcCur === 'stale-or-missing';
17733
+ const derived = fromBalance();
17734
+ if (!derived) return current;
17735
+ if (missingLike || measured <= Math.max(180, deadbandW)) return derived;
17736
+ return current;
17737
+ } catch (_ePrefer) {
17738
+ return current;
17739
+ }
17740
+ };
17741
+
17665
17742
  // Speicherfarm already provides normalized charge/discharge totals. Keep it authoritative
17666
17743
  // unless a signed single battery datapoint is explicitly mapped for a non-farm setup.
17667
17744
  const sfEnabled = !!(this.stateCache && this.stateCache['storageFarm.enabled'] && this.stateCache['storageFarm.enabled'].value);
@@ -17695,7 +17772,7 @@ Technische Details: system.adapter.${c.inst}.alive=false`,
17695
17772
  // If charge/discharge were both mapped to the same signed datapoint, keep the sign.
17696
17773
  // updateValue() normalizes their public state values to magnitudes, so the private raw cache is used here.
17697
17774
  if (sameChargeDischargeId && chargeRaw !== null) {
17698
- return fromSigned(chargeRaw, 'sameChargeDischargeSigned', { mirror: true });
17775
+ return preferBalance(fromSigned(chargeRaw, 'sameChargeDischargeSigned', { mirror: true }));
17699
17776
  }
17700
17777
 
17701
17778
  // Canonical single signed DP fallback: exactly like NVP signed handling.
@@ -17708,7 +17785,7 @@ Technische Details: system.adapter.${c.inst}.alive=false`,
17708
17785
  const bothEqualish = bothPublicDirections && Math.abs(Math.abs(Number(publicCharge || 0)) - Math.abs(Number(publicDischarge || 0))) <= Math.max(2, deadbandW);
17709
17786
 
17710
17787
  if (batterySigned !== null && (!separateAvailable || bothEqualish || (!chargeMapped && !dischargeMapped))) {
17711
- return fromSigned(batterySigned, bothEqualish ? 'batterySignedOverrideDual' : 'batterySigned', { mirror: true });
17788
+ return preferBalance(fromSigned(batterySigned, bothEqualish ? 'batterySignedOverrideDual' : 'batterySigned', { mirror: true }));
17712
17789
  }
17713
17790
 
17714
17791
  if (separateAvailable) {
@@ -17719,7 +17796,7 @@ Technische Details: system.adapter.${c.inst}.alive=false`,
17719
17796
  if (c <= deadbandW) c = 0;
17720
17797
  if (d <= deadbandW) d = 0;
17721
17798
  if (inv) { const t = c; c = d; d = t; }
17722
- return {
17799
+ return preferBalance({
17723
17800
  chargeW: Math.round(c),
17724
17801
  dischargeW: Math.round(d),
17725
17802
  signedW: Math.round(d - c),
@@ -17731,14 +17808,14 @@ Technische Details: system.adapter.${c.inst}.alive=false`,
17731
17808
  storageChargePower: this._nwGetCacheAgeMs('storageChargePower', now),
17732
17809
  storageDischargePower: this._nwGetCacheAgeMs('storageDischargePower', now),
17733
17810
  },
17734
- };
17811
+ });
17735
17812
  }
17736
17813
 
17737
17814
  if (batterySigned !== null) {
17738
- return fromSigned(batterySigned, 'batterySigned', { mirror: true });
17815
+ return preferBalance(fromSigned(batterySigned, 'batterySigned', { mirror: true }));
17739
17816
  }
17740
17817
 
17741
- return {
17818
+ return preferBalance({
17742
17819
  chargeW: 0,
17743
17820
  dischargeW: 0,
17744
17821
  signedW: 0,
@@ -17751,7 +17828,7 @@ Technische Details: system.adapter.${c.inst}.alive=false`,
17751
17828
  storageChargePower: this._nwGetCacheAgeMs('storageChargePower', now),
17752
17829
  storageDischargePower: this._nwGetCacheAgeMs('storageDischargePower', now),
17753
17830
  },
17754
- };
17831
+ });
17755
17832
  }
17756
17833
 
17757
17834
  _nwResolveGridImportExportFromCache() {
@@ -19288,7 +19365,7 @@ Technische Details: system.adapter.${c.inst}.alive=false`,
19288
19365
  if (!Number.isFinite(curC) || curC !== chargeRound) this.updateValue('storageChargePower', chargeRound, ts, { raw: false });
19289
19366
  if (!Number.isFinite(curD) || curD !== dischargeRound) this.updateValue('storageDischargePower', dischargeRound, ts, { raw: false });
19290
19367
  }
19291
- if (!this._nwHasMappedDatapoint('batteryPower')) {
19368
+ if (!this._nwHasMappedDatapoint('batteryPower') || (storageFlow && storageFlow.src === 'balanceDerived')) {
19292
19369
  const signedRound = Math.round(dischargeW - chargeW);
19293
19370
  const curB = Number(this.stateCache?.batteryPower?.value);
19294
19371
  if (!Number.isFinite(curB) || curB !== signedRound) this.updateValue('batteryPower', signedRound, ts, { raw: false });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.nexowatt-ui",
3
- "version": "0.7.41",
3
+ "version": "0.7.44",
4
4
  "description": "Responsive NexoWatt EMS visualization adapter.",
5
5
  "author": "NexoWatt",
6
6
  "license": "Proprietary License (NPL) v1.0",
package/www/app.js CHANGED
@@ -1037,22 +1037,35 @@ function nwAsBool(v, def) {
1037
1037
 
1038
1038
  function nwFeatureMappedRow(row) {
1039
1039
  if (!row || row.enabled === false) return false;
1040
+ // Nur echte Ladepunkt-Zuordnungen zählen. Legacy-Aggregate wie consumptionEvcs
1041
+ // oder alte boolesche Flags dürfen eine Kundenanlage ohne Wallbox nicht sichtbar machen.
1040
1042
  const fields = ['powerId','energyTotalId','energySessionId','statusId','activeId','onlineId','setCurrentAId','setPowerWId','enableWriteId','lockWriteId','rfidReadId','vehicleSocId'];
1041
1043
  return fields.some((key) => String(row[key] || '').trim());
1042
1044
  }
1043
1045
 
1046
+ function nwConfiguredEvcsRows(inputCfg) {
1047
+ const c = inputCfg || window.__nwCfg || {};
1048
+ try {
1049
+ const sc = (c.settingsConfig && typeof c.settingsConfig === 'object') ? c.settingsConfig : {};
1050
+ const fromSettings = Array.isArray(sc.evcsList) ? sc.evcsList : [];
1051
+ const fromRuntime = Array.isArray(c.evcsList) ? c.evcsList : [];
1052
+ const list = fromSettings.length ? fromSettings : fromRuntime;
1053
+ return list.filter(nwFeatureMappedRow);
1054
+ } catch (_e) {
1055
+ return [];
1056
+ }
1057
+ }
1058
+
1044
1059
  function nwEvcsFeatureFromConfig(inputCfg) {
1045
1060
  const c = inputCfg || window.__nwCfg || {};
1046
1061
  try {
1062
+ const rows = nwConfiguredEvcsRows(c);
1047
1063
  const sc = (c.settingsConfig && typeof c.settingsConfig === 'object') ? c.settingsConfig : {};
1048
- if (typeof sc.evcsAvailable === 'boolean') return sc.evcsAvailable;
1049
- if (c.ems && typeof c.ems.evcsAvailable === 'boolean') return c.ems.evcsAvailable;
1050
- const meta = c.flowSlots && c.flowSlots.meta;
1051
- if (meta && typeof meta.evcsAvailable === 'boolean') return meta.evcsAvailable;
1052
- const count = Number(sc.evcsCount ?? window.__nwEvcsCount ?? 0);
1053
- const list = Array.isArray(sc.evcsList) ? sc.evcsList : [];
1054
- const mapped = list.some(nwFeatureMappedRow);
1055
- return Number.isFinite(count) && count > 0 && mapped;
1064
+ const configuredCount = Number(sc.evcsConfiguredCount ?? (c.flowSlots && c.flowSlots.meta && c.flowSlots.meta.evcsConfiguredCount) ?? rows.length);
1065
+ const count = Number(sc.evcsCount ?? window.__nwEvcsCount ?? configuredCount ?? 0);
1066
+ // Strikte Regel: Sichtbar erst ab realem Ladepunkt. Ein altes evcsAvailable=true
1067
+ // ohne gemappte Ladepunkt-Zeile wird bewusst ignoriert.
1068
+ return rows.length > 0 || (Number.isFinite(configuredCount) && configuredCount > 0 && Number.isFinite(count) && count > 0);
1056
1069
  } catch (_e) {
1057
1070
  return false;
1058
1071
  }
@@ -2037,6 +2050,77 @@ function getConfiguredDatapointId(key) {
2037
2050
  }
2038
2051
  }
2039
2052
 
2053
+ function getBalanceDerivedBatteryFlow(opts = {}) {
2054
+ try {
2055
+ const deadbandW = Number.isFinite(Number(opts.deadbandW)) ? Math.max(0, Number(opts.deadbandW)) : 180;
2056
+ const st = state || window.latestState || {};
2057
+ const read = (k) => st && st[k] ? st[k].value : undefined;
2058
+
2059
+ // In Speicherfarm-Anlagen sind die Farm-Summen die Quelle der Wahrheit.
2060
+ if (nwAsBool(read('storageFarm.enabled'), false)) return null;
2061
+
2062
+ const soc = coerceNumber(read('storageSoc') ?? read('batterySOC'));
2063
+ if (soc === null) return null;
2064
+
2065
+ // Nur aus der Bilanz ableiten, wenn eine echte Verbrauchsleistung gemappt ist.
2066
+ // Sonst würden wir aus einem bereits abgeleiteten consumptionTotal wieder zurückrechnen.
2067
+ const hasDirectLoad = isMappedDatapoint('consumptionTotal') || isMappedDatapoint('housePower');
2068
+ if (!hasDirectLoad) return null;
2069
+
2070
+ const load = coerceNumber(read('consumptionTotal') ?? read('housePower'));
2071
+ if (load === null) return null;
2072
+
2073
+ const grid = getGridImportExport(read);
2074
+ if (!grid || !grid.hasGridInfo) return null;
2075
+
2076
+ let pv = coerceNumber(read('pvPower'));
2077
+ if (pv === null && isMappedDatapoint('productionTotal')) pv = coerceNumber(read('productionTotal'));
2078
+ if (pv === null) return null;
2079
+
2080
+ let production = Math.max(0, Math.abs(Number(pv) || 0));
2081
+ for (let i = 1; i <= 5; i++) {
2082
+ const p = coerceNumber(read(`producer${i}Power`));
2083
+ if (p !== null) production += Math.max(0, Math.abs(p));
2084
+ }
2085
+
2086
+ const signed = Math.round((Math.max(0, load) - production - Math.max(0, grid.buy || 0) + Math.max(0, grid.sell || 0)));
2087
+ if (!Number.isFinite(signed) || Math.abs(signed) <= deadbandW) return null;
2088
+
2089
+ // Plausibilitätsbremsen gegen kurze Messversätze oder unbekannte Verbraucher.
2090
+ const activity = production + Math.max(0, load) + Math.max(0, grid.buy || 0) + Math.max(0, grid.sell || 0);
2091
+ if (activity < 500) return null;
2092
+ if (Math.abs(signed) > Math.max(3000, activity * 1.15)) return null;
2093
+ if (signed < 0 && soc >= 99.5) return null;
2094
+ if (signed > 0 && soc <= 0.5) return null;
2095
+
2096
+ return {
2097
+ chargeW: signed < 0 ? Math.abs(signed) : 0,
2098
+ dischargeW: signed > 0 ? signed : 0,
2099
+ signedW: signed,
2100
+ src: 'balanceDerived',
2101
+ inverted: false,
2102
+ derived: true
2103
+ };
2104
+ } catch (_e) {
2105
+ return null;
2106
+ }
2107
+ }
2108
+
2109
+ function preferBalanceDerivedBatteryFlow(current, opts = {}) {
2110
+ try {
2111
+ const deadbandW = Number.isFinite(Number(opts.deadbandW)) ? Math.max(180, Number(opts.deadbandW)) : 180;
2112
+ const measured = Math.max(0, Math.abs(Number(current && current.chargeW) || 0) + Math.abs(Number(current && current.dischargeW) || 0));
2113
+ const src = String(current && current.src || '');
2114
+ const missingLike = !current || src === 'missing' || src === 'stale-or-missing';
2115
+ const derived = getBalanceDerivedBatteryFlow({ deadbandW });
2116
+ if (!derived) return current;
2117
+ if (missingLike || measured <= deadbandW) return derived;
2118
+ return current;
2119
+ } catch (_e) {
2120
+ return current;
2121
+ }
2122
+ }
2123
+
2040
2124
  function getNormalizedBatteryFlow() {
2041
2125
  const deadbandW = 25;
2042
2126
  const inv = !!(state && state['settings.flowInvertBattery'] && state['settings.flowInvertBattery'].value);
@@ -2080,14 +2164,14 @@ function getNormalizedBatteryFlow() {
2080
2164
  const charge = chargeMapped ? getFreshFlowNumber('storageChargePower') : null;
2081
2165
  const discharge = dischargeMapped ? getFreshFlowNumber('storageDischargePower') : null;
2082
2166
 
2083
- if (samePair && signedBattery !== null) return fromSigned(signedBattery, 'batterySignedForSamePair');
2167
+ if (samePair && signedBattery !== null) return preferBalanceDerivedBatteryFlow(fromSigned(signedBattery, 'batterySignedForSamePair'), { deadbandW });
2084
2168
 
2085
2169
  const separateAvailable = (charge !== null || discharge !== null);
2086
2170
  const bothDirections = Math.abs(Number(charge || 0)) > deadbandW && Math.abs(Number(discharge || 0)) > deadbandW;
2087
2171
  const bothEqualish = bothDirections && Math.abs(Math.abs(Number(charge || 0)) - Math.abs(Number(discharge || 0))) <= Math.max(2, deadbandW);
2088
2172
 
2089
2173
  if (signedBattery !== null && (!separateAvailable || bothEqualish || (!chargeMapped && !dischargeMapped))) {
2090
- return fromSigned(signedBattery, bothEqualish ? 'batterySignedOverrideDual' : 'batterySigned');
2174
+ return preferBalanceDerivedBatteryFlow(fromSigned(signedBattery, bothEqualish ? 'batterySignedOverrideDual' : 'batterySigned'), { deadbandW });
2091
2175
  }
2092
2176
 
2093
2177
  if (separateAvailable) {
@@ -2096,12 +2180,12 @@ function getNormalizedBatteryFlow() {
2096
2180
  if (c <= deadbandW) c = 0;
2097
2181
  if (d <= deadbandW) d = 0;
2098
2182
  if (inv) { const t = c; c = d; d = t; }
2099
- return { chargeW: c, dischargeW: d, signedW: d - c, src: inv ? 'chargeDischarge(inv)' : 'chargeDischarge', inverted: inv };
2183
+ return preferBalanceDerivedBatteryFlow({ chargeW: c, dischargeW: d, signedW: d - c, src: inv ? 'chargeDischarge(inv)' : 'chargeDischarge', inverted: inv }, { deadbandW });
2100
2184
  }
2101
2185
 
2102
- if (signedBattery !== null) return fromSigned(signedBattery, 'batterySigned');
2186
+ if (signedBattery !== null) return preferBalanceDerivedBatteryFlow(fromSigned(signedBattery, 'batterySigned'), { deadbandW });
2103
2187
 
2104
- return { chargeW: 0, dischargeW: 0, signedW: 0, src: (batteryMapped || chargeMapped || dischargeMapped) ? 'stale-or-missing' : 'missing', inverted: inv };
2188
+ return preferBalanceDerivedBatteryFlow({ chargeW: 0, dischargeW: 0, signedW: 0, src: (batteryMapped || chargeMapped || dischargeMapped) ? 'stale-or-missing' : 'missing', inverted: inv }, { deadbandW });
2105
2189
  }
2106
2190
 
2107
2191
  function render() {
@@ -52,7 +52,7 @@
52
52
  fetch('/config', { cache: 'no-store' }).then(function(r){ return r.json(); }).then(function(cfg){
53
53
  cfg = cfg || {};
54
54
  var sc = (cfg.settingsConfig && typeof cfg.settingsConfig === 'object') ? cfg.settingsConfig : {};
55
- var evAvail = !!(sc.evcsAvailable || (cfg.ems && cfg.ems.evcsAvailable));
55
+ var evAvail = ((Number(sc.evcsConfiguredCount || 0) || (Array.isArray(sc.evcsList) ? sc.evcsList.filter(function(r){ if(!r || r.enabled === false) return false; return ['powerId','energyTotalId','energySessionId','statusId','activeId','onlineId','setCurrentAId','setPowerWId','enableWriteId','lockWriteId','rfidReadId','vehicleSocId'].some(function(k){ return String(r[k] || '').trim(); }); }).length : 0)) > 0);
56
56
  var evCount = Math.max(0, Math.round(Number(sc.evcsCount || 0) || 0));
57
57
  var showEvcs = evAvail && evCount >= 2;
58
58
  var sh = !!((cfg.smartHome && cfg.smartHome.enabled) || cfg.smartHomeEnabled);
@@ -284,7 +284,7 @@ function toISODate(ms){
284
284
  const settingsConfig = (cfg && cfg.settingsConfig) || {};
285
285
  const smartHomeEnabled = !!(cfg && (cfg.smartHomeEnabled || (cfg.smartHome && cfg.smartHome.enabled)));
286
286
  const storageFarmEnabled = !!(cfg && ((typeof cfg.storageFarmEnabled === 'boolean') ? cfg.storageFarmEnabled : (cfg.ems && cfg.ems.storageFarmEnabled)));
287
- const evcsAvailable = !!(settingsConfig.evcsAvailable || (cfg && cfg.ems && cfg.ems.evcsAvailable));
287
+ const evcsAvailable = ((Number(settingsConfig.evcsConfiguredCount || 0) || (Array.isArray(settingsConfig.evcsList) ? settingsConfig.evcsList.filter(function(r){ if(!r || r.enabled === false) return false; return ['powerId','energyTotalId','energySessionId','statusId','activeId','onlineId','setCurrentAId','setPowerWId','enableWriteId','lockWriteId','rfidReadId','vehicleSocId'].some(function(k){ return String(r[k] || '').trim(); }); }).length : 0)) > 0);
288
288
  const evcsCount = evcsAvailable ? Math.max(0, Math.round(Number(settingsConfig.evcsCount) || 0)) : 0;
289
289
 
290
290
  const tabEvcs = document.getElementById('tabEvcs');
package/www/evcs.js CHANGED
@@ -702,7 +702,7 @@ function render() {
702
702
  if (!list) return;
703
703
 
704
704
  const sc = (cfg && cfg.settingsConfig) || {};
705
- const evcsAvailable = !!(sc.evcsAvailable || (cfg && cfg.ems && cfg.ems.evcsAvailable));
705
+ const evcsAvailable = ((Number(sc.evcsConfiguredCount || 0) || (Array.isArray(sc.evcsList) ? sc.evcsList.filter(function(r){ if(!r || r.enabled === false) return false; return ['powerId','energyTotalId','energySessionId','statusId','activeId','onlineId','setCurrentAId','setPowerWId','enableWriteId','lockWriteId','rfidReadId','vehicleSocId'].some(function(k){ return String(r[k] || '').trim(); }); }).length : 0)) > 0);
706
706
  const count = evcsAvailable ? Math.max(0, Math.round(Number(sc.evcsCount) || 0)) : 0;
707
707
  const meta = evcsAvailable && Array.isArray(sc.evcsList) ? sc.evcsList : [];
708
708
 
@@ -1251,7 +1251,7 @@ async function bootstrap() {
1251
1251
  try {
1252
1252
  cfg = await fetch('/config', { cache: 'no-store' }).then(r => r.json());
1253
1253
  const sc = (cfg && cfg.settingsConfig) || {};
1254
- const evcsAvailable = !!(sc.evcsAvailable || (cfg && cfg.ems && cfg.ems.evcsAvailable));
1254
+ const evcsAvailable = ((Number(sc.evcsConfiguredCount || 0) || (Array.isArray(sc.evcsList) ? sc.evcsList.filter(function(r){ if(!r || r.enabled === false) return false; return ['powerId','energyTotalId','energySessionId','statusId','activeId','onlineId','setCurrentAId','setPowerWId','enableWriteId','lockWriteId','rfidReadId','vehicleSocId'].some(function(k){ return String(r[k] || '').trim(); }); }).length : 0)) > 0);
1255
1255
  const c = evcsAvailable ? Math.max(0, Math.round(Number(sc.evcsCount) || 0)) : 0;
1256
1256
  const showEvcsPage = evcsAvailable && c >= 2;
1257
1257
  if (!showEvcsPage) {
package/www/history.js CHANGED
@@ -2257,7 +2257,7 @@ async function load(force = false){
2257
2257
  (function(){
2258
2258
  fetch('/config', { cache: 'no-store' }).then(r=>r.json()).then(cfg=>{
2259
2259
  const sc = (cfg && cfg.settingsConfig) || {};
2260
- const evcsAvailable = !!(sc.evcsAvailable || (cfg && cfg.ems && cfg.ems.evcsAvailable));
2260
+ const evcsAvailable = ((Number(sc.evcsConfiguredCount || 0) || (Array.isArray(sc.evcsList) ? sc.evcsList.filter(function(r){ if(!r || r.enabled === false) return false; return ['powerId','energyTotalId','energySessionId','statusId','activeId','onlineId','setCurrentAId','setPowerWId','enableWriteId','lockWriteId','rfidReadId','vehicleSocId'].some(function(k){ return String(r[k] || '').trim(); }); }).length : 0)) > 0);
2261
2261
  const c = evcsAvailable ? Math.max(0, Math.round(Number(sc.evcsCount) || 0)) : 0;
2262
2262
  const showEvcs = evcsAvailable && c >= 2;
2263
2263
  const l = document.getElementById('menuEvcsLink');
package/www/logic.js CHANGED
@@ -2909,7 +2909,7 @@ document.addEventListener('DOMContentLoaded', () => {
2909
2909
  }
2910
2910
  fetch('/config', { cache: 'no-store' }).then(r=>r.json()).then(cfg=>{
2911
2911
  const sc = (cfg && cfg.settingsConfig) || {};
2912
- const evcsAvailable = !!(sc.evcsAvailable || (cfg && cfg.ems && cfg.ems.evcsAvailable));
2912
+ const evcsAvailable = ((Number(sc.evcsConfiguredCount || 0) || (Array.isArray(sc.evcsList) ? sc.evcsList.filter(function(r){ if(!r || r.enabled === false) return false; return ['powerId','energyTotalId','energySessionId','statusId','activeId','onlineId','setCurrentAId','setPowerWId','enableWriteId','lockWriteId','rfidReadId','vehicleSocId'].some(function(k){ return String(r[k] || '').trim(); }); }).length : 0)) > 0);
2913
2913
  const c = evcsAvailable ? Math.max(0, Math.round(Number(sc.evcsCount) || 0)) : 0;
2914
2914
  const showEvcs = evcsAvailable && c >= 2;
2915
2915
  const l=document.getElementById('menuEvcsLink');
@@ -44,5 +44,5 @@
44
44
  "purpose": "maskable"
45
45
  }
46
46
  ],
47
- "version": "0.7.41"
47
+ "version": "0.7.44"
48
48
  }
@@ -148,7 +148,7 @@
148
148
  const settingsConfig = (cfg && cfg.settingsConfig) || {};
149
149
  const smartHomeEnabled = !!(cfg && (cfg.smartHomeEnabled || (cfg.smartHome && cfg.smartHome.enabled)));
150
150
  const storageFarmEnabled = !!(cfg && ((typeof cfg.storageFarmEnabled === 'boolean') ? cfg.storageFarmEnabled : (cfg.ems && cfg.ems.storageFarmEnabled)));
151
- const evcsAvailable = !!(settingsConfig.evcsAvailable || (cfg && cfg.ems && cfg.ems.evcsAvailable));
151
+ const evcsAvailable = ((Number(settingsConfig.evcsConfiguredCount || 0) || (Array.isArray(settingsConfig.evcsList) ? settingsConfig.evcsList.filter(function(r){ if(!r || r.enabled === false) return false; return ['powerId','energyTotalId','energySessionId','statusId','activeId','onlineId','setCurrentAId','setPowerWId','enableWriteId','lockWriteId','rfidReadId','vehicleSocId'].some(function(k){ return String(r[k] || '').trim(); }); }).length : 0)) > 0);
152
152
  const evcsCount = evcsAvailable ? Math.max(0, Math.round(Number(settingsConfig.evcsCount) || 0)) : 0;
153
153
  const showEvcs = evcsAvailable && evcsCount >= 2;
154
154
 
package/www/smarthome.js CHANGED
@@ -8397,7 +8397,7 @@ async function nwLoadUiConfigFlags() {
8397
8397
  const cfg = await fetch('/config', { cache: 'no-store' }).then(r => r.json());
8398
8398
 
8399
8399
  const sc = (cfg && cfg.settingsConfig) || {};
8400
- const evcsAvailable = !!(sc.evcsAvailable || (cfg && cfg.ems && cfg.ems.evcsAvailable));
8400
+ const evcsAvailable = ((Number(sc.evcsConfiguredCount || 0) || (Array.isArray(sc.evcsList) ? sc.evcsList.filter(function(r){ if(!r || r.enabled === false) return false; return ['powerId','energyTotalId','energySessionId','statusId','activeId','onlineId','setCurrentAId','setPowerWId','enableWriteId','lockWriteId','rfidReadId','vehicleSocId'].some(function(k){ return String(r[k] || '').trim(); }); }).length : 0)) > 0);
8401
8401
  nwEvcsCount = evcsAvailable ? Math.max(0, Math.round(Number(sc.evcsCount) || 0)) : 0;
8402
8402
  nwSmartHomeEnabled = !!((cfg.smartHome && cfg.smartHome.enabled) || cfg.smartHomeEnabled);
8403
8403
  const storageFarmEnabled = (typeof cfg.storageFarmEnabled === 'boolean') ? !!cfg.storageFarmEnabled : !!(cfg.ems && cfg.ems.storageFarmEnabled);
@@ -126,7 +126,7 @@
126
126
  var evcsCount = Math.max(0, Math.round(Number(settingsConfig.evcsCount) || 0));
127
127
  var smartHomeEnabled = !!(cfg && cfg.smartHome && cfg.smartHome.enabled);
128
128
  var storageFarmEnabled = (typeof cfg.storageFarmEnabled === 'boolean') ? !!cfg.storageFarmEnabled : !!(ems.storageFarmEnabled || cfg.storageFarmEnabled);
129
- var evcsAvailable = !!(cfg && cfg.settingsConfig && cfg.settingsConfig.evcsAvailable);
129
+ var evcsAvailable = ((Number(settingsConfig.evcsConfiguredCount || 0) || (Array.isArray(settingsConfig.evcsList) ? settingsConfig.evcsList.filter(function(r){ if(!r || r.enabled === false) return false; return ['powerId','energyTotalId','energySessionId','statusId','activeId','onlineId','setCurrentAId','setPowerWId','enableWriteId','lockWriteId','rfidReadId','vehicleSocId'].some(function(k){ return String(r[k] || '').trim(); }); }).length : 0)) > 0);
130
130
  var evcsTab = el('tabEvcs');
131
131
  var evcsMenu = el('menuEvcsLink');
132
132
  var shTab = el('tabSmartHome');
package/www/sw.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Increment cache name on releases so browser updates JS/HTML reliably.
2
2
  // NOTE: Keep this monotonic to force SW updates on hotfixes.
3
- const CACHE_NAME = 'nexowatt-cache-v209';
3
+ const CACHE_NAME = 'nexowatt-cache-v212';
4
4
 
5
5
  const OFFLINE_URLS = [
6
6
  './',
@@ -742,7 +742,7 @@
742
742
  (function(){
743
743
  fetch('/config', { cache: 'no-store' }).then(r=>r.json()).then(cfg=>{
744
744
  const sc = (cfg && cfg.settingsConfig) || {};
745
- const evcsAvailable = !!(sc.evcsAvailable || (cfg && cfg.ems && cfg.ems.evcsAvailable));
745
+ const evcsAvailable = ((Number(sc.evcsConfiguredCount || 0) || (Array.isArray(sc.evcsList) ? sc.evcsList.filter(function(r){ if(!r || r.enabled === false) return false; return ['powerId','energyTotalId','energySessionId','statusId','activeId','onlineId','setCurrentAId','setPowerWId','enableWriteId','lockWriteId','rfidReadId','vehicleSocId'].some(function(k){ return String(r[k] || '').trim(); }); }).length : 0)) > 0);
746
746
  const c = evcsAvailable ? Math.max(0, Math.round(Number(sc.evcsCount) || 0)) : 0;
747
747
  const showEvcs = evcsAvailable && c >= 2;
748
748
  const l = document.getElementById('menuEvcsLink');