iobroker.nexowatt-ui 0.7.40 → 0.7.41

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.
@@ -109,6 +109,34 @@ function isPeakShavingConfigured(config) {
109
109
  return ps.enabled === true || atypical.enabled === true;
110
110
  }
111
111
 
112
+
113
+ const EVCS_MAPPING_FIELDS = [
114
+ 'powerId', 'energyTotalId', 'energySessionId', 'statusId', 'activeId', 'modeId', 'onlineId',
115
+ 'setCurrentAId', 'setPowerWId', 'enableWriteId', 'lockWriteId', 'rfidReadId', 'vehicleSocId',
116
+ ];
117
+
118
+ function evcsRowHasMapping(row) {
119
+ const r = (row && typeof row === 'object') ? row : {};
120
+ return EVCS_MAPPING_FIELDS.some((key) => String(r[key] === null || r[key] === undefined ? '' : r[key]).trim().length > 0);
121
+ }
122
+
123
+ function inferEvcsAvailable(adapter, settingsCfg) {
124
+ const cfg = (adapter && adapter.config && typeof adapter.config === 'object') ? adapter.config : {};
125
+ const sc = (settingsCfg && typeof settingsCfg === 'object') ? settingsCfg : ((cfg.settingsConfig && typeof cfg.settingsConfig === 'object') ? cfg.settingsConfig : {});
126
+ if (typeof sc.evcsAvailable === 'boolean') return sc.evcsAvailable;
127
+ const lists = [];
128
+ if (Array.isArray(sc.evcsList)) lists.push(sc.evcsList);
129
+ if (Array.isArray(adapter && adapter.evcsList)) lists.push(adapter.evcsList);
130
+ if (Array.isArray(cfg.evcsList)) lists.push(cfg.evcsList);
131
+ if (cfg.chargingManagement && Array.isArray(cfg.chargingManagement.wallboxes)) lists.push(cfg.chargingManagement.wallboxes);
132
+ if (lists.some((list) => list.some(evcsRowHasMapping))) return true;
133
+ return false;
134
+ }
135
+
136
+ function evcsPhrase(hasEvcs, withArticle = true) {
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
+ }
139
+
112
140
  function buildPeakStateText(s, limitW, usagePct) {
113
141
  const statusRaw = String(s && s.peakStatus || '').trim();
114
142
  const suffix = statusRaw ? ` · Status ${statusRaw}` : '';
@@ -264,9 +292,11 @@ function toSafeIdPart(value) {
264
292
  .replace(/^_+|_+$/g, '');
265
293
  }
266
294
 
267
- function priorityText(priorities) {
295
+ function priorityText(priorities, options = {}) {
268
296
  const labels = { evcs: 'Wallbox', thermal: 'Thermik', heatingRod: 'Heizstab', storage: 'Speicherreserve', generic: 'sonstige Lasten' };
297
+ const hasEvcs = options && options.hasEvcs !== false;
269
298
  const entries = Object.keys(labels)
299
+ .filter((key) => hasEvcs || key !== 'evcs')
270
300
  .map((key) => ({ key, label: labels[key], value: Number(priorities && priorities[key]) || 0 }))
271
301
  .filter((x) => x.value > 0)
272
302
  .sort((a, b) => b.value - a.value);
@@ -514,8 +544,9 @@ class AiAdvisorModule extends BaseModule {
514
544
  return Array.from(new Set(keys.filter(Boolean)));
515
545
  }
516
546
 
517
- async _readEvGoals() {
547
+ async _readEvGoals(evcsAvailable = true) {
518
548
  const out = [];
549
+ if (!evcsAvailable) return out;
519
550
  const keys = this._chargingWallboxKeys();
520
551
  for (const safe of keys) {
521
552
  const base = `chargingManagement.wallboxes.${safe}`;
@@ -570,7 +601,7 @@ class AiAdvisorModule extends BaseModule {
570
601
  const storageChargeW = await this._readNumber(['ems.budget.storageChargeW', 'storageFarm.totalChargePowerW', 'storageChargePower'], 0);
571
602
  const storageDischargeW = await this._readNumber(['ems.budget.storageDischargeW', 'storageFarm.totalDischargePowerW', 'storageDischargePower'], 0);
572
603
 
573
- const evcsUsedW = await this._readNumber(['chargingManagement.control.usedW', 'evcs.totalPowerW', 'consumptionEvcs'], 0);
604
+ let evcsUsedW = await this._readNumber(['chargingManagement.control.usedW', 'evcs.totalPowerW', 'consumptionEvcs'], 0);
574
605
  const thermalUsedW = await this._readNumber(['thermal.summary.budgetUsedW'], 0);
575
606
  const heatingRodUsedW = await this._readNumber(['heatingRod.summary.budgetUsedW'], 0);
576
607
  let houseLoadW = await this._readNumber(['ems.budget.loadW', 'ems.budget.houseLoadW', 'derived.core.load.totalW', 'buildingConsumptionW', 'consumptionTotal', 'consumptionHouse'], null);
@@ -580,29 +611,33 @@ class AiAdvisorModule extends BaseModule {
580
611
 
581
612
  const aiCfg = (this.adapter && this.adapter.config && this.adapter.config.aiAdvisor && typeof this.adapter.config.aiAdvisor === 'object') ? this.adapter.config.aiAdvisor : {};
582
613
  const settingsCfg = (this.adapter && this.adapter.config && this.adapter.config.settingsConfig && typeof this.adapter.config.settingsConfig === 'object') ? this.adapter.config.settingsConfig : {};
583
- const evcsCountRaw = num(settingsCfg.evcsCount ?? this.adapter.evcsCount, Array.isArray(this.adapter && this.adapter.evcsList) ? this.adapter.evcsList.length : 0);
584
- const evcsCount = Math.max(0, Math.min(20, Math.round(num(evcsCountRaw, 0))));
614
+ const evcsAvailable = inferEvcsAvailable(this.adapter, settingsCfg);
615
+ if (!evcsAvailable) evcsUsedW = 0;
616
+ const evcsCountRaw = evcsAvailable ? num(settingsCfg.evcsCount ?? this.adapter.evcsCount, Array.isArray(this.adapter && this.adapter.evcsList) ? this.adapter.evcsList.length : 0) : 0;
617
+ const evcsCount = evcsAvailable ? Math.max(0, Math.min(20, Math.round(num(evcsCountRaw, 0)))) : 0;
585
618
  let evConnectedCount = 0;
586
619
  let evVehicleSocPct = null;
587
620
  let evStatusText = '';
588
621
  let evMode = '';
589
- for (let i = 1; i <= Math.max(1, evcsCount || 1); i++) {
590
- const status = await this._readString([`evcs.${i}.status`], '');
591
- const active = await this._readBool([`evcs.${i}.active`], false);
592
- const connectedByStatus = /charging|connected|plug|suspendedev|preparing|laden|verbunden/i.test(status || '');
593
- if (active || connectedByStatus) evConnectedCount += 1;
594
- if (!evStatusText && status) evStatusText = status;
595
- if (!evMode) evMode = await this._readString([`evcs.${i}.mode`], '');
596
- const soc = await this._readNumber([`evcs.${i}.vehicleSoc`, `evcs.${i}.vehicleSocPct`, `evcs.${i}.socPct`], null);
597
- if (finiteNumber(soc)) evVehicleSocPct = evVehicleSocPct === null ? soc : Math.min(evVehicleSocPct, soc);
622
+ if (evcsAvailable && evcsCount > 0) {
623
+ for (let i = 1; i <= evcsCount; i++) {
624
+ const status = await this._readString([`evcs.${i}.status`], '');
625
+ const active = await this._readBool([`evcs.${i}.active`], false);
626
+ const connectedByStatus = /charging|connected|plug|suspendedev|preparing|laden|verbunden/i.test(status || '');
627
+ if (active || connectedByStatus) evConnectedCount += 1;
628
+ if (!evStatusText && status) evStatusText = status;
629
+ if (!evMode) evMode = await this._readString([`evcs.${i}.mode`], '');
630
+ const soc = await this._readNumber([`evcs.${i}.vehicleSoc`, `evcs.${i}.vehicleSocPct`, `evcs.${i}.socPct`], null);
631
+ if (finiteNumber(soc)) evVehicleSocPct = evVehicleSocPct === null ? soc : Math.min(evVehicleSocPct, soc);
632
+ }
598
633
  }
599
- const connectedCount = await this._readNumber(['chargingManagement.control.connectedCount', 'evcs.connectedCount'], null);
600
- if (finiteNumber(connectedCount) && connectedCount > 0) evConnectedCount = Math.max(evConnectedCount, Math.round(connectedCount));
601
- const evTargetSocPct = await this._readNumber(['settings.aiAdvisorEvTargetSocPct', 'chargingManagement.targetSocPct', 'evcs.1.targetSoc', 'evcs.1.targetSocPct'], num(aiCfg.evTargetSocPct ?? aiCfg.defaultEvTargetSocPct, 80));
602
- const evBatteryCapacityKwh = num(aiCfg.evBatteryCapacityKwh, 60);
603
- const evReadyBy = await this._readString(['settings.aiAdvisorEvReadyBy', 'chargingManagement.readyBy', 'evcs.1.readyBy', 'evcs.1.departureTime'], String(aiCfg.evReadyBy || aiCfg.evDepartureTime || '07:00'));
604
- const evMinutesUntilReady = minutesUntilClock(evReadyBy, new Date());
605
- const evEnergyNeededKwh = (finiteNumber(evVehicleSocPct) && finiteNumber(evTargetSocPct) && finiteNumber(evBatteryCapacityKwh))
634
+ const connectedCount = evcsAvailable ? await this._readNumber(['chargingManagement.control.connectedCount', 'evcs.connectedCount'], null) : null;
635
+ if (evcsAvailable && finiteNumber(connectedCount) && connectedCount > 0) evConnectedCount = Math.max(evConnectedCount, Math.round(connectedCount));
636
+ const evTargetSocPct = evcsAvailable ? await this._readNumber(['settings.aiAdvisorEvTargetSocPct', 'chargingManagement.targetSocPct', 'evcs.1.targetSoc', 'evcs.1.targetSocPct'], num(aiCfg.evTargetSocPct ?? aiCfg.defaultEvTargetSocPct, 80)) : null;
637
+ const evBatteryCapacityKwh = evcsAvailable ? num(aiCfg.evBatteryCapacityKwh, 60) : null;
638
+ const evReadyBy = evcsAvailable ? await this._readString(['settings.aiAdvisorEvReadyBy', 'chargingManagement.readyBy', 'evcs.1.readyBy', 'evcs.1.departureTime'], String(aiCfg.evReadyBy || aiCfg.evDepartureTime || '07:00')) : '';
639
+ const evMinutesUntilReady = evcsAvailable ? minutesUntilClock(evReadyBy, new Date()) : null;
640
+ const evEnergyNeededKwh = (evcsAvailable && finiteNumber(evVehicleSocPct) && finiteNumber(evTargetSocPct) && finiteNumber(evBatteryCapacityKwh))
606
641
  ? Math.max(0, (evBatteryCapacityKwh * (Math.min(100, evTargetSocPct) - Math.max(0, evVehicleSocPct))) / 100)
607
642
  : null;
608
643
 
@@ -645,7 +680,7 @@ class AiAdvisorModule extends BaseModule {
645
680
  const peakStatusLower = String(peakStatus || '').toLowerCase();
646
681
  const peakConfigured = isPeakShavingConfigured(this.adapter && this.adapter.config)
647
682
  || (finiteNumber(peakLimitW) && peakLimitW > 0 && !['disabled', 'off', 'inactive', 'aus'].includes(peakStatusLower));
648
- const evGoals = await this._readEvGoals();
683
+ const evGoals = evcsAvailable ? await this._readEvGoals(evcsAvailable) : [];
649
684
 
650
685
  return {
651
686
  ts: Date.now(),
@@ -663,7 +698,9 @@ class AiAdvisorModule extends BaseModule {
663
698
  storageSocPct: finiteNumber(storageSocPct) ? storageSocPct : null,
664
699
  storageChargeW: Math.max(0, num(storageChargeW, 0)),
665
700
  storageDischargeW: Math.max(0, num(storageDischargeW, 0)),
666
- evcsUsedW: Math.max(0, num(evcsUsedW, 0)),
701
+ evcsAvailable,
702
+ evcsCount,
703
+ evcsUsedW: evcsAvailable ? Math.max(0, num(evcsUsedW, 0)) : 0,
667
704
  thermalUsedW: Math.max(0, num(thermalUsedW, 0)),
668
705
  heatingRodUsedW: Math.max(0, num(heatingRodUsedW, 0)),
669
706
  houseLoadW: Math.max(0, num(houseLoadW, 0)),
@@ -762,7 +799,7 @@ class AiAdvisorModule extends BaseModule {
762
799
  if (cfg.anomalyDetectionEnabled) {
763
800
  if (quietActive && unexplainedW >= cfg.nightBaseLoadW && Math.max(0, Number(s.evcsUsedW) || 0) < 200) {
764
801
  s.anomalyDetected = true;
765
- s.anomalyText = `Ungewöhnliche Grundlast im Ruhefenster: etwa ${formatKw(unexplainedW)} ohne erkennbare Wallbox-/Thermiklast.`;
802
+ s.anomalyText = s.evcsAvailable ? `Ungewöhnliche Grundlast im Ruhefenster: etwa ${formatKw(unexplainedW)} ohne erkennbare Wallbox-/Thermiklast.` : `Ungewöhnliche Grundlast im Ruhefenster: etwa ${formatKw(unexplainedW)} ohne erkennbare Thermik-/Heizstablast.`;
766
803
  } else if (unexplainedW >= cfg.anomalyHighLoadW) {
767
804
  s.anomalyDetected = true;
768
805
  s.anomalyText = `Ungewöhnlich hoher Gebäudeverbrauch: etwa ${formatKw(unexplainedW)} nicht durch bekannte flexible Verbraucher erklärt.`;
@@ -833,19 +870,21 @@ class AiAdvisorModule extends BaseModule {
833
870
  const currentCheap = !!(s.negativeActive || s.gridImportPreferred || tariffState.includes('günstig') || tariffState.includes('guenstig') || tariffState.includes('cheap'));
834
871
  const currentExpensive = !!(tariffState.includes('teuer') || tariffState.includes('expensive'));
835
872
  const surplusW = Math.max(Number(s.gridExportW) || 0, Number(s.pvBudgetW) || 0);
873
+ const hasEvcs = !!s.evcsAvailable && (Number(s.evcsCount) > 0 || Number(s.evConnectedCount) > 0 || Number(s.evcsUsedW) > 100);
874
+ const surplusTargets = hasEvcs ? 'Wallbox, Warmwasser oder andere flexible Verbraucher' : 'Warmwasser, Heizstab oder andere flexible Verbraucher';
836
875
  const peakLimit = finiteNumber(s.gridConnectionLimitW) && s.gridConnectionLimitW > 0 ? s.gridConnectionLimitW : (finiteNumber(s.peakLimitW) && s.peakLimitW > 0 ? s.peakLimitW : s.gridImportLimitEffectiveW);
837
876
  const peakUsagePct = peakLimit ? (s.gridImportW / peakLimit * 100) : 0;
838
- if (peakLimit && peakUsagePct >= (cfg.peakNearLimitPct || 90)) add('jetzt', 'Peak-Schutz', `Netzbezug bei ${formatPct(peakUsagePct)}: flexible Lasten nach Priorität reduzieren (${priorityText(cfg.priorities)}).`, 95, 'peak');
839
- if (surplusW >= cfg.pvSurplusThresholdW) add('jetzt', 'PV-Überschuss nutzen', `${formatKw(surplusW)} Überschuss in Wallbox, Warmwasser oder andere flexible Verbraucher legen.`, 86, 'pv');
877
+ if (peakLimit && peakUsagePct >= (cfg.peakNearLimitPct || 90)) add('jetzt', 'Peak-Schutz', `Netzbezug bei ${formatPct(peakUsagePct)}: flexible Lasten nach Priorität reduzieren (${priorityText(cfg.priorities, { hasEvcs })}).`, 95, 'peak');
878
+ if (surplusW >= cfg.pvSurplusThresholdW) add('jetzt', 'PV-Überschuss nutzen', `${formatKw(surplusW)} Überschuss in ${surplusTargets} legen.`, 86, 'pv');
840
879
  if (currentCheap) add('jetzt', 'Günstigen Tarif nutzen', `Preisfenster nutzen${finiteNumber(s.priceNow) ? ` (${formatPrice(s.priceNow)})` : ''}, solange Peak-Reserve bleibt.`, 84, 'tariff');
841
- else if (currentExpensive) add('jetzt vermeiden', 'Teures Tarif-/Lastfenster', 'EV-Laden und Heizstab möglichst verschieben; Speicherreserve nur gezielt nutzen.', 80, 'tariff');
880
+ else if (currentExpensive) add('jetzt vermeiden', 'Teures Tarif-/Lastfenster', hasEvcs ? 'EV-Laden und Heizstab möglichst verschieben; Speicherreserve nur gezielt nutzen.' : 'Heizstab und andere flexible Lasten möglichst verschieben; Speicherreserve nur gezielt nutzen.', 80, 'tariff');
842
881
  if (s.nextCheapFrom) add(shortIsoWindow(s.nextCheapFrom, s.nextCheapTo) || 'nächstes Tarif-Fenster', 'Nächstes günstiges Zeitfenster', 'Planbare Lasten in dieses Fenster verschieben.', 68, 'tariff');
843
882
  if (s.pvForecastUsable && (s.pvKwh24 > 0 || s.pvPeak24W > 0)) add('Sonnenfenster', 'PV-Prognose einplanen', `${formatKwh(s.pvKwh24)} in 24h erwartet${s.pvPeak24W > 0 ? `, Peak ${formatKw(s.pvPeak24W)}` : ''}. Speicher-Headroom und flexible Lasten darauf abstimmen.`, 70, 'forecast');
844
- if (s.evConnectedCount > 0) {
883
+ if (hasEvcs && s.evConnectedCount > 0) {
845
884
  if (finiteNumber(s.evEnergyNeededKwh) && s.evEnergyNeededKwh > 1) add(`bis ${s.evReadyBy || cfg.evReadyBy}`, 'EV-Ziel erreichen', `${formatKwh(s.evEnergyNeededKwh)} bis Ziel-SoC ${formatPct(s.evTargetSocPct || cfg.evTargetSocPct)} nachladen; PV-/Tariffenster bevorzugen.`, s.evMinutesUntilReady !== null && s.evMinutesUntilReady < 180 ? 90 : 74, 'evcs');
846
885
  else add(`bis ${s.evReadyBy || cfg.evReadyBy}`, 'EV-Komfort prüfen', 'Fahrzeug ist verbunden; Ziel-SoC/Abfahrtszeit prüfen, damit PV und Tarif sauber geplant werden können.', 52, 'evcs');
847
886
  }
848
- const activeGoals = (Array.isArray(s.evGoals) ? s.evGoals : []).filter((g) => g && (g.goalEnabled || g.goalActive));
887
+ const activeGoals = hasEvcs ? (Array.isArray(s.evGoals) ? s.evGoals : []).filter((g) => g && (g.goalEnabled || g.goalActive)) : [];
849
888
  if (activeGoals.length) {
850
889
  const next = activeGoals.slice().sort((a, b) => (Number(a.goalFinishTs || 0) || Infinity) - (Number(b.goalFinishTs || 0) || Infinity))[0];
851
890
  add(tsToShortWindow(next.goalFinishTs) || 'EV-Ziel', 'EV-Zielladen absichern', `${next.label}: Ziel ${next.goalTargetSocPct !== null ? `${round(next.goalTargetSocPct, 0)} %` : 'gesetzt'}${next.goalFinishTs ? ` bis ${formatClockMs(next.goalFinishTs)}` : ''}.`, 82, 'evcs');
@@ -858,7 +897,7 @@ class AiAdvisorModule extends BaseModule {
858
897
  }
859
898
  if (cfg.seasonLogicEnabled) {
860
899
  if (s.season === 'winter') add('laufend', 'Winterstrategie', 'Reserve höher gewichten, weil PV-Fenster kürzer und Wärmelasten relevanter sind.', 54, 'storage');
861
- if (s.season === 'summer') add('tagsüber', 'Sommerstrategie', 'PV-Headroom und Eigenverbrauch hoch gewichten; Abendspitzen durch EV/Kühlung vermeiden.', 54, 'pv');
900
+ if (s.season === 'summer') add('tagsüber', 'Sommerstrategie', hasEvcs ? 'PV-Headroom und Eigenverbrauch hoch gewichten; Abendspitzen durch EV/Kühlung vermeiden.' : 'PV-Headroom und Eigenverbrauch hoch gewichten; Abendspitzen durch Kühlung/Heizstab vermeiden.', 54, 'pv');
862
901
  }
863
902
  if (s.peakRiskWindow) add(s.peakRiskWindow, 'Gelerntes Peak-Fenster entschärfen', 'Große flexible Lasten nicht gleichzeitig starten.', 74, 'learning');
864
903
  if (s.anomalyDetected) add('prüfen', 'Anomalie prüfen', s.anomalyText, 88, 'anomaly');
@@ -900,7 +939,12 @@ class AiAdvisorModule extends BaseModule {
900
939
  const currentExpensive = !!(tariffState.includes('teuer') || tariffState.includes('expensive') || (finiteNumber(s.priceNow) && finiteNumber(s.priceAvg) && s.priceNow >= (s.priceAvg + cfg.expensivePriceMarginEurKwh)));
901
940
  const hasStorage = s.storageSocPct !== null;
902
941
  const storageEnough = !hasStorage || s.storageSocPct >= cfg.minSocForDischargePct;
903
- const hasFlexibleLoad = (s.evcsUsedW > 100 || s.thermalUsedW > 100 || s.heatingRodUsedW > 100) || !!(this.adapter && this.adapter.config && (this.adapter.config.enableChargingManagement || this.adapter.config.enableThermalControl || this.adapter.config.enableHeatingRodControl));
942
+ const hasEvcs = !!s.evcsAvailable && (Number(s.evcsCount) > 0 || Number(s.evConnectedCount) > 0 || Number(s.evcsUsedW) > 100);
943
+ const evLoadW = hasEvcs ? Math.max(0, Number(s.evcsUsedW) || 0) : 0;
944
+ const hasFlexibleLoad = (evLoadW > 100 || s.thermalUsedW > 100 || s.heatingRodUsedW > 100) || !!(this.adapter && this.adapter.config && ((hasEvcs && this.adapter.config.enableChargingManagement) || this.adapter.config.enableThermalControl || this.adapter.config.enableHeatingRodControl));
945
+ const flexibleLoadLabel = evcsPhrase(hasEvcs, true);
946
+ const flexibleConsumerLabel = evcsPhrase(hasEvcs, false);
947
+ const pvSurplusTargets = hasEvcs ? 'Wallbox, Warmwasser oder andere flexible Verbraucher' : 'Warmwasser, Heizstab oder andere flexible Verbraucher';
904
948
  const configuredGridLimitW = finiteNumber(s.gridConnectionLimitW) && s.gridConnectionLimitW > 0 ? s.gridConnectionLimitW : null;
905
949
  const effectiveGridLimitW = finiteNumber(s.peakLimitW) && s.peakLimitW > 0 ? s.peakLimitW : (finiteNumber(s.gridImportLimitEffectiveW) && s.gridImportLimitEffectiveW > 0 ? s.gridImportLimitEffectiveW : null);
906
950
  const peakReferenceLimitW = configuredGridLimitW || effectiveGridLimitW;
@@ -919,7 +963,7 @@ class AiAdvisorModule extends BaseModule {
919
963
  id: 'peak-window-protect', category: 'peak', severity: s.peakOverW > 0 ? 'critical' : 'warning', priority: 98, icon: '⚡',
920
964
  title: s.hlzfActive ? 'Hochlastzeitfenster / Lastspitze aktiv' : 'Lastspitzenkappung aktiv',
921
965
  text: s.peakOverW > 0 ? `Aktuell liegt der Netzbezug etwa ${formatKw(s.peakOverW)} über dem Limit${pctText}. Lastspitzenkappung ist aktiv.` : `Der Netzbezug wird aktuell durch ${s.hlzfActive ? 'HLZF/§19' : 'Lastspitzenkappung'} begrenzt${pctText || (finiteNumber(s.peakLimitW) ? ` (Limit ${formatKw(s.peakLimitW)})` : '')}.`,
922
- action: `EV-Laden, Heizstab und andere flexible Lasten nach Priorität pausieren/reduzieren (${priorityText(cfg.priorities)}), bis der Netzanschluss wieder unter der Grenze liegt.`,
966
+ action: `${flexibleLoadLabel} nach Priorität pausieren/reduzieren (${priorityText(cfg.priorities, { hasEvcs })}), bis der Netzanschluss wieder unter der Grenze liegt.`,
923
967
  window: 'jetzt', impact: 'Leistungspreis / Netzanschluss schützen', confidence: 92,
924
968
  });
925
969
  } else if (peakNearLimit) {
@@ -929,7 +973,7 @@ class AiAdvisorModule extends BaseModule {
929
973
  id: 'peak-near-grid-connection-limit', category: 'peak', severity: peakCriticalLimit ? 'critical' : 'warning', priority: peakCriticalLimit ? 97 : 92, icon: peakCriticalLimit ? '🛑' : '🚧',
930
974
  title: peakCriticalLimit ? 'Netzanschluss am Limit' : `Netzanschluss zu ${formatPct(cfg.peakNearLimitPct)} ausgelastet`,
931
975
  text: `Aktuell werden ${formatKw(s.gridImportW)} von ${formatKw(peakReferenceLimitW)} genutzt (${formatPct(peakUsagePct)}). ${warnText} ${peakReadinessText}`.replace(/\s+/g, ' ').trim(),
932
- action: s.peakConfigured ? `Jetzt optimieren: flexible Lasten nach Priorität reduzieren oder verschieben (${priorityText(cfg.priorities)})${hasStorage && storageEnough ? ', Speicherentladung als Stütze prüfen' : ''}. Es bleiben nur etwa ${formatKw(remainingW)} Reserve bis zum Netzanschlusslimit.` : `Peak-Shaving im Installer/App-Center prüfen. Bis dahin flexible Lasten manuell reduzieren oder verschieben${hasStorage && storageEnough ? ' und Speicherstützung prüfen' : ''}. Es bleiben nur etwa ${formatKw(remainingW)} Reserve.`,
976
+ action: s.peakConfigured ? `Jetzt optimieren: flexible Lasten nach Priorität reduzieren oder verschieben (${priorityText(cfg.priorities, { hasEvcs })})${hasStorage && storageEnough ? ', Speicherentladung als Stütze prüfen' : ''}. Es bleiben nur etwa ${formatKw(remainingW)} Reserve bis zum Netzanschlusslimit.` : `Peak-Shaving im Installer/App-Center prüfen. Bis dahin flexible Lasten manuell reduzieren oder verschieben${hasStorage && storageEnough ? ' und Speicherstützung prüfen' : ''}. Es bleiben nur etwa ${formatKw(remainingW)} Reserve.`,
933
977
  window: 'jetzt', impact: 'Lastspitze vermeiden', confidence: s.peakConfigured ? 90 : 82,
934
978
  });
935
979
  }
@@ -938,8 +982,8 @@ class AiAdvisorModule extends BaseModule {
938
982
  this._pushSuggestion(out, { id: 'ai-day-plan', category: 'plan', severity: 'info', priority: (cfg.optimizationMode === 'comfort' ? 82 : 76), icon: '🗓️', title: 'Tagesfahrplan erstellt', text: s.dayPlan.text, action: 'Planbare Verbraucher anhand dieser Reihenfolge einplanen; der Berater schaltet weiterhin nichts automatisch.', window: 'heute', impact: 'Vorausschauende Planung', confidence: 76 });
939
983
  }
940
984
 
941
- const activeEvGoals = (Array.isArray(s.evGoals) ? s.evGoals : []).filter((g) => g && (g.goalEnabled || g.goalActive));
942
- if (cfg.evGoalPlanningEnabled && (activeEvGoals.length || (s.evConnectedCount > 0 && finiteNumber(s.evEnergyNeededKwh)))) {
985
+ const activeEvGoals = hasEvcs ? (Array.isArray(s.evGoals) ? s.evGoals : []).filter((g) => g && (g.goalEnabled || g.goalActive)) : [];
986
+ if (hasEvcs && cfg.evGoalPlanningEnabled && (activeEvGoals.length || (s.evConnectedCount > 0 && finiteNumber(s.evEnergyNeededKwh)))) {
943
987
  const urgent = activeEvGoals.length ? activeEvGoals.slice().sort((a, b) => (finiteNumber(a.goalRemainingMin) ? a.goalRemainingMin : 999999) - (finiteNumber(b.goalRemainingMin) ? b.goalRemainingMin : 999999))[0] : null;
944
988
  const remaining = urgent && finiteNumber(urgent.goalRemainingMin) ? urgent.goalRemainingMin : s.evMinutesUntilReady;
945
989
  const shortfall = urgent && finiteNumber(urgent.goalShortfallW) ? Math.max(0, urgent.goalShortfallW) : 0;
@@ -955,18 +999,18 @@ class AiAdvisorModule extends BaseModule {
955
999
  if (s.weatherEnabled) {
956
1000
  const rainyTomorrow = (finiteNumber(s.weatherTomorrowPrecipPct) && s.weatherTomorrowPrecipPct >= cfg.weatherRainRiskPct) || textContainsAny(`${s.weatherTomorrowText || ''} ${s.weatherText || ''}`, ['regen', 'schauer', 'gewitter', 'schnee', 'bedeckt']);
957
1001
  const sunnyTomorrow = !rainyTomorrow && (textContainsAny(`${s.weatherTomorrowText || ''} ${s.weatherText || ''}`, ['sonnig', 'klar', 'heiter']) || (finiteNumber(s.weatherTomorrowPrecipPct) && s.weatherTomorrowPrecipPct <= 25));
958
- if (cfg.storageStrategyEnabled && rainyTomorrow && hasStorage) this._pushSuggestion(out, { id: 'weather-storage-reserve', category: 'weather', severity: s.storageSocPct < cfg.lowSocPct ? 'warning' : 'info', priority: s.storageSocPct < cfg.lowSocPct ? 82 : 68, icon: '🌧️', title: 'Speicherstrategie nach Wetter', text: `Wetter: ${s.weatherSummary}. Für morgen ist ein schwächeres PV-Fenster möglich.`, action: 'Speicherreserve nicht unnötig leeren; EV/Warmwasser eher in sichere Tarif- oder PV-Fenster legen.', window: 'heute / morgen', impact: 'Reserve & Autarkie', confidence: 75 });
1002
+ if (cfg.storageStrategyEnabled && rainyTomorrow && hasStorage) this._pushSuggestion(out, { id: 'weather-storage-reserve', category: 'weather', severity: s.storageSocPct < cfg.lowSocPct ? 'warning' : 'info', priority: s.storageSocPct < cfg.lowSocPct ? 82 : 68, icon: '🌧️', title: 'Speicherstrategie nach Wetter', text: `Wetter: ${s.weatherSummary}. Für morgen ist ein schwächeres PV-Fenster möglich.`, action: hasEvcs ? 'Speicherreserve nicht unnötig leeren; EV/Warmwasser eher in sichere Tarif- oder PV-Fenster legen.' : 'Speicherreserve nicht unnötig leeren; Warmwasser/Heizstab eher in sichere Tarif- oder PV-Fenster legen.', window: 'heute / morgen', impact: 'Reserve & Autarkie', confidence: 75 });
959
1003
  if (cfg.storageStrategyEnabled && sunnyTomorrow && hasStorage) this._pushSuggestion(out, { id: 'weather-pv-headroom', category: 'weather', severity: 'success', priority: 64, icon: '☀️', title: 'PV-Headroom vorbereiten', text: `Wetter: ${s.weatherSummary}. Gutes PV-Fenster wahrscheinlich.`, action: 'Speicher nicht unnötig per Netz füllen; Platz für PV freihalten und flexible Lasten in die Sonne legen.', window: 'morgen', impact: 'Eigenverbrauch erhöhen', confidence: 72 });
960
1004
  if (finiteNumber(s.weatherTomorrowMinC) && s.weatherTomorrowMinC <= 3 && hasFlexibleLoad) this._pushSuggestion(out, { id: 'weather-cold-thermal-plan', category: 'weather', severity: 'info', priority: 60, icon: '❄️', title: 'Kalte Nacht einplanen', text: `Die Prognose meldet bis ${formatTemp(s.weatherTomorrowMinC)}. Wärmelasten können später teurer oder peak-relevant werden.`, action: 'Warmwasser, Heizstab oder Wärmepumpe bevorzugt in günstige Tarif- oder PV-Fenster legen, ohne das Peak-Limit zu reißen.', window: 'nächste Nacht', impact: 'Komfort und Peak optimieren', confidence: 68 });
961
1005
  }
962
1006
 
963
1007
  if (cfg.seasonLogicEnabled) {
964
- if (s.season === 'winter' && hasStorage) this._pushSuggestion(out, { id: 'season-winter-storage', category: 'storage', severity: 'info', priority: 55, icon: '🧊', title: 'Winterstrategie', text: 'Kürzere PV-Fenster und höhere Wärmelasten: Speicherreserve und Komfortziele höher gewichten.', action: 'Abends nicht zu aggressiv entladen und Warmwasser/EV möglichst in sichere Tarif- oder PV-Fenster legen.', window: 'laufend', impact: 'Reserve & Komfort', confidence: 66 });
965
- if (s.season === 'summer') this._pushSuggestion(out, { id: 'season-summer-pv', category: 'pv', severity: 'success', priority: 54, icon: '🌞', title: 'Sommerstrategie', text: 'Lange PV-Fenster: Eigenverbrauch und Speicher-Headroom sind besonders wertvoll.', action: 'Große Verbraucher tagsüber staffeln und Abendspitzen durch EV/Kühlung vermeiden.', window: 'tagsüber', impact: 'Eigenverbrauch & Peak', confidence: 66 });
1008
+ if (s.season === 'winter' && hasStorage) this._pushSuggestion(out, { id: 'season-winter-storage', category: 'storage', severity: 'info', priority: 55, icon: '🧊', title: 'Winterstrategie', text: 'Kürzere PV-Fenster und höhere Wärmelasten: Speicherreserve und Komfortziele höher gewichten.', action: hasEvcs ? 'Abends nicht zu aggressiv entladen und Warmwasser/EV möglichst in sichere Tarif- oder PV-Fenster legen.' : 'Abends nicht zu aggressiv entladen und Warmwasser/Heizstab möglichst in sichere Tarif- oder PV-Fenster legen.', window: 'laufend', impact: 'Reserve & Komfort', confidence: 66 });
1009
+ if (s.season === 'summer') this._pushSuggestion(out, { id: 'season-summer-pv', category: 'pv', severity: 'success', priority: 54, icon: '🌞', title: 'Sommerstrategie', text: 'Lange PV-Fenster: Eigenverbrauch und Speicher-Headroom sind besonders wertvoll.', action: hasEvcs ? 'Große Verbraucher tagsüber staffeln und Abendspitzen durch EV/Kühlung vermeiden.' : 'Große Verbraucher tagsüber staffeln und Abendspitzen durch Kühlung/Heizstab vermeiden.', window: 'tagsüber', impact: 'Eigenverbrauch & Peak', confidence: 66 });
966
1010
  }
967
1011
 
968
1012
  if (s.anomalyDetected) this._pushSuggestion(out, { id: 'anomaly-detected', category: 'anomaly', severity: 'warning', priority: 87, icon: '🔎', title: 'Ungewöhnlichen Verbrauch prüfen', text: s.anomalyText, action: 'Geräteliste/SmartHome prüfen und nicht benötigte Verbraucher ausschalten oder in ein passendes Fenster verschieben.', window: 'jetzt prüfen', impact: 'Fehlverbrauch vermeiden', confidence: 74 });
969
- if (s.peakRiskWindow && !peakNearLimit) this._pushSuggestion(out, { id: 'peak-learning-risk', category: 'learning', severity: 'info', priority: 68, icon: '📈', title: 'Gelernte Lastspitze beachten', text: `Die Lastspitzen-Lernfunktion markiert ${s.peakRiskWindow} als typisches Peak-Risiko.`, action: `Flexible Verbraucher vorsorglich staffeln: ${priorityText(cfg.priorities)}.`, window: s.peakRiskWindow, impact: 'Peak vermeiden', confidence: 70 });
1013
+ if (s.peakRiskWindow && !peakNearLimit) this._pushSuggestion(out, { id: 'peak-learning-risk', category: 'learning', severity: 'info', priority: 68, icon: '📈', title: 'Gelernte Lastspitze beachten', text: `Die Lastspitzen-Lernfunktion markiert ${s.peakRiskWindow} als typisches Peak-Risiko.`, action: `Flexible Verbraucher vorsorglich staffeln: ${priorityText(cfg.priorities, { hasEvcs })}.`, window: s.peakRiskWindow, impact: 'Peak vermeiden', confidence: 70 });
970
1014
  if (cfg.forecastQualityEnabled && finiteNumber(s.forecastQualityPct) && s.forecastQualityPct < cfg.forecastQualityWarnPct) this._pushSuggestion(out, { id: 'forecast-quality-low', category: 'forecast', severity: 'info', priority: 57, icon: '🎯', title: 'Prognosequalität vorsichtig bewerten', text: `${s.forecastQualityText} Empfehlungen werden konservativer gewichtet.`, action: 'Bei niedriger Prognosequalität Speicherreserve erhöhen und harte Lastverschiebungen vermeiden.', window: 'laufend', impact: 'Risiko reduzieren', confidence: 70 });
971
1015
 
972
1016
  if (cfg.optimizationMode === 'co2' && finiteNumber(s.co2IntensityGPerKwh)) {
@@ -974,18 +1018,18 @@ class AiAdvisorModule extends BaseModule {
974
1018
  const dirty = s.co2IntensityGPerKwh >= cfg.co2HighGPerKwh;
975
1019
  if (clean || dirty) this._pushSuggestion(out, { id: clean ? 'co2-clean-window' : 'co2-high-window', category: 'co2', severity: clean ? 'success' : 'info', priority: clean ? 75 : 65, icon: clean ? '🌱' : '🌫️', title: clean ? 'CO₂-günstiges Zeitfenster' : 'CO₂-intensive Netzphase', text: `Aktuelle CO₂-Intensität: ${Math.round(s.co2IntensityGPerKwh)} g/kWh.`, action: clean ? 'Flexible Lasten bevorzugen, solange Peak-Reserve bleibt.' : 'Nicht dringende Netzlasten verschieben; PV/Speicher bevorzugen.', window: 'jetzt', impact: 'CO₂-Optimierung', confidence: 72 });
976
1020
  }
977
- if (cfg.optimizationMode === 'autarky' && s.gridExportW >= cfg.pvSurplusThresholdW) this._pushSuggestion(out, { id: 'autarky-mode-surplus', category: 'pv', severity: 'success', priority: 75, icon: '🏡', title: 'Autarkie-Modus: Überschuss nutzen', text: `${formatKw(s.gridExportW)} Einspeisung erkannt.`, action: 'Eigenverbrauch erhöhen: Wallbox, Warmwasser oder steuerbare Lasten staffeln.', window: 'jetzt', impact: 'Autarkie erhöhen', confidence: 78 });
978
- if (cfg.optimizationMode === 'peak' && peakReferenceLimitW) this._pushSuggestion(out, { id: 'peak-mode-reserve', category: 'peak', severity: peakNearLimit ? 'warning' : 'info', priority: peakNearLimit ? 90 : 56, icon: '🛡️', title: 'Peak-Schutz-Modus', text: `Netzanschluss-Auslastung aktuell ${formatPct(peakUsagePct || 0)}.`, action: `Lasten konsequent nach Priorität staffeln: ${priorityText(cfg.priorities)}.`, window: 'laufend', impact: 'Lastspitzen vermeiden', confidence: 72 });
1021
+ if (cfg.optimizationMode === 'autarky' && s.gridExportW >= cfg.pvSurplusThresholdW) this._pushSuggestion(out, { id: 'autarky-mode-surplus', category: 'pv', severity: 'success', priority: 75, icon: '🏡', title: 'Autarkie-Modus: Überschuss nutzen', text: `${formatKw(s.gridExportW)} Einspeisung erkannt.`, action: `Eigenverbrauch erhöhen: ${pvSurplusTargets} staffeln.`, window: 'jetzt', impact: 'Autarkie erhöhen', confidence: 78 });
1022
+ if (cfg.optimizationMode === 'peak' && peakReferenceLimitW) this._pushSuggestion(out, { id: 'peak-mode-reserve', category: 'peak', severity: peakNearLimit ? 'warning' : 'info', priority: peakNearLimit ? 90 : 56, icon: '🛡️', title: 'Peak-Schutz-Modus', text: `Netzanschluss-Auslastung aktuell ${formatPct(peakUsagePct || 0)}.`, action: `Lasten konsequent nach Priorität staffeln: ${priorityText(cfg.priorities, { hasEvcs })}.`, window: 'laufend', impact: 'Lastspitzen vermeiden', confidence: 72 });
979
1023
 
980
1024
  if (s.negativeActive || s.gridImportPreferred) this._pushSuggestion(out, { id: 'negative-price-window', category: 'tariff', severity: 'success', priority: 88, icon: '€', title: s.negativeActive ? 'Negativpreis-Fenster nutzen' : 'Günstiges Netzladefenster', text: s.negativeActive ? 'Der aktuelle Strompreis ist negativ bzw. sehr günstig.' : 'Der Tarif bevorzugt aktuell Netzbezug.', action: `Flexible Lasten jetzt nutzen${hasStorage ? ', Speicherladung prüfen' : ''}, solange Peak-Reserve bleibt.`, window: 'jetzt', impact: 'Kosten senken', confidence: 86 });
981
- else if (currentExpensive && hasFlexibleLoad) this._pushSuggestion(out, { id: 'expensive-price-avoid-loads', category: 'tariff', severity: 'warning', priority: 74, icon: '💸', title: 'Teures Tarif-Fenster', text: finiteNumber(s.priceNow) ? `Aktueller Preis ${formatPrice(s.priceNow)} liegt über dem Vergleichswert.` : 'Der aktuelle Tarifzustand ist teuer.', action: 'EV-Laden, Heizstab und andere flexible Verbraucher verschieben oder reduzieren, wenn Komfortziele es erlauben.', window: 'jetzt', impact: 'Kosten vermeiden', confidence: 78 });
982
- if (s.nextCheapFrom && !currentCheap) this._pushSuggestion(out, { id: 'next-cheap-window', category: 'tariff', severity: 'info', priority: 62, icon: '⏱️', title: 'Nächstes günstiges Zeitfenster', text: `Günstiges Tarif-Fenster: ${shortIsoWindow(s.nextCheapFrom, s.nextCheapTo) || s.nextCheapFrom}.`, action: 'Planbare Lasten bis dahin zurückstellen, sofern Komfort und EV-Zielzeiten passen.', window: shortIsoWindow(s.nextCheapFrom, s.nextCheapTo), impact: 'Kosten optimieren', confidence: 72 });
983
- if (s.gridExportW >= cfg.pvSurplusThresholdW) this._pushSuggestion(out, { id: 'pv-surplus-use', category: 'pv', severity: 'success', priority: 82, icon: '☀️', title: 'PV-Überschuss verfügbar', text: `Aktuell werden etwa ${formatKw(s.gridExportW)} eingespeist.`, action: 'Wallbox, Warmwasser oder andere flexible Verbraucher einschalten bzw. erhöhen, solange kein Peak-Risiko besteht.', window: 'jetzt', impact: 'Eigenverbrauch erhöhen', confidence: 82 });
1025
+ else if (currentExpensive && hasFlexibleLoad) this._pushSuggestion(out, { id: 'expensive-price-avoid-loads', category: 'tariff', severity: 'warning', priority: 74, icon: '💸', title: 'Teures Tarif-Fenster', text: finiteNumber(s.priceNow) ? `Aktueller Preis ${formatPrice(s.priceNow)} liegt über dem Vergleichswert.` : 'Der aktuelle Tarifzustand ist teuer.', action: `${flexibleConsumerLabel} verschieben oder reduzieren, wenn Komfortziele es erlauben.`, window: 'jetzt', impact: 'Kosten vermeiden', confidence: 78 });
1026
+ if (s.nextCheapFrom && !currentCheap) this._pushSuggestion(out, { id: 'next-cheap-window', category: 'tariff', severity: 'info', priority: 62, icon: '⏱️', title: 'Nächstes günstiges Zeitfenster', text: `Günstiges Tarif-Fenster: ${shortIsoWindow(s.nextCheapFrom, s.nextCheapTo) || s.nextCheapFrom}.`, action: hasEvcs ? 'Planbare Lasten bis dahin zurückstellen, sofern Komfort und EV-Zielzeiten passen.' : 'Planbare Lasten bis dahin zurückstellen, sofern Komfortziele passen.', window: shortIsoWindow(s.nextCheapFrom, s.nextCheapTo), impact: 'Kosten optimieren', confidence: 72 });
1027
+ if (s.gridExportW >= cfg.pvSurplusThresholdW) this._pushSuggestion(out, { id: 'pv-surplus-use', category: 'pv', severity: 'success', priority: 82, icon: '☀️', title: 'PV-Überschuss verfügbar', text: `Aktuell werden etwa ${formatKw(s.gridExportW)} eingespeist.`, action: `${pvSurplusTargets} einschalten bzw. erhöhen, solange kein Peak-Risiko besteht.`, window: 'jetzt', impact: 'Eigenverbrauch erhöhen', confidence: 82 });
984
1028
  if (s.pvForecastUsable && (s.pvKwh24 >= cfg.pvForecastMinKwh || s.pvPeak24W >= cfg.pvPeakMinW)) this._pushSuggestion(out, { id: 'pv-forecast-plan', category: 'forecast', severity: 'info', priority: 66, icon: '🔮', title: 'PV-Prognose einplanen', text: `${formatKwh(s.pvKwh24)} PV-Ertrag in den nächsten 24h erwartet, Peak ca. ${formatKw(s.pvPeak24W)}.`, action: hasStorage ? 'Speicher-Headroom für PV freihalten und flexible Lasten in das Sonnenfenster legen.' : 'Flexible Lasten in das Sonnenfenster legen.', window: 'nächste 24h', impact: 'Autarkie erhöhen', confidence: 75 });
985
1029
  if (hasStorage && s.storageSocPct <= cfg.lowSocPct) this._pushSuggestion(out, { id: 'storage-low-reserve', category: 'storage', severity: 'warning', priority: 78, icon: '🔋', title: 'Speicherreserve niedrig', text: `Der Speicher liegt bei ${round(s.storageSocPct, 0)} %.`, action: 'Reservegrenze prüfen; flexible Lasten eher in PV- oder günstige Tariffenster verschieben.', window: 'bis Reserve erholt ist', impact: 'Reserve schützen', confidence: 80 });
986
1030
  if (s.gridImportW >= cfg.highImportThresholdW && !currentCheap && !s.negativeActive && !peakNearLimit && !s.peakActive && !(s.peakOverW > 0)) this._pushSuggestion(out, { id: 'high-grid-import', category: 'grid', severity: 'warning', priority: 70, icon: '📉', title: 'Hoher Netzbezug erkannt', text: `Aktuell werden etwa ${formatKw(s.gridImportW)} aus dem Netz bezogen.`, action: 'Nicht dringende Verbraucher verschieben; bei Speicher prüfen, ob Entladen freigegeben ist.', window: 'jetzt', impact: 'Netzbezug senken', confidence: 72 });
987
1031
  if (s.para14aActive) this._pushSuggestion(out, { id: 'para14a-active', category: 'grid', severity: 'warning', priority: 84, icon: '🚦', title: '§14a-Leistungsbegrenzung aktiv', text: 'Der Netzbetreiber-/EMS-Deckel für steuerbare Verbraucher ist aktiv.', action: 'Komfortverbraucher priorisieren und nicht notwendige Verbraucher verschieben.', window: 'jetzt', impact: 'Netzvorgabe einhalten', confidence: 85 });
988
- if (cfg.comfortHintsEnabled && s.quietActive && (s.evcsUsedW + s.thermalUsedW + s.heatingRodUsedW) > 500 && cfg.optimizationMode !== 'comfort') this._pushSuggestion(out, { id: 'comfort-quiet-hours-flex-load', category: 'comfort', severity: 'info', priority: 63, icon: '🌙', title: 'Ruhezeit: flexible Lasten prüfen', text: `Im Ruhefenster ${s.quietWindow} laufen flexible Verbraucher mit etwa ${formatKw(s.evcsUsedW + s.thermalUsedW + s.heatingRodUsedW)}.`, action: 'Nur laufen lassen, wenn Komfortziel, Abfahrtszeit oder günstiger Tarif wichtiger ist; sonst in PV-/Tariffenster verschieben.', window: 'jetzt', impact: 'Komfort / Geräusch / Peak', confidence: 70 });
1032
+ if (cfg.comfortHintsEnabled && s.quietActive && (evLoadW + s.thermalUsedW + s.heatingRodUsedW) > 500 && cfg.optimizationMode !== 'comfort') this._pushSuggestion(out, { id: 'comfort-quiet-hours-flex-load', category: 'comfort', severity: 'info', priority: 63, icon: '🌙', title: 'Ruhezeit: flexible Lasten prüfen', text: `Im Ruhefenster ${s.quietWindow} laufen flexible Verbraucher mit etwa ${formatKw(evLoadW + s.thermalUsedW + s.heatingRodUsedW)}.`, action: 'Nur laufen lassen, wenn Komfortziel, Abfahrtszeit oder günstiger Tarif wichtiger ist; sonst in PV-/Tariffenster verschieben.', window: 'jetzt', impact: 'Komfort / Geräusch / Peak', confidence: 70 });
989
1033
  if (cfg.includeInstallerHints && !configuredGridLimitW) this._pushSuggestion(out, { id: 'setup-grid-connection-limit', category: 'setup', severity: 'info', priority: 32, icon: '🔌', title: 'Netzanschlussleistung hinterlegen', text: 'Für korrekte Peak-Shaving-Vorwarnungen fehlt die konfigurierte Netzanschlussleistung.', action: 'Im Installer die Netzanschlussleistung eintragen, z. B. 30000 W für einen 30-kW-Anschluss.', window: 'Setup', impact: 'Peak-Beratung verbessern', confidence: 72 });
990
1034
  if (cfg.includeInstallerHints && !s.tariffActive && !finiteNumber(s.priceNow)) this._pushSuggestion(out, { id: 'setup-tariff', category: 'setup', severity: 'info', priority: 30, icon: '🧭', title: 'Dynamischen Tarif anbinden', text: 'Für bessere Zeitvorschläge fehlt aktuell ein frisches Preis-/Tarifsignal.', action: 'Im App-Center Tarife/Preisprognose zuordnen.', window: 'Setup', impact: 'KI-Beratung verbessern', confidence: 70 });
991
1035
  if (cfg.includeInstallerHints && !s.pvForecastUsable) this._pushSuggestion(out, { id: 'setup-pv-forecast', category: 'setup', severity: 'info', priority: 28, icon: '☀️', title: 'PV-Forecast aktivieren', text: 'Für vorausschauende Empfehlungen fehlt eine nutzbare PV-Prognose.', action: 'PV-Forecast im App-Center einrichten, damit Verbraucher zeitlich besser geplant werden können.', window: 'Setup', impact: 'Prognosequalität erhöhen', confidence: 70 });
@@ -1114,7 +1158,7 @@ class AiAdvisorModule extends BaseModule {
1114
1158
  const peakStateText = buildPeakStateText(snapshot, peakReferenceLimitW, peakUsagePct);
1115
1159
  const weatherSummary = buildWeatherSummary(snapshot);
1116
1160
  const dailyPlan = snapshot.dayPlan || { mode: cfg.optimizationMode, modeLabel: optimizationModeLabel(cfg.optimizationMode), items: [], text: '' };
1117
- const evPlanText = (snapshot.evConnectedCount > 0)
1161
+ const evPlanText = (snapshot.evcsAvailable && snapshot.evConnectedCount > 0)
1118
1162
  ? (finiteNumber(snapshot.evEnergyNeededKwh) && snapshot.evEnergyNeededKwh > 1
1119
1163
  ? `${formatKwh(snapshot.evEnergyNeededKwh)} bis ${formatPct(snapshot.evTargetSocPct || cfg.evTargetSocPct)} Ziel-SoC nachladen · bereit bis ${snapshot.evReadyBy || cfg.evReadyBy}.`
1120
1164
  : `Fahrzeug verbunden · Ziel-SoC ${formatPct(snapshot.evTargetSocPct || cfg.evTargetSocPct)} · bereit bis ${snapshot.evReadyBy || cfg.evReadyBy}.`)
package/io-package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "nexowatt-ui",
4
- "version": "0.7.40",
4
+ "version": "0.7.41",
5
5
  "news": {
6
+ "0.7.41": {
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
+ "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
+ },
6
10
  "0.7.39": {
7
11
  "en": "AI Advisor extended with weather-aware recommendations and a corrected peak-shaving early warning: the grid connection warning starts at 90% of the configured connection limit (30 kW -> 27 kW). The advisor now reports whether peak shaving is active, prepared, or not configured and publishes additional peak/weather states.",
8
12
  "de": "KI-Energieberater erweitert: Wetterprognose fließt in Empfehlungen ein und die Peak-Shaving-Vorwarnung greift korrekt ab 90 % der konfigurierten Netzanschlussleistung (30 kW -> 27 kW). Der Berater zeigt jetzt klar, ob Lastspitzenkappung aktiv, vorbereitet oder nicht konfiguriert ist, und veröffentlicht zusätzliche Peak-/Wetter-States."
@@ -1975,8 +1979,12 @@
1975
1979
  }
1976
1980
  },
1977
1981
  "instanceObjects": [],
1978
- "version": "0.7.40",
1982
+ "version": "0.7.41",
1979
1983
  "news": {
1984
+ "0.7.41": {
1985
+ "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
+ "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
+ },
1980
1988
  "0.7.39": {
1981
1989
  "en": "AI Advisor now includes weather-aware recommendations and peak-shaving early warning at 90% of the configured grid connection limit.",
1982
1990
  "de": "KI-Energieberater nutzt jetzt Wetterprognosen und meldet Peak-Shaving-Vorwarnungen ab 90 % der konfigurierten Netzanschlussleistung."
package/main.js CHANGED
@@ -1507,7 +1507,7 @@ class NexoWattVis extends utils.Adapter {
1507
1507
  weatherApiKey: { type: 'string', role: 'text', def: '' },
1508
1508
 
1509
1509
  // EVCS defaults mirrored into runtime settings (written by syncSettingsConfigToStates())
1510
- evcsCount: { type: 'number', role: 'value', def: 1 },
1510
+ evcsCount: { type: 'number', role: 'value', def: 0 },
1511
1511
  evcsMaxPower: { type: 'number', role: 'value.power', def: 11000 },
1512
1512
 
1513
1513
  // Energy-flow presentation toggles
@@ -2991,14 +2991,14 @@ class NexoWattVis extends utils.Adapter {
2991
2991
  }
2992
2992
 
2993
2993
  const native = (simObj && simObj.native && typeof simObj.native === 'object') ? simObj.native : {};
2994
- let evcsCount = Math.max(1, Math.min(200, Math.round(Number(native.chargersCount || native.chargerCount || native.evcsCount || 1))));
2994
+ let evcsCount = Math.max(0, Math.min(200, Math.round(Number(native.chargersCount ?? native.chargerCount ?? native.evcsCount ?? 0) || 0)));
2995
2995
 
2996
2996
  // Prefer runtime state if available (supports dynamic changes in sim adapter)
2997
2997
  try {
2998
2998
  const stCount = await this.getForeignStateAsync(`${inst}.evcs.count`).catch(() => null);
2999
2999
  const n = (stCount && stCount.val !== undefined && stCount.val !== null) ? Number(stCount.val) : NaN;
3000
- if (Number.isFinite(n) && n > 0) {
3001
- evcsCount = Math.max(1, Math.min(200, Math.round(n)));
3000
+ if (Number.isFinite(n) && n >= 0) {
3001
+ evcsCount = Math.max(0, Math.min(200, Math.round(n)));
3002
3002
  }
3003
3003
  } catch (_e) {}
3004
3004
 
@@ -3423,9 +3423,13 @@ class NexoWattVis extends utils.Adapter {
3423
3423
  async syncStorageFarmConfigFromAdmin() {
3424
3424
  try {
3425
3425
  const cfg = this.config || {};
3426
- const enabled = !!cfg.enableStorageFarm;
3426
+ const adminSf = (cfg.storageFarm && typeof cfg.storageFarm === 'object') ? cfg.storageFarm : {};
3427
+ const rowsRaw = Array.isArray(adminSf.storages) ? adminSf.storages : [];
3428
+ const hasConfiguredStorage = rowsRaw.some(r => r && typeof r === 'object' && r.enabled !== false);
3429
+ const enabled = !!cfg.enableStorageFarm && hasConfiguredStorage;
3427
3430
 
3428
- // Master-Enable aus Admin in State spiegeln (damit UI + Runtime konsistent bleiben)
3431
+ // Master-Enable aus Admin in State spiegeln (damit UI + Runtime konsistent bleiben).
3432
+ // Ohne konfigurierte Speicher bleibt die Kunden-Farmansicht unsichtbar.
3429
3433
  try {
3430
3434
  await this.setStateAsync('storageFarm.enabled', { val: enabled, ack: true });
3431
3435
  try { this.updateValue('storageFarm.enabled', enabled, Date.now()); } catch (_e0) {}
@@ -3433,7 +3437,6 @@ class NexoWattVis extends utils.Adapter {
3433
3437
 
3434
3438
  if (!enabled) return;
3435
3439
 
3436
- const adminSf = (cfg.storageFarm && typeof cfg.storageFarm === 'object') ? cfg.storageFarm : {};
3437
3440
  const modeRaw = String(adminSf.mode || 'pool').toLowerCase().trim();
3438
3441
  const mode = (modeRaw === 'groups') ? 'groups' : 'pool';
3439
3442
 
@@ -4950,13 +4953,19 @@ try {
4950
4953
  const cfg = (this.config && this.config.settingsConfig) || {};
4951
4954
  const ratedKw = Number(cfg.evcsMaxPowerKw || 11); // default 11 kW
4952
4955
  const ratedW = Math.round(ratedKw * 1000);
4953
- const evcsCount = Math.max(1, Math.min(50, Math.round(Number(cfg.evcsCount || 1))));
4956
+
4957
+ // Ladepunkte sind optional. Alte Builds hatten implizit 1 Ladepunkt als Default;
4958
+ // im Kunden-Frontend darf eine nicht konfigurierte Wallbox dadurch aber nicht sichtbar werden.
4959
+ const rawList = Array.isArray(cfg.evcsList) ? cfg.evcsList : [];
4960
+ const rawCount = (cfg.evcsCount !== undefined && cfg.evcsCount !== null && String(cfg.evcsCount).trim() !== '')
4961
+ ? Number(cfg.evcsCount)
4962
+ : rawList.length;
4963
+ const evcsCount = Math.max(0, Math.min(50, Math.round(Number.isFinite(rawCount) ? rawCount : 0)));
4954
4964
  this.evcsCount = evcsCount;
4955
4965
  this.log.info(`[NexoWatt UI] Ladepunkte konfiguriert: ${evcsCount}`);
4956
4966
 
4957
4967
 
4958
- // derive evcs list (names) from config; keep it stable and always at least evcsCount entries
4959
- const rawList = Array.isArray(cfg.evcsList) ? cfg.evcsList : [];
4968
+ // derive evcs list (names) from config; keep it stable and only as long as explicitly configured
4960
4969
  const evcsList = [];
4961
4970
  for (let i = 0; i < evcsCount; i++) {
4962
4971
  const row = rawList[i] || {};
@@ -5068,7 +5077,7 @@ evcsList.push({ index: i+1, enabled, priority, name, note, powerId, energyTotalI
5068
5077
  }
5069
5078
 
5070
5079
  async ensureEvcsStates() {
5071
- const count = Number(this.evcsCount || 1) || 1;
5080
+ const count = Math.max(0, Math.round(Number(this.evcsCount || 0) || 0));
5072
5081
 
5073
5082
  await this.setObjectNotExistsAsync('evcs', {
5074
5083
  type: 'channel',
@@ -5533,7 +5542,7 @@ evcsList.push({ index: i+1, enabled, priority, name, note, powerId, energyTotalI
5533
5542
 
5534
5543
  async seedEvcsDayBaseCache() {
5535
5544
  try {
5536
- const count = Number(this.evcsCount || 1) || 1;
5545
+ const count = Math.max(0, Math.round(Number(this.evcsCount || 0) || 0));
5537
5546
  for (let i = 1; i <= count; i++) {
5538
5547
  const kBase = `evcs.${i}._dayBaseKwh`;
5539
5548
  const kDate = `evcs.${i}._dayBaseDate`;
@@ -5582,8 +5591,8 @@ evcsList.push({ index: i+1, enabled, priority, name, note, powerId, energyTotalI
5582
5591
  try {
5583
5592
  const cfg = this.config || {};
5584
5593
  const ns = this.namespace;
5585
- const count = (Number(this.evcsCount) || (cfg && cfg.settingsConfig && Number(cfg.settingsConfig.evcsCount)) || 1);
5586
- const evcsCount = (Number.isFinite(count) && count > 0) ? Math.round(count) : 1;
5594
+ const count = (Number(this.evcsCount) || (cfg && cfg.settingsConfig && Number(cfg.settingsConfig.evcsCount)) || 0);
5595
+ const evcsCount = (Number.isFinite(count) && count > 0) ? Math.round(count) : 0;
5587
5596
 
5588
5597
  // Subscribe to all local EMS states (wildcards are supported by the runtime).
5589
5598
  // This keeps the state cache in sync and prevents UI mode buttons from jumping.
@@ -7347,8 +7356,8 @@ async onReady() {
7347
7356
  const enabledFlag = cfg.enableChargingManagement;
7348
7357
  // UI-States auch dann bereitstellen, wenn das Modul vorübergehend deaktiviert ist.
7349
7358
 
7350
- const count = (Number(this.evcsCount) || Number(cfg?.settingsConfig?.evcsCount) || 1);
7351
- const evcsCount = (Number.isFinite(count) && count > 0) ? Math.round(count) : 1;
7359
+ const count = (Number(this.evcsCount) || Number(cfg?.settingsConfig?.evcsCount) || 0);
7360
+ const evcsCount = (Number.isFinite(count) && count > 0) ? Math.round(count) : 0;
7352
7361
 
7353
7362
  // Subscribe to ALL internal EMS states (wildcards). This is efficient and ensures
7354
7363
  // state changes propagate to the SSE/stateCache.
@@ -13255,29 +13264,51 @@ app.get('/config', (req, res) => {
13255
13264
  // were not persisted yet.
13256
13265
  const cfg = this.config || {};
13257
13266
 
13258
- const inferChargingEnabled = () => {
13259
- const v = cfg.enableChargingManagement;
13260
- if (typeof v === 'boolean') return v;
13267
+ const boolOr = (val, def) => (typeof val === 'boolean' ? val : !!def);
13268
+ const datapoints = (cfg && cfg.datapoints && typeof cfg.datapoints === 'object') ? cfg.datapoints : {};
13269
+ const datapointFlags = Object.fromEntries(Object.entries(datapoints).map(([k, v]) => [k, !!String(v == null ? '' : v).trim()]));
13270
+
13271
+ const evcsMappedFields = [
13272
+ 'powerId', 'energyTotalId', 'energySessionId', 'statusId', 'activeId', 'onlineId',
13273
+ 'setCurrentAId', 'setPowerWId', 'enableWriteId', 'lockWriteId', 'rfidReadId',
13274
+ 'vehicleSocId'
13275
+ ];
13276
+ const rawEvcsRows = Array.isArray(cfg.settingsConfig && cfg.settingsConfig.evcsList) ? cfg.settingsConfig.evcsList : [];
13277
+ const evcsListForConfig = Array.isArray(this.evcsList) ? this.evcsList : rawEvcsRows;
13278
+ const evcsConfiguredCount = rawEvcsRows.filter((row) => {
13279
+ if (!row || row.enabled === false) return false;
13280
+ return evcsMappedFields.some((key) => String(row[key] || '').trim());
13281
+ }).length;
13282
+ // A legacy aggregate datapoint may exist as a default placeholder even on Anlagen ohne Wallbox.
13283
+ // Customer EVCS UI is therefore enabled only when at least one real Ladepunkt row has a mapping/control DP.
13284
+ const evcsAvailable = !!(evcsConfiguredCount > 0);
13285
+ const evcsCountForConfig = evcsAvailable
13286
+ ? Math.max(evcsConfiguredCount, Math.max(0, Math.round(Number(this.evcsCount || 0) || 0)))
13287
+ : 0;
13261
13288
 
13262
- // Upgrade/default behaviour: if the user did not explicitly disable charging,
13263
- // we expose the EMS runtime controls. The embedded module itself will still
13264
- // write setpoints only when controllable datapoints are mapped.
13289
+ const parseJsonArraySafe = (raw) => {
13265
13290
  try {
13266
- const cnt = Number(cfg && cfg.settingsConfig && cfg.settingsConfig.evcsCount);
13267
- if (Number.isFinite(cnt) && cnt > 0) return true;
13268
- const list = Array.isArray(this.evcsList) ? this.evcsList : [];
13269
- if (list && list.length) return true;
13291
+ if (Array.isArray(raw)) return raw;
13292
+ if (raw === undefined || raw === null || raw === '') return [];
13293
+ const parsed = JSON.parse(String(raw));
13294
+ return Array.isArray(parsed) ? parsed : [];
13270
13295
  } catch (_e) {
13271
- // ignore
13296
+ return [];
13272
13297
  }
13273
- return false;
13274
13298
  };
13299
+ const storageRowsFromConfig = Array.isArray(cfg && cfg.storageFarm && cfg.storageFarm.storages) ? cfg.storageFarm.storages : [];
13300
+ // Stale runtime states from older builds must not expose the customer Speicherfarm page.
13301
+ // The page is visible only when the installer configured at least one active storage row.
13302
+ const storageFarmConfigured = storageRowsFromConfig.some((row) => row && row.enabled !== false);
13303
+ const storageFarmAvailable = !!(cfg.enableStorageFarm && storageFarmConfigured);
13275
13304
 
13276
- const boolOr = (val, def) => (typeof val === 'boolean' ? val : !!def);
13305
+ const inferChargingEnabled = () => {
13306
+ const v = cfg.enableChargingManagement;
13307
+ if (typeof v === 'boolean') return v && evcsAvailable;
13308
+ return evcsAvailable;
13309
+ };
13277
13310
 
13278
13311
  const sess = getSession(req);
13279
- const datapoints = (cfg && cfg.datapoints && typeof cfg.datapoints === 'object') ? cfg.datapoints : {};
13280
- const datapointFlags = Object.fromEntries(Object.entries(datapoints).map(([k, v]) => [k, !!String(v == null ? '' : v).trim()]));
13281
13312
 
13282
13313
  res.json({
13283
13314
  units: cfg.units || { power: 'W', energy: 'kWh' },
@@ -13508,33 +13539,35 @@ app.get('/config', (req, res) => {
13508
13539
  return out;
13509
13540
  };
13510
13541
 
13511
- const evcsList = Array.isArray(this.evcsList) ? this.evcsList : [];
13512
- const evcsHasPower = evcsList.some(e => e && String(e.powerId || '').trim());
13513
- const evcsAltMapped = !!String(dps.consumptionEvcs || '').trim();
13514
-
13515
13542
  return {
13516
13543
  core,
13517
13544
  consumers: buildSlots('consumers'),
13518
13545
  producers: buildSlots('producers'),
13519
13546
  meta: {
13520
- evcsAvailable: !!(evcsHasPower || evcsAltMapped)
13547
+ evcsAvailable: evcsAvailable,
13548
+ evcsConfiguredCount: evcsConfiguredCount
13521
13549
  }
13522
13550
  };
13523
13551
  })(),
13524
13552
 
13525
13553
  settingsConfig: {
13526
- evcsCount: (cfg && cfg.settingsConfig && Number(cfg.settingsConfig.evcsCount)) || (this.evcsCount || 1),
13554
+ evcsCount: evcsCountForConfig,
13555
+ evcsConfiguredCount: evcsConfiguredCount,
13556
+ evcsAvailable: evcsAvailable,
13527
13557
  evcsMaxPowerKw: (cfg && cfg.settingsConfig && Number(cfg.settingsConfig.evcsMaxPowerKw)) || 11,
13528
- evcsList: Array.isArray(this.evcsList) ? this.evcsList : []
13558
+ evcsList: evcsAvailable ? evcsListForConfig : []
13529
13559
  },
13530
13560
  smartHome: cfg.smartHome || {},
13561
+ smartHomeEnabled: !!(cfg.smartHome && cfg.smartHome.enabled),
13562
+ storageFarmEnabled: storageFarmAvailable,
13531
13563
  ems: {
13532
13564
  chargingEnabled: inferChargingEnabled(),
13565
+ evcsAvailable: evcsAvailable,
13533
13566
  peakShavingEnabled: boolOr(cfg.enablePeakShaving, false) || boolOr(cfg && cfg.peakShaving && cfg.peakShaving.atypical && cfg.peakShaving.atypical.enabled, false),
13534
13567
  para14aEnabled: boolOr(cfg && cfg.installerConfig && cfg.installerConfig.para14a, false),
13535
13568
  gridConstraintsEnabled: boolOr(cfg.enableGridConstraints, false),
13536
13569
  storageEnabled: boolOr(cfg.enableStorageControl, false),
13537
- storageFarmEnabled: boolOr(cfg.enableStorageFarm, false),
13570
+ storageFarmEnabled: storageFarmAvailable,
13538
13571
  heatingRodEnabled: boolOr(cfg.enableHeatingRodControl, false),
13539
13572
  thresholdEnabled: boolOr(cfg.enableThresholdControl, false),
13540
13573
  relayEnabled: boolOr(cfg.enableRelayControl, false),
@@ -19991,7 +20024,7 @@ Technische Details: system.adapter.${c.inst}.alive=false`,
19991
20024
  // derived EVCS aggregates
19992
20025
  try {
19993
20026
  if (/^evcs\.\d+\.powerW$/.test(key)) {
19994
- const count = Number(this.evcsCount || 1) || 1;
20027
+ const count = Math.max(0, Math.round(Number(this.evcsCount || 0) || 0));
19995
20028
  let sum = 0;
19996
20029
  for (let i = 1; i <= count; i++) {
19997
20030
  const v = this.stateCache[`evcs.${i}.powerW`]?.value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.nexowatt-ui",
3
- "version": "0.7.40",
3
+ "version": "0.7.41",
4
4
  "description": "Responsive NexoWatt EMS visualization adapter.",
5
5
  "author": "NexoWatt",
6
6
  "license": "Proprietary License (NPL) v1.0",