iobroker.nexowatt-ui 0.7.45 → 0.7.47

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.
@@ -565,30 +565,42 @@ class CoreLimitsModule extends BaseModule {
565
565
  return Math.max(0, this._readCacheNumber(['derived.core.pv.totalW', 'pvPower', 'productionTotal', 'storageFarm.totalPvPowerW'], 0) || 0);
566
566
  })();
567
567
 
568
- // Speicherfarm- und Einzelakku-Aliase können parallel existieren. Ein 0-W-Wert aus
569
- // storageFarm.* darf einen echten Wert aus storageChargePower/storageDischargePower
570
- // nicht verdecken, sonst sieht Gate C keine Akku-Entladung und Verbraucher halten
571
- // fälschlich Last aus dem Speicher. Darum hier bewusst den größten frischen Wert nutzen.
572
- let storageChargeW = Math.max(0, this._readCacheNumberMax(['storageFarm.totalChargePowerW', 'storageChargePower'], 0) || 0);
573
- let storageDischargeW = Math.max(0, this._readCacheNumberMax(['storageFarm.totalDischargePowerW', 'storageDischargePower'], 0) || 0);
574
- const batteryPowerW = this._readCacheNumber(['batteryPower'], null);
575
- if (isFiniteNumber(batteryPowerW)) {
576
- const flowBatteryMapped = !!(cfg.datapoints && String(cfg.datapoints.batteryPower || '').trim());
577
- const farmActive = !!this._readCacheNumber(['storageFarm.enabled'], 0);
578
- // Apply the VIS inversion only to a raw mapped batteryPower datapoint.
579
- // If batteryPower was mirrored from the already-normalized storage pair/farm,
580
- // flipping it here again would swap charge/discharge twice.
581
- const invBattery = flowBatteryMapped && !farmActive && !!(cfg.settings && cfg.settings.flowInvertBattery);
582
- const signed = Math.round(invBattery ? -batteryPowerW : batteryPowerW);
583
- if (signed < -25) {
584
- storageChargeW = Math.max(storageChargeW, Math.abs(signed));
585
- storageDischargeW = 0;
586
- } else if (signed > 25) {
587
- storageDischargeW = Math.max(storageDischargeW, signed);
588
- storageChargeW = 0;
589
- } else {
590
- storageChargeW = 0;
591
- storageDischargeW = 0;
568
+ // Speicherleistung wird zentral wie im Energiefluss aufgelöst:
569
+ // - getrennte Lade-/Entlade-DPs bleiben vollständig gültig
570
+ // - signed Batterie-DP bleibt gültig (- = Laden, + = Entladen; invertierbar)
571
+ // - nur wenn keine frische Messquelle vorhanden ist, wird rechnerisch über die Bilanz abgeleitet
572
+ let storageChargeW = 0;
573
+ let storageDischargeW = 0;
574
+ let usedCentralStorageFlow = false;
575
+ try {
576
+ const flow = (this.adapter && typeof this.adapter._nwResolveBatteryFlowFromCache === 'function')
577
+ ? this.adapter._nwResolveBatteryFlowFromCache({ maxAgeMs: staleMs, deadbandW: 25 })
578
+ : null;
579
+ if (flow && typeof flow === 'object') {
580
+ usedCentralStorageFlow = true;
581
+ storageChargeW = Math.max(0, Math.round(Number(flow.chargeW) || 0));
582
+ storageDischargeW = Math.max(0, Math.round(Number(flow.dischargeW) || 0));
583
+ }
584
+ } catch (_eFlow) {}
585
+
586
+ if (!usedCentralStorageFlow) {
587
+ // Fallback für sehr alte Laufzeiten ohne zentralen Resolver. Keine Plausibilitäts-
588
+ // Unterdrückung hier: gemappte Split-DPs sind autoritativ.
589
+ storageChargeW = Math.max(0, this._readCacheNumberMax(['storageFarm.totalChargePowerW', 'storageChargePower'], 0) || 0);
590
+ storageDischargeW = Math.max(0, this._readCacheNumberMax(['storageFarm.totalDischargePowerW', 'storageDischargePower'], 0) || 0);
591
+ const batteryPowerW = this._readCacheNumber(['batteryPower'], null);
592
+ if (isFiniteNumber(batteryPowerW)) {
593
+ const flowBatteryMapped = !!(cfg.datapoints && String(cfg.datapoints.batteryPower || '').trim());
594
+ const farmActive = !!this._readCacheNumber(['storageFarm.enabled'], 0);
595
+ const invBattery = flowBatteryMapped && !farmActive && !!(cfg.settings && cfg.settings.flowInvertBattery);
596
+ const signed = Math.round(invBattery ? -batteryPowerW : batteryPowerW);
597
+ if (signed < -25) {
598
+ storageChargeW = Math.max(storageChargeW, Math.abs(signed));
599
+ storageDischargeW = 0;
600
+ } else if (signed > 25) {
601
+ storageDischargeW = Math.max(storageDischargeW, signed);
602
+ storageChargeW = 0;
603
+ }
592
604
  }
593
605
  }
594
606
 
@@ -604,42 +604,47 @@ class HeatingRodControlModule extends BaseModule {
604
604
  }
605
605
 
606
606
  _readStorageSnapshot(staleMs) {
607
- // Speicherfarm- und Einzelakku-Aliase können beide im Cache stehen. Ein 0-W-Wert
608
- // aus storageFarm.* darf einen echten Entlade-/Ladewert aus den Basis-Aliasen nicht
609
- // verdecken. Sonst erkennt der Heizstab keine Akku-Entladung und hält zu hohe Stufen.
610
- let chargeW = Math.max(0, num(this._readNumberMaxAny([
611
- 'storageFarm.totalChargePowerW',
612
- 'storageChargePower'
613
- ], staleMs, null), 0));
614
-
615
- let dischargeW = Math.max(0, num(this._readNumberMaxAny([
616
- 'storageFarm.totalDischargePowerW',
617
- 'storageDischargePower'
618
- ], staleMs, null), 0));
619
-
620
- const batteryPowerW = this._readNumberAny(['batteryPower'], staleMs, null);
621
- if (typeof batteryPowerW === 'number' && Number.isFinite(batteryPowerW)) {
622
- const cfg = (this.adapter && this.adapter.config) ? this.adapter.config : {};
623
- const flowBatteryMapped = !!(cfg.datapoints && String(cfg.datapoints.batteryPower || '').trim());
624
- const farmActive = !!this._readCacheNumber('storageFarm.enabled', 0);
625
- // Apply the VIS inversion only to a raw mapped batteryPower datapoint.
626
- // Mirrored batteryPower values are already normalized by the main flow engine.
627
- const invBattery = flowBatteryMapped && !farmActive && !!(cfg.settings && cfg.settings.flowInvertBattery);
628
- const signedW = Math.round(invBattery ? -batteryPowerW : batteryPowerW);
629
- const noiseW = 25;
630
- // batteryPower is the canonical direction signal in this adapter:
631
- // +W = discharge, -W = charge. Prefer that direction over separate
632
- // charge/discharge aliases, because those can be delayed or vendor-specific.
633
- // Otherwise a charging battery can look like discharge and block stage-up.
634
- if (signedW < -noiseW) {
635
- chargeW = Math.max(chargeW, Math.abs(signedW));
636
- dischargeW = 0;
637
- } else if (signedW > noiseW) {
638
- dischargeW = Math.max(dischargeW, signedW);
639
- chargeW = 0;
640
- } else {
641
- chargeW = 0;
642
- dischargeW = 0;
607
+ let chargeW = 0;
608
+ let dischargeW = 0;
609
+ let usedCentralStorageFlow = false;
610
+ try {
611
+ const flow = (this.adapter && typeof this.adapter._nwResolveBatteryFlowFromCache === 'function')
612
+ ? this.adapter._nwResolveBatteryFlowFromCache({ maxAgeMs: staleMs, deadbandW: 25 })
613
+ : null;
614
+ if (flow && typeof flow === 'object') {
615
+ usedCentralStorageFlow = true;
616
+ chargeW = Math.max(0, Math.round(Number(flow.chargeW) || 0));
617
+ dischargeW = Math.max(0, Math.round(Number(flow.dischargeW) || 0));
618
+ }
619
+ } catch (_eFlow) {}
620
+
621
+ if (!usedCentralStorageFlow) {
622
+ // Fallback für ältere Laufzeiten: Split-DPs und signed DP bleiben wie bisher erlaubt.
623
+ chargeW = Math.max(0, num(this._readNumberMaxAny([
624
+ 'storageFarm.totalChargePowerW',
625
+ 'storageChargePower'
626
+ ], staleMs, null), 0));
627
+
628
+ dischargeW = Math.max(0, num(this._readNumberMaxAny([
629
+ 'storageFarm.totalDischargePowerW',
630
+ 'storageDischargePower'
631
+ ], staleMs, null), 0));
632
+
633
+ const batteryPowerW = this._readNumberAny(['batteryPower'], staleMs, null);
634
+ if (typeof batteryPowerW === 'number' && Number.isFinite(batteryPowerW)) {
635
+ const cfg = (this.adapter && this.adapter.config) ? this.adapter.config : {};
636
+ const flowBatteryMapped = !!(cfg.datapoints && String(cfg.datapoints.batteryPower || '').trim());
637
+ const farmActive = !!this._readCacheNumber('storageFarm.enabled', 0);
638
+ const invBattery = flowBatteryMapped && !farmActive && !!(cfg.settings && cfg.settings.flowInvertBattery);
639
+ const signedW = Math.round(invBattery ? -batteryPowerW : batteryPowerW);
640
+ const noiseW = 25;
641
+ if (signedW < -noiseW) {
642
+ chargeW = Math.max(chargeW, Math.abs(signedW));
643
+ dischargeW = 0;
644
+ } else if (signedW > noiseW) {
645
+ dischargeW = Math.max(dischargeW, signedW);
646
+ chargeW = 0;
647
+ }
643
648
  }
644
649
  }
645
650
 
@@ -691,7 +696,6 @@ class HeatingRodControlModule extends BaseModule {
691
696
  const exportW = gridKnown ? Math.max(0, -gridW) : 0;
692
697
  const importW = gridKnown ? Math.max(0, gridW) : 0;
693
698
  const storage = this._readStorageSnapshot(staleMs);
694
-
695
699
  const storageTargetSocPct = clamp(num(cfg.storageTargetSocPct, 90), 0, 100);
696
700
  const storageReserveCfgW = Math.max(0, Math.round(num(cfg.storageReserveW, 1000)));
697
701
  const storageKnown = storage.chargeW > 0
package/io-package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "nexowatt-ui",
4
- "version": "0.7.45",
4
+ "version": "0.7.47",
5
5
  "news": {
6
+ "0.7.47": {
7
+ "en": "Energy-flow datapoint resolver fixed: split charge/discharge datapoints and signed battery power are supported consistently again; calculated fallback is only used when a fresh measurement source is missing. Heating-rod reserve inputs are flushed before save.",
8
+ "de": "Energiefluss-Datenpunktauflösung korrigiert: getrennte Lade-/Entlade-Datenpunkte und signed Batterie-Leistung werden wieder konsistent unterstützt; der rechnerische Fallback greift nur, wenn keine frische Messquelle vorhanden ist. Heizstab-Reservefelder werden vor dem Speichern direkt übernommen."
9
+ },
6
10
  "0.7.42": {
7
11
  "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
12
  "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,7 +1991,7 @@
1987
1991
  }
1988
1992
  },
1989
1993
  "instanceObjects": [],
1990
- "version": "0.7.45",
1994
+ "version": "0.7.47",
1991
1995
  "news": {
1992
1996
  "0.7.42": {
1993
1997
  "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.",
package/main.js CHANGED
@@ -17727,13 +17727,15 @@ Technische Details: system.adapter.${c.inst}.alive=false`,
17727
17727
 
17728
17728
  const preferBalance = (current) => {
17729
17729
  try {
17730
- const measured = Math.max(0, Math.abs(Number(current && current.chargeW) || 0) + Math.abs(Number(current && current.dischargeW) || 0));
17731
17730
  const srcCur = String(current && current.src || '');
17732
- const missingLike = !current || srcCur === 'missing' || srcCur === 'stale-or-missing';
17731
+ const missingLike = !current || srcCur === 'missing' || srcCur === 'stale-or-missing' || current.incomplete === true;
17732
+ if (!missingLike) return current;
17733
17733
  const derived = fromBalance();
17734
17734
  if (!derived) return current;
17735
- if (missingLike || measured <= Math.max(180, deadbandW)) return derived;
17736
- return current;
17735
+ return Object.assign({}, derived, {
17736
+ src: String(derived.src || 'balanceDerived') + (current && current.incomplete ? '+missing-side' : ''),
17737
+ fallbackFor: srcCur || 'missing'
17738
+ });
17737
17739
  } catch (_ePrefer) {
17738
17740
  return current;
17739
17741
  }
@@ -17796,6 +17798,7 @@ Technische Details: system.adapter.${c.inst}.alive=false`,
17796
17798
  if (c <= deadbandW) c = 0;
17797
17799
  if (d <= deadbandW) d = 0;
17798
17800
  if (inv) { const t = c; c = d; d = t; }
17801
+ const completePair = !!(chargeMapped && dischargeMapped && chargeRaw !== null && dischargeRaw !== null && !sameChargeDischargeId);
17799
17802
  return preferBalance({
17800
17803
  chargeW: Math.round(c),
17801
17804
  dischargeW: Math.round(d),
@@ -17804,6 +17807,7 @@ Technische Details: system.adapter.${c.inst}.alive=false`,
17804
17807
  inverted: inv,
17805
17808
  fromSigned: false,
17806
17809
  mirror: sameChargeDischargeId || !chargeMapped || !dischargeMapped,
17810
+ incomplete: !completePair,
17807
17811
  staleMs: {
17808
17812
  storageChargePower: this._nwGetCacheAgeMs('storageChargePower', now),
17809
17813
  storageDischargePower: this._nwGetCacheAgeMs('storageDischargePower', now),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.nexowatt-ui",
3
- "version": "0.7.45",
3
+ "version": "0.7.47",
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
@@ -2109,13 +2109,15 @@ function getBalanceDerivedBatteryFlow(opts = {}) {
2109
2109
  function preferBalanceDerivedBatteryFlow(current, opts = {}) {
2110
2110
  try {
2111
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
2112
  const src = String(current && current.src || '');
2114
- const missingLike = !current || src === 'missing' || src === 'stale-or-missing';
2113
+ const missingLike = !current || src === 'missing' || src === 'stale-or-missing' || current.incomplete === true;
2114
+ if (!missingLike) return current;
2115
2115
  const derived = getBalanceDerivedBatteryFlow({ deadbandW });
2116
2116
  if (!derived) return current;
2117
- if (missingLike || measured <= deadbandW) return derived;
2118
- return current;
2117
+ return Object.assign({}, derived, {
2118
+ src: String(derived.src || 'balanceDerived') + (current && current.incomplete ? '+missing-side' : ''),
2119
+ fallbackFor: src || 'missing'
2120
+ });
2119
2121
  } catch (_e) {
2120
2122
  return current;
2121
2123
  }
@@ -2180,7 +2182,8 @@ function getNormalizedBatteryFlow() {
2180
2182
  if (c <= deadbandW) c = 0;
2181
2183
  if (d <= deadbandW) d = 0;
2182
2184
  if (inv) { const t = c; c = d; d = t; }
2183
- return preferBalanceDerivedBatteryFlow({ chargeW: c, dischargeW: d, signedW: d - c, src: inv ? 'chargeDischarge(inv)' : 'chargeDischarge', inverted: inv }, { deadbandW });
2185
+ const completePair = !!(chargeMapped && dischargeMapped && charge !== null && discharge !== null && !samePair);
2186
+ return preferBalanceDerivedBatteryFlow({ chargeW: c, dischargeW: d, signedW: d - c, src: inv ? 'chargeDischarge(inv)' : 'chargeDischarge', inverted: inv, incomplete: !completePair }, { deadbandW });
2184
2187
  }
2185
2188
 
2186
2189
  if (signedBattery !== null) return preferBalanceDerivedBatteryFlow(fromSigned(signedBattery, 'batterySigned'), { deadbandW });
package/www/ems-apps.js CHANGED
@@ -2547,8 +2547,10 @@ function _collectFlowPowerDpIsWFromUI() {
2547
2547
  currentConfig.heatingRod = (currentConfig.heatingRod && typeof currentConfig.heatingRod === 'object') ? currentConfig.heatingRod : {};
2548
2548
  const h = currentConfig.heatingRod;
2549
2549
  h.devices = Array.isArray(h.devices) ? h.devices : [];
2550
- h.storageReserveW = Math.max(0, Math.round(Number(h.storageReserveW ?? 1000) || 1000));
2551
- h.storageTargetSocPct = Math.max(0, Math.min(100, Math.round(Number(h.storageTargetSocPct ?? 90) || 90)));
2550
+ const _hrReserveRaw = Number(h.storageReserveW);
2551
+ h.storageReserveW = Math.max(0, Math.round(Number.isFinite(_hrReserveRaw) ? _hrReserveRaw : 1000));
2552
+ const _hrSocRaw = Number(h.storageTargetSocPct);
2553
+ h.storageTargetSocPct = Math.max(0, Math.min(100, Math.round(Number.isFinite(_hrSocRaw) ? _hrSocRaw : 90)));
2552
2554
  const hMinPvRaw = Number(h.minPvPowerW ?? h.pvAutoMinPvPowerW ?? h.minCurrentPvW);
2553
2555
  h.minPvPowerW = Math.max(0, Math.round(Number.isFinite(hMinPvRaw) ? hMinPvRaw : 800));
2554
2556
  h.useBudgetGates = true;
@@ -2687,13 +2689,48 @@ function _collectFlowPowerDpIsWFromUI() {
2687
2689
  if (opts.step != null) inp.step = String(opts.step);
2688
2690
  if (opts.width) inp.style.width = opts.width;
2689
2691
  if (opts.disabled) inp.disabled = true;
2690
- inp.addEventListener('change', () => {
2692
+ const commit = () => {
2691
2693
  const v = (type === 'number') ? Number(inp.value) : (type === 'checkbox' ? !!inp.checked : inp.value);
2692
2694
  onChange(v, inp);
2693
- });
2695
+ };
2696
+ // Number/text fields must update the in-memory config immediately. Otherwise a
2697
+ // fast save or a reactive UI refresh can write the previous value again (e.g.
2698
+ // Heizstab Speicher-Reserve snapped back to the default 1000 W).
2699
+ inp.addEventListener('change', commit);
2700
+ if (type !== 'checkbox') inp.addEventListener('input', commit);
2701
+ return inp;
2702
+ }
2703
+
2704
+ function _mkHeatingRodNumberInput(key, value, onChange, opts = {}) {
2705
+ const inp = _mkCfgInput('number', value, onChange, opts);
2706
+ inp.dataset.heatingRodCfgKey = String(key || '');
2707
+ inp.id = `heatingRod_${String(key || '').replace(/[^a-zA-Z0-9_-]/g, '_')}`;
2694
2708
  return inp;
2695
2709
  }
2696
2710
 
2711
+ function flushHeatingRodConfigFromDom() {
2712
+ try {
2713
+ if (!document || !document.querySelectorAll) return;
2714
+ currentConfig = currentConfig || {};
2715
+ currentConfig.heatingRod = (currentConfig.heatingRod && typeof currentConfig.heatingRod === 'object') ? currentConfig.heatingRod : {};
2716
+ const h = currentConfig.heatingRod;
2717
+ const numericKeys = new Set([
2718
+ 'storageReserveW', 'storageTargetSocPct', 'minPvPowerW', 'budgetSafetyReserveW',
2719
+ 'stageUpDelaySec', 'minStageRunSec', 'cooldownAfterOffSec', 'maxGridImportW',
2720
+ 'gridImportHoldSec', 'storageDischargeToleranceW', 'storageDischargeHoldSec'
2721
+ ]);
2722
+ document.querySelectorAll('[data-heating-rod-cfg-key]').forEach((el) => {
2723
+ const key = String(el.dataset.heatingRodCfgKey || '').trim();
2724
+ if (!key || !numericKeys.has(key)) return;
2725
+ const n = Number(el.value);
2726
+ if (!Number.isFinite(n)) return;
2727
+ if (key === 'storageTargetSocPct') h[key] = Math.max(0, Math.min(100, Math.round(n)));
2728
+ else h[key] = Math.max(0, Math.round(n));
2729
+ });
2730
+ } catch (_e) {}
2731
+ }
2732
+
2733
+
2697
2734
  function _mkCfgSelect(value, options, onChange, opts = {}) {
2698
2735
  const sel = document.createElement('select');
2699
2736
  sel.className = opts.className || 'nw-config-select';
@@ -3031,10 +3068,10 @@ function _collectFlowPowerDpIsWFromUI() {
3031
3068
  autoInfo.style.flexBasis = '100%';
3032
3069
  autoInfo.textContent = 'Zentrale EMS-Budget-Gates lesen, PV/NVP-Überschuss verfolgen und eigene PV-Auto-Stufen halten. Externe KNX-/Relais-Schaltungen werden nur beobachtet.';
3033
3070
  grpAuto.body.appendChild(autoInfo);
3034
- grpAuto.body.appendChild(_mkCfgField('Speicher-Reserve (W)', _mkCfgInput('number', cfg.storageReserveW, (v) => { cfg.storageReserveW = Math.max(0, Math.round(Number(v) || 0)); setDirty(); }, { min: 0, step: 50, width: '150px' }), 'Bleibt für Speicherladung frei, solange der Speicher unter dem Ziel-SoC liegt.'));
3035
- grpAuto.body.appendChild(_mkCfgField('Reserve bis SoC (%)', _mkCfgInput('number', cfg.storageTargetSocPct, (v) => { cfg.storageTargetSocPct = Math.max(0, Math.min(100, Math.round(Number(v) || 0))); setDirty(); }, { min: 0, max: 100, step: 1, width: '130px' }), 'Ab diesem SoC darf der Heizstab den Überschuss ohne Speicherreserve nutzen.'));
3036
- grpAuto.body.appendChild(_mkCfgField('PV-Auto ab PV (W)', _mkCfgInput('number', cfg.minPvPowerW, (v) => { cfg.minPvPowerW = Math.max(0, Math.round(Number(v) || 0)); setDirty(); }, { min: 0, step: 50, width: '150px' }), 'Start-/Hochschaltgrenze. Unterhalb wird nicht neu zugeschaltet, laufende Auto-Stufen werden aber über Netz-/Speichergates stabil gehalten.'));
3037
- grpAuto.body.appendChild(_mkCfgField('Sicherheitsreserve (W)', _mkCfgInput('number', cfg.budgetSafetyReserveW, (v) => { cfg.budgetSafetyReserveW = Math.max(0, Math.round(Number(v) || 0)); setDirty(); }, { min: 0, step: 10, width: '150px' }), 'Abzug vom Heizstab-Budget gegen Messrauschen.'));
3071
+ grpAuto.body.appendChild(_mkCfgField('Speicher-Reserve (W)', _mkHeatingRodNumberInput('storageReserveW', cfg.storageReserveW, (v) => { cfg.storageReserveW = Math.max(0, Math.round(Number(v) || 0)); setDirty(); }, { min: 0, step: 50, width: '150px' }), 'Bleibt für Speicherladung frei, solange der Speicher unter dem Ziel-SoC liegt.'));
3072
+ grpAuto.body.appendChild(_mkCfgField('Reserve bis SoC (%)', _mkHeatingRodNumberInput('storageTargetSocPct', cfg.storageTargetSocPct, (v) => { cfg.storageTargetSocPct = Math.max(0, Math.min(100, Math.round(Number(v) || 0))); setDirty(); }, { min: 0, max: 100, step: 1, width: '130px' }), 'Ab diesem SoC darf der Heizstab den Überschuss ohne Speicherreserve nutzen.'));
3073
+ grpAuto.body.appendChild(_mkCfgField('PV-Auto ab PV (W)', _mkHeatingRodNumberInput('minPvPowerW', cfg.minPvPowerW, (v) => { cfg.minPvPowerW = Math.max(0, Math.round(Number(v) || 0)); setDirty(); }, { min: 0, step: 50, width: '150px' }), 'Start-/Hochschaltgrenze. Unterhalb wird nicht neu zugeschaltet, laufende Auto-Stufen werden aber über Netz-/Speichergates stabil gehalten.'));
3074
+ grpAuto.body.appendChild(_mkCfgField('Sicherheitsreserve (W)', _mkHeatingRodNumberInput('budgetSafetyReserveW', cfg.budgetSafetyReserveW, (v) => { cfg.budgetSafetyReserveW = Math.max(0, Math.round(Number(v) || 0)); setDirty(); }, { min: 0, step: 10, width: '150px' }), 'Abzug vom Heizstab-Budget gegen Messrauschen.'));
3038
3075
  els.heatingRodDevices.appendChild(grpAuto.wrap);
3039
3076
 
3040
3077
  const grpSwitch = _mkCfgGroup('Robustes Schalten');
@@ -3043,13 +3080,13 @@ function _collectFlowPowerDpIsWFromUI() {
3043
3080
  switchInfo.style.flexBasis = '100%';
3044
3081
  switchInfo.textContent = 'Hysterese gegen Netz- und WR-Schwankungen: erst stabil hochfahren, bei kleinem Netzbezug halten und nur nach Haltezeit reduzieren.';
3045
3082
  grpSwitch.body.appendChild(switchInfo);
3046
- grpSwitch.body.appendChild(_mkCfgField('Stufe-hoch Wartezeit (s)', _mkCfgInput('number', cfg.stageUpDelaySec, (v) => { cfg.stageUpDelaySec = Math.max(0, Math.round(Number(v) || 0)); setDirty(); }, { min: 0, step: 1, width: '150px' }), 'Maximal eine physische Stufe pro Wartezeit.'));
3047
- grpSwitch.body.appendChild(_mkCfgField('Min. Laufzeit Auto-Stufe (s)', _mkCfgInput('number', cfg.minStageRunSec, (v) => { cfg.minStageRunSec = Math.max(0, Math.round(Number(v) || 0)); setDirty(); }, { min: 0, step: 1, width: '170px' }), 'Verhindert nervöses Runterschalten bei kurzen Budget-Dellen.'));
3048
- grpSwitch.body.appendChild(_mkCfgField('Cooldown nach Abwurf (s)', _mkCfgInput('number', cfg.cooldownAfterOffSec, (v) => { cfg.cooldownAfterOffSec = Math.max(0, Math.round(Number(v) || 0)); setDirty(); }, { min: 0, step: 1, width: '170px' }), 'Wartezeit bevor nach komplettem AUS wieder gestartet wird.'));
3049
- grpSwitch.body.appendChild(_mkCfgField('Netzbezug erlaubt (W)', _mkCfgInput('number', cfg.maxGridImportW, (v) => { cfg.maxGridImportW = Math.max(0, Math.round(Number(v) || 0)); setDirty(); }, { min: 0, step: 10, width: '150px' }), 'Kleiner erlaubter Bezug, damit der Heizstab bei NVP-Schwankungen an bleibt.'));
3050
- grpSwitch.body.appendChild(_mkCfgField('Netzbezug Haltezeit (s)', _mkCfgInput('number', cfg.gridImportHoldSec, (v) => { cfg.gridImportHoldSec = Math.max(0, Math.round(Number(v) || 0)); setDirty(); }, { min: 0, step: 1, width: '160px' }), 'Erst wenn der Bezug so lange überschritten ist, wird eine Auto-Stufe reduziert.'));
3051
- grpSwitch.body.appendChild(_mkCfgField('Speicherentladung erlaubt (W)', _mkCfgInput('number', cfg.storageDischargeToleranceW, (v) => { cfg.storageDischargeToleranceW = Math.max(0, Math.round(Number(v) || 0)); setDirty(); }, { min: 0, step: 10, width: '170px' }), 'Akku-Schutz: kurze Messdellen sind erlaubt, dauerhafte Entladung reduziert Auto-Stufen.'));
3052
- grpSwitch.body.appendChild(_mkCfgField('Speicherentladung Haltezeit (s)', _mkCfgInput('number', cfg.storageDischargeHoldSec, (v) => { cfg.storageDischargeHoldSec = Math.max(0, Math.round(Number(v) || 0)); setDirty(); }, { min: 0, step: 1, width: '190px' }), 'Dauer bis zur Reduzierung bei Akku-Entladung.'));
3083
+ grpSwitch.body.appendChild(_mkCfgField('Stufe-hoch Wartezeit (s)', _mkHeatingRodNumberInput('stageUpDelaySec', cfg.stageUpDelaySec, (v) => { cfg.stageUpDelaySec = Math.max(0, Math.round(Number(v) || 0)); setDirty(); }, { min: 0, step: 1, width: '150px' }), 'Maximal eine physische Stufe pro Wartezeit.'));
3084
+ grpSwitch.body.appendChild(_mkCfgField('Min. Laufzeit Auto-Stufe (s)', _mkHeatingRodNumberInput('minStageRunSec', cfg.minStageRunSec, (v) => { cfg.minStageRunSec = Math.max(0, Math.round(Number(v) || 0)); setDirty(); }, { min: 0, step: 1, width: '170px' }), 'Verhindert nervöses Runterschalten bei kurzen Budget-Dellen.'));
3085
+ grpSwitch.body.appendChild(_mkCfgField('Cooldown nach Abwurf (s)', _mkHeatingRodNumberInput('cooldownAfterOffSec', cfg.cooldownAfterOffSec, (v) => { cfg.cooldownAfterOffSec = Math.max(0, Math.round(Number(v) || 0)); setDirty(); }, { min: 0, step: 1, width: '170px' }), 'Wartezeit bevor nach komplettem AUS wieder gestartet wird.'));
3086
+ grpSwitch.body.appendChild(_mkCfgField('Netzbezug erlaubt (W)', _mkHeatingRodNumberInput('maxGridImportW', cfg.maxGridImportW, (v) => { cfg.maxGridImportW = Math.max(0, Math.round(Number(v) || 0)); setDirty(); }, { min: 0, step: 10, width: '150px' }), 'Kleiner erlaubter Bezug, damit der Heizstab bei NVP-Schwankungen an bleibt.'));
3087
+ grpSwitch.body.appendChild(_mkCfgField('Netzbezug Haltezeit (s)', _mkHeatingRodNumberInput('gridImportHoldSec', cfg.gridImportHoldSec, (v) => { cfg.gridImportHoldSec = Math.max(0, Math.round(Number(v) || 0)); setDirty(); }, { min: 0, step: 1, width: '160px' }), 'Erst wenn der Bezug so lange überschritten ist, wird eine Auto-Stufe reduziert.'));
3088
+ grpSwitch.body.appendChild(_mkCfgField('Speicherentladung erlaubt (W)', _mkHeatingRodNumberInput('storageDischargeToleranceW', cfg.storageDischargeToleranceW, (v) => { cfg.storageDischargeToleranceW = Math.max(0, Math.round(Number(v) || 0)); setDirty(); }, { min: 0, step: 10, width: '170px' }), 'Akku-Schutz: kurze Messdellen sind erlaubt, dauerhafte Entladung reduziert Auto-Stufen.'));
3089
+ grpSwitch.body.appendChild(_mkCfgField('Speicherentladung Haltezeit (s)', _mkHeatingRodNumberInput('storageDischargeHoldSec', cfg.storageDischargeHoldSec, (v) => { cfg.storageDischargeHoldSec = Math.max(0, Math.round(Number(v) || 0)); setDirty(); }, { min: 0, step: 1, width: '190px' }), 'Dauer bis zur Reduzierung bei Akku-Entladung.'));
3053
3090
  els.heatingRodDevices.appendChild(grpSwitch.wrap);
3054
3091
 
3055
3092
  const grpProtect = _mkCfgDetailsGroup('Erweitert: harte Schutzgrenzen', false);
@@ -7732,13 +7769,19 @@ function _collectFlowPowerDpIsWFromUI() {
7732
7769
  const socId = _nwGetAlias(stDev, 'r.soc');
7733
7770
 
7734
7771
  let storageMapped = false;
7735
- if (chargeId && dischargeId) {
7772
+ // Prefer the single signed battery power datapoint when it is available.
7773
+ // It is the safest source for the VIS/EMS balance (+ Entladen / - Laden).
7774
+ // Some devices expose split powerCharge/powerDischarge aliases that are
7775
+ // control/assist values rather than the real physical battery flow. Those
7776
+ // can make the house load and PV budget wrong, so use them only when no
7777
+ // signed datapoint exists.
7778
+ if (signedId) {
7779
+ if (_nwApplyFlowDpIfEmpty('batteryPower', signedId, { powerIsW: true })) out.changed = true;
7780
+ storageMapped = true;
7781
+ } else if (chargeId && dischargeId) {
7736
7782
  if (_nwApplyFlowDpIfEmpty('storageChargePower', chargeId, { powerIsW: true })) out.changed = true;
7737
7783
  if (_nwApplyFlowDpIfEmpty('storageDischargePower', dischargeId, { powerIsW: true })) out.changed = true;
7738
7784
  storageMapped = true;
7739
- } else if (signedId) {
7740
- if (_nwApplyFlowDpIfEmpty('batteryPower', signedId, { powerIsW: true })) out.changed = true;
7741
- storageMapped = true;
7742
7785
  }
7743
7786
  if (socId) {
7744
7787
  if (_nwApplyFlowDpIfEmpty('storageSoc', socId)) out.changed = true;
@@ -8122,6 +8165,7 @@ function _collectFlowPowerDpIsWFromUI() {
8122
8165
  }
8123
8166
 
8124
8167
  // Thermik / Heizstab (PV‑Auto für Verbraucher‑Slots)
8168
+ try { flushHeatingRodConfigFromDom(); } catch (_e) {}
8125
8169
  patch.thermal = deepMerge({}, currentConfig.thermal || {});
8126
8170
  patch.heatingRod = deepMerge({}, currentConfig.heatingRod || {});
8127
8171
  patch.bhkw = deepMerge({}, currentConfig.bhkw || {});
@@ -44,5 +44,5 @@
44
44
  "purpose": "maskable"
45
45
  }
46
46
  ],
47
- "version": "0.7.45"
47
+ "version": "0.7.47"
48
48
  }
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-v213';
3
+ const CACHE_NAME = 'nexowatt-cache-v215';
4
4
 
5
5
  const OFFLINE_URLS = [
6
6
  './',