iobroker.nexowatt-ui 0.7.45 → 0.7.46

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.
@@ -592,6 +592,19 @@ class CoreLimitsModule extends BaseModule {
592
592
  }
593
593
  }
594
594
 
595
+ // Guard against ghost split-battery aliases: with no direct house-load meter,
596
+ // discharge + NVP export would inflate house load and reduce the PV budget.
597
+ // This keeps signed batteryPower and direct load meters authoritative, but avoids
598
+ // bad powerDischarge aliases breaking Heizstab/EMS budgets.
599
+ try {
600
+ const hasDirectLoad = !!(cfg.datapoints && (String(cfg.datapoints.consumptionTotal || '').trim() || String(cfg.datapoints.housePower || '').trim()));
601
+ const splitBatteryConfigured = !!(cfg.datapoints && (String(cfg.datapoints.storageChargePower || '').trim() || String(cfg.datapoints.storageDischargePower || '').trim()));
602
+ const signedBatteryConfigured = !!(cfg.datapoints && String(cfg.datapoints.batteryPower || '').trim());
603
+ if (!hasDirectLoad && splitBatteryConfigured && !signedBatteryConfigured && gridExportW > 250 && storageDischargeW > 250 && storageChargeW <= 250) {
604
+ storageDischargeW = 0;
605
+ }
606
+ } catch (_eSanitizeStorage) {}
607
+
595
608
  const evcsEnabled = cfg.enableChargingManagement !== false;
596
609
  const thermalEnabled = cfg.enableThermalControl === true;
597
610
  const heatingRodEnabled = cfg.enableHeatingRodControl === true;
@@ -691,6 +691,16 @@ class HeatingRodControlModule extends BaseModule {
691
691
  const exportW = gridKnown ? Math.max(0, -gridW) : 0;
692
692
  const importW = gridKnown ? Math.max(0, gridW) : 0;
693
693
  const storage = this._readStorageSnapshot(staleMs);
694
+ try {
695
+ const appCfg = (this.adapter && this.adapter.config) ? this.adapter.config : {};
696
+ const hasDirectLoad = !!(appCfg.datapoints && (String(appCfg.datapoints.consumptionTotal || '').trim() || String(appCfg.datapoints.housePower || '').trim()));
697
+ const splitBatteryConfigured = !!(appCfg.datapoints && (String(appCfg.datapoints.storageChargePower || '').trim() || String(appCfg.datapoints.storageDischargePower || '').trim()));
698
+ const signedBatteryConfigured = !!(appCfg.datapoints && String(appCfg.datapoints.batteryPower || '').trim());
699
+ if (!hasDirectLoad && splitBatteryConfigured && !signedBatteryConfigured && exportW > 250 && storage.dischargeW > 250 && storage.chargeW <= 250) {
700
+ storage.dischargeW = 0;
701
+ storage.sanitizedExportDischarge = true;
702
+ }
703
+ } catch (_eSanitizeStorage) {}
694
704
 
695
705
  const storageTargetSocPct = clamp(num(cfg.storageTargetSocPct, 90), 0, 100);
696
706
  const storageReserveCfgW = Math.max(0, Math.round(num(cfg.storageReserveW, 1000)));
package/io-package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "nexowatt-ui",
4
- "version": "0.7.45",
4
+ "version": "0.7.46",
5
5
  "news": {
6
6
  "0.7.42": {
7
7
  "en": "Feature-dependent visibility fixed: EVCS/charging station and storage farm are only shown in the customer frontend when they are actually configured. Default/legacy placeholders no longer enable wallbox UI; AI Advisor suppresses EV/wallbox hints when no wallbox is available.",
@@ -1987,7 +1987,7 @@
1987
1987
  }
1988
1988
  },
1989
1989
  "instanceObjects": [],
1990
- "version": "0.7.45",
1990
+ "version": "0.7.46",
1991
1991
  "news": {
1992
1992
  "0.7.42": {
1993
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.",
package/main.js CHANGED
@@ -17739,6 +17739,31 @@ Technische Details: system.adapter.${c.inst}.alive=false`,
17739
17739
  }
17740
17740
  };
17741
17741
 
17742
+ const sanitizeSeparateBatteryFlow = (flow) => {
17743
+ try {
17744
+ if (!flow || String(flow.src || '').indexOf('chargeDischarge') < 0) return flow;
17745
+ const hasDirectLoad = this._nwHasMappedDatapoint('consumptionTotal') || this._nwHasMappedDatapoint('housePower');
17746
+ if (hasDirectLoad) return flow;
17747
+ const grid = this._nwResolveGridImportExportFromCache ? this._nwResolveGridImportExportFromCache() : null;
17748
+ const sellW = Math.max(0, Number(grid && grid.gridSellW) || 0);
17749
+ const dischargeW = Math.max(0, Number(flow.dischargeW) || 0);
17750
+ const chargeW = Math.max(0, Number(flow.chargeW) || 0);
17751
+ const limitW = Math.max(250, deadbandW * 10);
17752
+ if (sellW > limitW && dischargeW > limitW && chargeW <= limitW) {
17753
+ return Object.assign({}, flow, {
17754
+ chargeW: 0,
17755
+ dischargeW: 0,
17756
+ signedW: 0,
17757
+ src: String(flow.src || 'chargeDischarge') + '+sanitized-export-discharge',
17758
+ rejectedDischargeW: Math.round(dischargeW),
17759
+ sanitized: true,
17760
+ mirror: true
17761
+ });
17762
+ }
17763
+ } catch (_eSanitize) {}
17764
+ return flow;
17765
+ };
17766
+
17742
17767
  // Speicherfarm already provides normalized charge/discharge totals. Keep it authoritative
17743
17768
  // unless a signed single battery datapoint is explicitly mapped for a non-farm setup.
17744
17769
  const sfEnabled = !!(this.stateCache && this.stateCache['storageFarm.enabled'] && this.stateCache['storageFarm.enabled'].value);
@@ -17796,7 +17821,7 @@ Technische Details: system.adapter.${c.inst}.alive=false`,
17796
17821
  if (c <= deadbandW) c = 0;
17797
17822
  if (d <= deadbandW) d = 0;
17798
17823
  if (inv) { const t = c; c = d; d = t; }
17799
- return preferBalance({
17824
+ return preferBalance(sanitizeSeparateBatteryFlow({
17800
17825
  chargeW: Math.round(c),
17801
17826
  dischargeW: Math.round(d),
17802
17827
  signedW: Math.round(d - c),
@@ -17808,7 +17833,7 @@ Technische Details: system.adapter.${c.inst}.alive=false`,
17808
17833
  storageChargePower: this._nwGetCacheAgeMs('storageChargePower', now),
17809
17834
  storageDischargePower: this._nwGetCacheAgeMs('storageDischargePower', now),
17810
17835
  },
17811
- });
17836
+ }));
17812
17837
  }
17813
17838
 
17814
17839
  if (batterySigned !== null) {
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.46",
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
@@ -2146,6 +2146,36 @@ function getNormalizedBatteryFlow() {
2146
2146
  };
2147
2147
  };
2148
2148
 
2149
+ const sanitizeSeparateBatteryFlow = (flow) => {
2150
+ try {
2151
+ if (!flow || String(flow.src || '').indexOf('chargeDischarge') < 0) return flow;
2152
+ // In a normal AC-coupled house setup a storage discharge while the NVP is
2153
+ // exporting and no direct house-load meter is configured is almost always a
2154
+ // vendor-/alias-side ghost value (seen with some nexowatt-devices powerDischarge aliases).
2155
+ // Without a direct load meter this value would inflate the building load and
2156
+ // eat the PV budget. Keep true signed batteryPower authoritative, but guard
2157
+ // the separate charge/discharge pair.
2158
+ const hasDirectLoad = isMappedDatapoint('consumptionTotal') || isMappedDatapoint('housePower');
2159
+ if (hasDirectLoad) return flow;
2160
+ const grid = getGridImportExport((k) => state && state[k] ? state[k].value : undefined);
2161
+ const sellW = Math.max(0, Number(grid && grid.sell) || 0);
2162
+ const dischargeW = Math.max(0, Number(flow.dischargeW) || 0);
2163
+ const chargeW = Math.max(0, Number(flow.chargeW) || 0);
2164
+ const limitW = Math.max(250, deadbandW * 10);
2165
+ if (sellW > limitW && dischargeW > limitW && chargeW <= limitW) {
2166
+ return Object.assign({}, flow, {
2167
+ chargeW: 0,
2168
+ dischargeW: 0,
2169
+ signedW: 0,
2170
+ src: String(flow.src || 'chargeDischarge') + '+sanitized-export-discharge',
2171
+ rejectedDischargeW: Math.round(dischargeW),
2172
+ sanitized: true,
2173
+ });
2174
+ }
2175
+ } catch (_e) {}
2176
+ return flow;
2177
+ };
2178
+
2149
2179
  const sfEnabled = !!(state && state['storageFarm.enabled'] && state['storageFarm.enabled'].value);
2150
2180
  if (sfEnabled) {
2151
2181
  const fc = getFreshFlowNumber('storageFarm.totalChargePowerW');
@@ -2180,7 +2210,7 @@ function getNormalizedBatteryFlow() {
2180
2210
  if (c <= deadbandW) c = 0;
2181
2211
  if (d <= deadbandW) d = 0;
2182
2212
  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 });
2213
+ return preferBalanceDerivedBatteryFlow(sanitizeSeparateBatteryFlow({ chargeW: c, dischargeW: d, signedW: d - c, src: inv ? 'chargeDischarge(inv)' : 'chargeDischarge', inverted: inv }), { deadbandW });
2184
2214
  }
2185
2215
 
2186
2216
  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,10 +2689,15 @@ 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);
2694
2701
  return inp;
2695
2702
  }
2696
2703
 
@@ -7732,13 +7739,19 @@ function _collectFlowPowerDpIsWFromUI() {
7732
7739
  const socId = _nwGetAlias(stDev, 'r.soc');
7733
7740
 
7734
7741
  let storageMapped = false;
7735
- if (chargeId && dischargeId) {
7742
+ // Prefer the single signed battery power datapoint when it is available.
7743
+ // It is the safest source for the VIS/EMS balance (+ Entladen / - Laden).
7744
+ // Some devices expose split powerCharge/powerDischarge aliases that are
7745
+ // control/assist values rather than the real physical battery flow. Those
7746
+ // can make the house load and PV budget wrong, so use them only when no
7747
+ // signed datapoint exists.
7748
+ if (signedId) {
7749
+ if (_nwApplyFlowDpIfEmpty('batteryPower', signedId, { powerIsW: true })) out.changed = true;
7750
+ storageMapped = true;
7751
+ } else if (chargeId && dischargeId) {
7736
7752
  if (_nwApplyFlowDpIfEmpty('storageChargePower', chargeId, { powerIsW: true })) out.changed = true;
7737
7753
  if (_nwApplyFlowDpIfEmpty('storageDischargePower', dischargeId, { powerIsW: true })) out.changed = true;
7738
7754
  storageMapped = true;
7739
- } else if (signedId) {
7740
- if (_nwApplyFlowDpIfEmpty('batteryPower', signedId, { powerIsW: true })) out.changed = true;
7741
- storageMapped = true;
7742
7755
  }
7743
7756
  if (socId) {
7744
7757
  if (_nwApplyFlowDpIfEmpty('storageSoc', socId)) out.changed = true;
@@ -44,5 +44,5 @@
44
44
  "purpose": "maskable"
45
45
  }
46
46
  ],
47
- "version": "0.7.45"
47
+ "version": "0.7.46"
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-v214';
4
4
 
5
5
  const OFFLINE_URLS = [
6
6
  './',