iobroker.nexowatt-ui 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  NexoWatt EOS is the local platform for energy, charging and building control, including the responsive customer cockpit and installer workspace.
4
4
 
5
- **Current stable release:** `1.0.4` (2026-09-11)
5
+ **Current stable release:** `1.0.5` (2026-09-12)
6
6
 
7
7
  It provides live energy-flow visualization, historical analysis, SmartHome visualization, installer-controlled EMS applications, and selected customer controls for desktop, tablet, and smartphone use.
8
8
 
@@ -0,0 +1,101 @@
1
+ # NexoWatt EOS 1.0.5 – offizielle Stable-Version
2
+
3
+ **Datum:** 2026-09-12
4
+ **Basis:** vollständige Repository-ZIP 1.0.4
5
+
6
+ ## Gezielte Korrektur
7
+
8
+ Die Kundenwahl „Speicher schützen“ ist von der Messwertqualität getrennt. In Auto,
9
+ Boost und Min+PV wird eine unbekannte Fahrzeuglast nicht mehr als 0 W und damit als
10
+ Freigabe der Speicherentladung behandelt. Alte Wattwerte werden nicht als aktuelle
11
+ Messwerte fortgeschrieben; Sollwerte ersetzen keine gemessene Fahrzeugleistung.
12
+
13
+ Bei unbekannter geschützter Fahrzeuglast pausiert die gesamte Speicherentladung.
14
+ Der NVP allein erlaubt keine verlässliche Trennung von Hauslast und Fahrzeuglast.
15
+ Daher kann während dieser Störung auch der Hausverbrauch vorübergehend Netzbezug
16
+ verursachen. Das ist der beabsichtigte konservative Fehlerfall, keine Änderung der
17
+ Normalregelung. Echter Gesamtüberschuss nach Haus und Fahrzeug darf weiterhin in
18
+ den Speicher geladen werden. Speicherentladung wird nicht als PV interpretiert.
19
+
20
+ Nach Rückkehr gültiger Telemetrie ist ohne manuellen Reset wieder der bisherige
21
+ Hauslastausgleich aktiv. Frisch bestätigter Stillstand/Standby blockiert ihn nicht.
22
+ Ein Wechsel auf „Mitnutzen“ oder reines PV-Laden wird bei der nächsten vollständigen
23
+ Policy-Auswertung berücksichtigt; reines PV aktiviert weiterhin keinen Speicherschutz.
24
+ Die AppCenter-Bedienfreigabe bleibt eine Bedienfreigabe, keine neue Installateursperre.
25
+
26
+ ## Verteilung und Schutzpfade
27
+
28
+ Auto-PV-Priorität, Gebäudeverbrauch, Wallbox-Startminimum, Phasenwahl/-umschaltung,
29
+ Umschaltpausen, Tarif-/Ladezielfreigaben und bestehende Netz-/Stations-/§14a-Grenzen
30
+ bleiben unverändert. Im Normalbetrieb wird nur der frische geschützte Fahrzeuganteil
31
+ aus der zulässigen Speicherentladung entfernt. Unterhalb des technisch zulässigen
32
+ PV-Ladestarts bleibt ungenutzter Überschuss für den Speicher verfügbar.
33
+
34
+ Die Korrektur sitzt in der gemeinsamen EVCS-Speicher-Policy und der vorhandenen
35
+ asymmetrischen Speicherschranke vor den Ausgangspfaden. Die bestehenden Protokoll-Writer bleiben erhalten. Für E3/DC RSCP wird ein
36
+ 0-W-Stopp wegen unbekannter geschützter Fahrzeuglast ausdrücklich mit dem bereits
37
+ vorhandenen IDLE-Modus gesendet: NORMAL würde die lokale Eigenverbrauchsregelung
38
+ wieder freigeben. Diese Auswahl gilt nur für den betreffenden Störfallbefehl; die
39
+ gespeicherte Einstellung `e3dcZeroMode` und alle normalen Schreibpfade bleiben erhalten. Ein notwendiger Stopp
40
+ läuft über die vorhandene Zero-Write-Firewall und darf dort nicht gehalten werden.
41
+
42
+ ## Snapshot und Diagnose
43
+
44
+ Ein begrenzter JSON-Snapshot enthält Freigabeabsicht, aktuelle Wattwerte, Anzahl
45
+ unbekannter geschützter Ladepunkte und einen Zeitstempel. Er wird im bestehenden
46
+ Regeltakt veröffentlicht, ohne zusätzlichen Timer oder unbeschränkte Historie.
47
+ Bei unvollständigem Tick, abgelaufenem Snapshot oder Wiederanlauf werden alte Wattwerte
48
+ verworfen, eine bekannte Schutzanforderung aber konservativ beibehalten. Der nächste
49
+ vollständige gültige Snapshot ersetzt sie, einschließlich bewusster Modusänderungen.
50
+
51
+ Neue beziehungsweise ergänzte Diagnosewerte:
52
+
53
+ - `chargingManagement.control.storagePolicyJson`
54
+ - `chargingManagement.control.storageProtectionRequestedWallboxes`
55
+ - `chargingManagement.control.storageProtectedUnknownWallboxes`
56
+ - `chargingManagement.wallboxes.<Ladepunkt>.storagePolicyLoadUnknown`
57
+ - `speicher.regelung.evcsSpeicherSchutzLastUnbekannt`
58
+ - `speicher.regelung.evcsSpeicherSchutzUnbekannteWallboxen`
59
+ - vorhandene `evcsSpeicherSchutzAktion` / `evcsSpeicherSchutzJson`
60
+
61
+ ## Prüfgrenzen und Inbetriebnahme
62
+
63
+ Die automatisierten Tests verwenden simulierte ioBroker-Zustände und Schreibziele,
64
+ keine reale Kundenanlage. Vor Kundenfreigabe sind Schützen/Mitnutzen, ein kontrollierter
65
+ Telemetrieausfall mit laufender Ladung, Wiederkehr gültiger Werte sowie PV-Übergabe
66
+ an Fahrzeug und Speicher zu prüfen. Ein defekter oder unerreichbarer Speicherwriter
67
+ kann physische Vorgaben nicht garantieren; vorhandene Geräteschutz-/Watchdogkonzepte
68
+ bleiben erforderlich. Die Releasebezeichnung ist keine Hardware-Zertifizierung.
69
+
70
+ Eine frische Online-Abhängigkeitsinstallation (`npm ci`) scheiterte in der Prüfumgebung
71
+ an Registry-/DNS-Fehlern (`EAI_AGAIN`). Build/Tests verwenden lokal vorhandene Werkzeuge:
72
+ Node.js 22.16.0, TypeScript 5.8.3, Node-Typen 22.19.7. Der Lockfile verlangt Node-Typen
73
+ 22.19.21; eine frische Installation genau dieser Entwicklungsabhängigkeiten wird daher
74
+ nicht behauptet. Die Produktions- und Entwicklungsabhängigkeiten wurden nicht geändert.
75
+ Die npm-Versionsverfügbarkeit prüft weiterhin der bestehende Publish-Guard.
76
+
77
+ ## Testpflege ohne Änderung des Frontends
78
+
79
+ Zwei ältere Prüfskripte (`evcs-visual-online-state` und `evcs-online-id-depth`)
80
+ prüften noch veraltete Funktionssignaturen beziehungsweise Quelltextzeilen. Beide
81
+ schlugen auch im unveränderten 1.0.4-Repository fehl. Ihre Erwartungen entsprechen
82
+ jetzt dem bereits vorhandenen Online-/OCPP-Vertrag. Die Kachelprüfung führt zusätzlich
83
+ die echten Frontend-Hilfsfunktionen für Online, Leerlauf, Störung und veralteten Status
84
+ aus. Die produktive Online-Ermittlung und das Wallbox-Frontend wurden nicht geändert.
85
+
86
+ ## Automatisierte Freigabeprüfung
87
+
88
+ - TypeScript-Build, Typecheck, Runtime-Synchronität und vollständige `test:all`-Kette.
89
+ - Neuer Speicherschutztest: 87 Szenariogruppen und 960 deterministische Grenzfälle.
90
+ - Vorhandener 1.0.4-Test: 37 Szenariogruppen zur Auto-/PV-/Phasenregelung.
91
+ - Zusätzliche 57 Speicher-, EVCS- und PV-Prüfskripte, einschließlich beider aktualisierter Online-Verträge.
92
+ - 4.400 Vergleichsfälle gegen die unveränderte 1.0.4-Basis: bestehende Ergebnisfelder
93
+ der normalen Speicherpolicy und der asymmetrischen Leistungsgrenze unverändert.
94
+ - Drei untergeordnete Speicher-Writer bytegleich auf Methodenebene. Im Dispatcher
95
+ kommt ausschließlich die E3/DC-IDLE-Auswahl für den neuen Telemetrie-Stopp hinzu.
96
+ - Echte Modul-Ticks mit simulierten Lese-/Schreibdatenpunkten für signed/split,
97
+ Sungrow und E3/DC; keine reale Hardware angesteuert.
98
+
99
+ Paketmanifest, npm-Pakettrockenlauf und abschließende ZIP-Prüfung gehören zur
100
+ Freigabe. Die frisch entpackte Repository-ZIP wird erneut gebaut und vollständig
101
+ getestet. Build-Zwischenstände und lokale Abhängigkeiten sind nicht Teil der ZIP.
@@ -2,7 +2,7 @@
2
2
  * AUTO-GENERATED RUNTIME FILE - NICHT MANUELL BEARBEITEN.
3
3
  *
4
4
  * Quelle: src-ts/runtime-executables/ems/modules/charging-management.ts
5
- * Quell-Hash: sha256:545a9dc4df73467512fa8407e9446f7e5d20ba1aa2881e72b5783b9e02cd6429
5
+ * Quell-Hash: sha256:d7cc5fbbbf978980b9bd0807719a20d5a635df2a2a0f83ecdfe7f8303deabf4a
6
6
  * Erzeugung: npm run sync:ts-runtime-executables
7
7
  *
8
8
  * Zweck:
@@ -2556,15 +2556,24 @@ function resolveEvcsStoragePolicyActualLoad({
2556
2556
  activityThresholdW = 100,
2557
2557
  storageProtectionRequested = false,
2558
2558
  storageAssistRequested = false,
2559
+ physicalIdleConfirmed = false,
2559
2560
  } = {}) {
2560
- const actualW = Math.max(0, Math.abs(Number(actualPowerW) || 0));
2561
+ const actualValid = actualPowerW !== null && actualPowerW !== undefined
2562
+ && typeof actualPowerW !== 'boolean' && String(actualPowerW).trim() !== ''
2563
+ && Number.isFinite(Number(actualPowerW));
2564
+ const actualW = actualValid ? Math.max(0, Math.abs(Number(actualPowerW))) : 0;
2561
2565
  const thresholdW = Math.max(1, Number(activityThresholdW) || 100);
2562
2566
  const state = String(vehicleStateNormalized || 'unknown');
2563
2567
  const demandConfirmed = vehicleDemandConfirmed === true || state === 'charging';
2564
2568
  const operational = online === true && enabled === true;
2565
- const measurementUsable = operational && meterFresh === true;
2569
+ const measurementUsable = operational && meterFresh === true && actualValid;
2566
2570
  const assistRequested = storageAssistRequested === true;
2567
2571
  const protectionRequested = storageProtectionRequested === true && !assistRequested;
2572
+ // A missing measurement is not permission to discharge into the vehicle.
2573
+ // Never substitute an old reading or an unacknowledged charging command.
2574
+ // Only an independently confirmed physical idle reading may clear uncertainty
2575
+ // while the charging control itself is disabled/offline.
2576
+ const protectedLoadUnknown = protectionRequested && !measurementUsable && physicalIdleConfirmed !== true;
2568
2577
  const actualVehicleLoadW = measurementUsable && demandConfirmed && actualW >= thresholdW
2569
2578
  ? actualW
2570
2579
  : 0;
@@ -2573,6 +2582,7 @@ function resolveEvcsStoragePolicyActualLoad({
2573
2582
  if (protectionRequested || assistRequested) {
2574
2583
  if (!operational) reason = 'wallbox-not-operational';
2575
2584
  else if (!meterFresh) reason = 'meter-not-fresh';
2585
+ else if (!actualValid) reason = 'meter-invalid';
2576
2586
  else if (!demandConfirmed) reason = 'no-confirmed-vehicle-demand';
2577
2587
  else if (actualW < thresholdW) reason = 'standby-below-activity-threshold';
2578
2588
  else reason = assistRequested ? 'assist-actual-vehicle-load' : 'protect-actual-vehicle-load';
@@ -2587,6 +2597,8 @@ function resolveEvcsStoragePolicyActualLoad({
2587
2597
  demandConfirmed,
2588
2598
  vehicleStateNormalized: state,
2589
2599
  actualVehicleLoadW,
2600
+ protectionRequested,
2601
+ protectedLoadUnknown,
2590
2602
  protectedLoadW: protectionRequested ? actualVehicleLoadW : 0,
2591
2603
  assistRequestedLoadW: assistRequested ? actualVehicleLoadW : 0,
2592
2604
  protectedWallbox: protectionRequested && actualVehicleLoadW > 0,
@@ -5210,6 +5222,9 @@ class ChargingManagementModule extends BaseModule {
5210
5222
  await mk('chargingManagement.control.storageAssistPowerAgeMs', 'Stationary storage discharge value age (ms)', 'number', 'value.interval');
5211
5223
  await mk('chargingManagement.control.storageAssistPowerFresh', 'Stationary storage discharge value fresh', 'boolean', 'indicator');
5212
5224
  await mk('chargingManagement.control.storageProtectedLoadW', 'EVCS load protected from storage (W)', 'number', 'value.power');
5225
+ await mk('chargingManagement.control.storageProtectionRequestedWallboxes', 'Ladepunkte mit gewähltem Speicherschutz', 'number', 'value');
5226
+ await mk('chargingManagement.control.storageProtectedUnknownWallboxes', 'Geschützte Ladepunkte mit unbekannter Fahrzeuglast', 'number', 'value');
5227
+ await mk('chargingManagement.control.storagePolicyJson', 'Atomarer EVCS-Speicher-Policy-Snapshot', 'string', 'json');
5213
5228
  await mk('chargingManagement.control.storageProtectedWallboxes', 'EVCS wallboxes protected from storage', 'number', 'value');
5214
5229
  await mk('chargingManagement.control.storageProtectedLoadTs', 'EVCS storage-protection timestamp', 'number', 'value.time');
5215
5230
  await mk('chargingManagement.control.storageAssistRequestedLoadW', 'EVCS load allowed to use storage (W)', 'number', 'value.power');
@@ -5521,6 +5536,7 @@ class ChargingManagementModule extends BaseModule {
5521
5536
  await mk('storageProtectionRequested', 'Speicher-Schutz für Ladepunkt explizit aktiv', 'boolean', 'indicator');
5522
5537
  await mk('storagePolicyActualLoadW', 'Tatsächliche EV-Fahrzeuglast für Speicher-Policy (W)', 'number', 'value.power');
5523
5538
  await mk('storagePolicyActualLoadActive', 'Tatsächliche EV-Fahrzeuglast für Speicher-Policy aktiv', 'boolean', 'indicator');
5539
+ await mk('storagePolicyLoadUnknown', 'Speicherschutz: Fahrzeuglast unbekannt', 'boolean', 'indicator');
5524
5540
  await mk('storagePolicyActualLoadReason', 'Tatsächliche EV-Fahrzeuglast für Speicher-Policy Grund', 'string', 'text');
5525
5541
  await mk('effectiveStorageAssist', 'Speicher-Mitnutzung effektiv', 'boolean', 'indicator');
5526
5542
  await mk('storageAssistBlockedReason', 'Speicher-Mitnutzung Grund', 'string', 'text');
@@ -6043,7 +6059,7 @@ class ChargingManagementModule extends BaseModule {
6043
6059
  try {
6044
6060
  const caps = (this.adapter && this.adapter._emsCaps && typeof this.adapter._emsCaps === 'object') ? this.adapter._emsCaps : {};
6045
6061
  const prev = (caps.evcsStoragePolicy && typeof caps.evcsStoragePolicy === 'object') ? caps.evcsStoragePolicy : {};
6046
- this.adapter._emsCaps = { ...caps, evcsStoragePolicy: { ...prev, ...(patch || {}), ts: now } };
6062
+ this.adapter._emsCaps = { ...caps, evcsStoragePolicy: { ...prev, ...(patch || {}), ts: Number.isFinite(patch && patch.ts) ? patch.ts : now } };
6047
6063
  } catch { /* diagnostics only */ }
6048
6064
  };
6049
6065
 
@@ -6060,9 +6076,16 @@ class ChargingManagementModule extends BaseModule {
6060
6076
  storageSource: '',
6061
6077
  });
6062
6078
 
6063
- // Neutraler Tick-Start verhindert, dass ein früher Return alte Schutzlasten stehen lässt.
6064
- publishEvStoragePolicyCaps({ protectedLoadW: 0, protectedWallboxes: 0, assistRequestedLoadW: 0, source: 'charging-tick-reset' });
6079
+ // Do not publish a fresh 'no protection' verdict before reading the customer
6080
+ // choices. A failed/incomplete tick must discard old watts but retain the
6081
+ // protection intent conservatively until a complete snapshot replaces it.
6082
+ const pendingProtectedWallboxes = wallboxes.filter(w => w && w.storageAssistCustomerAllowed === true).length;
6083
+ publishEvStoragePolicyCaps({ protectedLoadW: 0, protectedWallboxes: 0,
6084
+ protectionRequestedWallboxes: pendingProtectedWallboxes,
6085
+ protectedUnknownWallboxes: pendingProtectedWallboxes, complete: false,
6086
+ assistRequestedLoadW: 0, source: 'charging-tick-reset' });
6065
6087
  let storageProtectedLoadW = 0, storageProtectedWallboxes = 0, storageAssistRequestedLoadW = 0;
6088
+ let storageProtectionRequestedWallboxes = 0, storageProtectedUnknownWallboxes = 0;
6066
6089
  try {
6067
6090
  await Promise.all([
6068
6091
  this._queueState('chargingManagement.control.storageProtectedLoadW', 0, true),
@@ -7319,7 +7342,8 @@ class ChargingManagementModule extends BaseModule {
7319
7342
  vehicleDemandReason = String(vehicleDemand.reason || '');
7320
7343
  const vehicleStateNormalized = String(vehicleDemand.state || 'unknown');
7321
7344
 
7322
- // Speicher-Schutz/Assist zaehlt nur frische, bestaetigte Fahrzeuglast.
7345
+ // Only measured vehicle watts are counted. Missing protected watts
7346
+ // are published separately as uncertainty, not as a fictitious 0-W load.
7323
7347
  // Wallbox-Eigenverbrauch unterhalb der Aktivitaetsschwelle (z. B. ABL
7324
7348
  // eMH1 mit rund 69 W im B2-Wartezustand) bleibt normale Gebaeudelast.
7325
7349
  const storagePolicyActualLoad = resolveEvcsStoragePolicyActualLoad({
@@ -7332,13 +7356,18 @@ class ChargingManagementModule extends BaseModule {
7332
7356
  activityThresholdW,
7333
7357
  storageProtectionRequested,
7334
7358
  storageAssistRequested,
7359
+ physicalIdleConfirmed: !meterStale && pWRawNum !== null
7360
+ && Math.abs(pWRawNum) < Math.max(1, activityThresholdW),
7335
7361
  });
7362
+ if (storagePolicyActualLoad.protectionRequested) storageProtectionRequestedWallboxes += 1;
7363
+ if (storagePolicyActualLoad.protectedLoadUnknown) storageProtectedUnknownWallboxes += 1;
7336
7364
  storageProtectedLoadW += storagePolicyActualLoad.protectedLoadW;
7337
7365
  storageAssistRequestedLoadW += storagePolicyActualLoad.assistRequestedLoadW;
7338
7366
  if (storagePolicyActualLoad.protectedWallbox) storageProtectedWallboxes += 1;
7339
7367
  try {
7340
7368
  await this._queueState(`${ch}.storagePolicyActualLoadW`, Math.round(storagePolicyActualLoad.actualVehicleLoadW), true);
7341
7369
  await this._queueState(`${ch}.storagePolicyActualLoadActive`, storagePolicyActualLoad.active === true, true);
7370
+ await this._queueState(`${ch}.storagePolicyLoadUnknown`, storagePolicyActualLoad.protectedLoadUnknown === true, true);
7342
7371
  await this._queueState(`${ch}.storagePolicyActualLoadReason`, String(storagePolicyActualLoad.reason || ''), true);
7343
7372
  } catch { /* diagnostics only */ }
7344
7373
 
@@ -7759,6 +7788,7 @@ class ChargingManagementModule extends BaseModule {
7759
7788
  storageProtectionRequested,
7760
7789
  storagePolicyActualLoadW: storagePolicyActualLoad.actualVehicleLoadW,
7761
7790
  storagePolicyActualLoadReason: storagePolicyActualLoad.reason,
7791
+ storagePolicyLoadUnknown: storagePolicyActualLoad.protectedLoadUnknown,
7762
7792
  effectiveStorageAssist: false,
7763
7793
  storageAssistBlockedReason: storageAssistCustomerAllowed ? (userStorageAssistEnabled ? 'pending' : 'user-disabled') : 'installer-locked',
7764
7794
  batteryContributionW: 0,
@@ -9630,7 +9660,22 @@ if (components.length) {
9630
9660
  }
9631
9661
 
9632
9662
  // Finaler Same-cycle Stand; persistente States darunter bleiben Diagnose/Fallback.
9633
- publishEvStoragePolicyCaps({ protectedLoadW: Math.max(0, Math.round(Number(storageProtectedLoadW || 0))), protectedWallboxes: Math.max(0, Math.round(Number(storageProtectedWallboxes || 0))), assistRequestedLoadW: Math.max(0, Math.round(Number(storageAssistRequestedLoadW || 0))), source: 'charging-runtime' });
9663
+ const completedStoragePolicy = {
9664
+ protectedLoadW: Math.max(0, Math.round(Number(storageProtectedLoadW || 0))),
9665
+ protectedWallboxes: Math.max(0, Math.round(Number(storageProtectedWallboxes || 0))),
9666
+ protectionRequestedWallboxes: storageProtectionRequestedWallboxes,
9667
+ protectedUnknownWallboxes: storageProtectedUnknownWallboxes,
9668
+ assistRequestedLoadW: Math.max(0, Math.round(Number(storageAssistRequestedLoadW || 0))),
9669
+ complete: true, source: 'charging-runtime', sampledAt: now, ts: Date.now(),
9670
+ };
9671
+ publishEvStoragePolicyCaps(completedStoragePolicy);
9672
+ // One bounded snapshot, no history or new timer. Its embedded timestamp
9673
+ // cannot turn old watts into fresh measurements after adapter restart.
9674
+ try {
9675
+ await this._queueState('chargingManagement.control.storagePolicyJson', JSON.stringify(completedStoragePolicy), true);
9676
+ await this._queueState('chargingManagement.control.storageProtectionRequestedWallboxes', storageProtectionRequestedWallboxes, true);
9677
+ await this._queueState('chargingManagement.control.storageProtectedUnknownWallboxes', storageProtectedUnknownWallboxes, true);
9678
+ } catch { /* runtime snapshot remains authoritative if diagnostic persistence fails */ }
9634
9679
 
9635
9680
  // Publish diagnostics for UI. `storageAssistW` bleibt der Request an die
9636
9681
  // Speicherregelung; nur `storageAssistAcceptedW` darf das Ladebudget erhoehen.
@@ -2,7 +2,7 @@
2
2
  * AUTO-GENERATED RUNTIME FILE - NICHT MANUELL BEARBEITEN.
3
3
  *
4
4
  * Quelle: src-ts/runtime-executables/ems/modules/storage-control.ts
5
- * Quell-Hash: sha256:0a33ac9b0fc7e7d2d9ca0fab4f5005ae577c54079a99e1e31eadcac7b104b61a
5
+ * Quell-Hash: sha256:3be0c12bc621b62c036d8a58836824d114aa8a85fe2dededf64593e9fac11b82
6
6
  * Erzeugung: npm run sync:ts-runtime-executables
7
7
  *
8
8
  * Zweck:
@@ -455,11 +455,51 @@ function applyStorageLicensePowerLimit(targetW, profile = {}) {
455
455
  * Dadurch kann der Speicher weiterhin den Hausverbrauch ausgleichen, versorgt aber
456
456
  * weder die geschuetzte E-Mobilitaet noch laedt er parallel aus dem Netz.
457
457
  */
458
+ /**
459
+ * A policy's watts expire; a customer's protection request does not expire with
460
+ * them. Fresh, completed snapshots (including a deliberate mode change) replace
461
+ * the old intent. No old EV reading is ever held as a current physical load.
462
+ */
463
+ function resolveEvcsStorageProtectionSnapshot(policy, options = {}) {
464
+ const count = value => Math.max(0, Number.isFinite(Number(value)) ? Math.floor(Number(value)) : 0);
465
+ const watts = value => Math.max(0, Number.isFinite(Number(value)) ? Number(value) : 0);
466
+ const record = policy && typeof policy === 'object' && !Array.isArray(policy) ? policy : null;
467
+ const now = Number.isFinite(Number(options.now)) ? Number(options.now) : Date.now();
468
+ const maxAgeMs = Math.max(1000, Number(options.maxAgeMs) || 5000);
469
+ const ts = Number(record && record.ts);
470
+ const validNonNegative = value => value !== null && value !== undefined
471
+ && typeof value !== 'boolean' && String(value).trim() !== ''
472
+ && Number.isFinite(Number(value)) && Number(value) >= 0;
473
+ const payloadValid = !!record && validNonNegative(record.protectedLoadW)
474
+ && validNonNegative(record.protectedWallboxes)
475
+ && (record.protectedUnknownWallboxes === undefined || validNonNegative(record.protectedUnknownWallboxes));
476
+ const fresh = payloadValid && Number.isFinite(ts) && ts > 0 && ts <= now
477
+ && now - ts <= maxAgeMs && record.complete !== false;
478
+ const protectedWallboxes = count(record && record.protectedWallboxes);
479
+ const protectedLoadW = watts(record && record.protectedLoadW);
480
+ const unknown = count(record && record.protectedUnknownWallboxes);
481
+ const requested = Math.max(count(record && record.protectionRequestedWallboxes),
482
+ protectedWallboxes, unknown, protectedLoadW > 0 ? 1 : 0,
483
+ (!record || !payloadValid || (!fresh && !validNonNegative(record.protectionRequestedWallboxes)))
484
+ ? count(options.configuredCandidates) : 0);
485
+ return {
486
+ protectedLoadW: fresh ? protectedLoadW : 0,
487
+ protectedWallboxes: fresh ? protectedWallboxes : 0,
488
+ protectionRequestedWallboxes: requested,
489
+ protectedUnknownWallboxes: fresh ? unknown : requested,
490
+ protectedLoadUnknown: (fresh ? unknown : requested) > 0,
491
+ assistRequestedLoadW: fresh ? watts(record.assistRequestedLoadW) : 0,
492
+ fresh,
493
+ source: String(record && record.source || 'state-fallback') + (fresh || !requested ? '' : '-unconfirmed'),
494
+ };
495
+ }
496
+
458
497
  function resolveEvcsProtectedStorageTarget(input = {}) {
459
498
  const finite = (v) => v !== null && v !== undefined && v !== '' && Number.isFinite(Number(v));
460
499
  const requestedW = finite(input.requestedTargetW) ? Number(input.requestedTargetW) : 0;
461
500
  const lastTargetW = finite(input.lastTargetW) ? Number(input.lastTargetW) : 0;
462
501
  const protectedLoadW = Math.max(0, finite(input.protectedEvcsLoadW) ? Number(input.protectedEvcsLoadW) : 0);
502
+ const protectedLoadUnknown = input.protectedLoadUnknown === true;
463
503
  const nvpW = finite(input.nvpW) ? Number(input.nvpW) : null;
464
504
  const targetNvpW = finite(input.targetNvpW) ? Number(input.targetNvpW) : 0;
465
505
  const storageActualKnown = finite(input.storageActualW);
@@ -472,13 +512,14 @@ function resolveEvcsProtectedStorageTarget(input = {}) {
472
512
  const actualChargeActive = storageActualKnown && storageActualW < -activeThresholdW;
473
513
  const actualDischargeActive = storageActualKnown && storageActualW > activeThresholdW;
474
514
 
475
- if (protectedLoadW <= 0) {
515
+ if (protectedLoadW <= 0 && !protectedLoadUnknown) {
476
516
  return {
477
517
  active: false,
478
518
  requestedW,
479
519
  targetW: requestedW,
480
520
  lastTargetW,
481
521
  protectedLoadW: 0,
522
+ protectedLoadUnknown,
482
523
  nvpW,
483
524
  targetNvpW,
484
525
  storageActualW: storageActualKnown ? storageActualW : null,
@@ -500,13 +541,14 @@ function resolveEvcsProtectedStorageTarget(input = {}) {
500
541
  }
501
542
 
502
543
  if (nvpW === null) {
503
- const explicitStop = lastTargetW !== 0 || actualChargeActive || actualDischargeActive;
544
+ const explicitStop = protectedLoadUnknown || lastTargetW !== 0 || actualChargeActive || actualDischargeActive;
504
545
  return {
505
546
  active: true,
506
547
  requestedW,
507
548
  targetW: null,
508
549
  lastTargetW,
509
550
  protectedLoadW,
551
+ protectedLoadUnknown,
510
552
  nvpW: null,
511
553
  targetNvpW,
512
554
  storageActualW: storageActualKnown ? storageActualW : null,
@@ -543,9 +585,11 @@ function resolveEvcsProtectedStorageTarget(input = {}) {
543
585
  ? storageActualW
544
586
  : (storageDischargeBasisKnown ? storageDischargeBasisW : 0);
545
587
  const totalDesiredW = chargeBasisStorageW + nvpW - targetNvpW;
546
- const houseDesiredW = dischargeBasisStorageW + nvpW - targetNvpW - protectedLoadW;
588
+ const houseDesiredW = protectedLoadUnknown ? null : dischargeBasisStorageW + nvpW - targetNvpW - protectedLoadW;
547
589
  const chargeAllowanceW = Math.max(0, -totalDesiredW);
548
- const dischargeAllowanceW = Math.max(0, houseDesiredW);
590
+ // With unknown EV load, NVP cannot distinguish house from protected vehicle.
591
+ // Pause discharge; real net surplus may still charge the storage.
592
+ const dischargeAllowanceW = protectedLoadUnknown ? 0 : Math.max(0, houseDesiredW);
549
593
  const actionThresholdW = activeThresholdW;
550
594
 
551
595
  let targetW = requestedW;
@@ -614,8 +658,18 @@ function resolveEvcsProtectedStorageTarget(input = {}) {
614
658
  else action = 'idle-no-active-command';
615
659
  }
616
660
 
661
+ if (protectedLoadUnknown && targetW === 0) {
662
+ // A zero stop must pass the existing no-write/hold firewall, including
663
+ // vendor self-control with no remembered EOS command after a restart.
664
+ dischargeStop = true;
665
+ action = 'stop-discharge-evcs-load-unknown';
666
+ }
617
667
  const explicitStop = chargeStop || dischargeStop;
618
- const reason = chargeStop
668
+ const reason = protectedLoadUnknown
669
+ ? (targetW < 0
670
+ ? 'EVCS-Speicherschutz: Fahrzeuglast unbekannt – nur echten Gesamtueberschuss laden'
671
+ : 'EVCS-Speicherschutz: Fahrzeuglast unbekannt – Entladung voruebergehend gesperrt')
672
+ : chargeStop
619
673
  ? 'EVCS-Speicherschutz: Laden stoppen – kein tatsaechlicher Gesamtueberschuss am NVP'
620
674
  : (dischargeStop
621
675
  ? 'EVCS-Speicherschutz: Entladen stoppen – nur geschuetzte E-Mobilitaet verursacht den Bedarf'
@@ -631,6 +685,7 @@ function resolveEvcsProtectedStorageTarget(input = {}) {
631
685
  targetW,
632
686
  lastTargetW,
633
687
  protectedLoadW,
688
+ protectedLoadUnknown,
634
689
  nvpW,
635
690
  targetNvpW,
636
691
  storageActualW: storageActualKnown ? storageActualW : null,
@@ -2533,19 +2588,39 @@ class SpeicherRegelungModule extends BaseModule {
2533
2588
  const protectedEvcsMaxAgeMs = Math.max(1000, Math.min(15000, num(cfg.evcsStoragePolicyMaxAgeMs, 5000)));
2534
2589
  const sharedCaps = (this.adapter && this.adapter._emsCaps && typeof this.adapter._emsCaps === 'object') ? this.adapter._emsCaps : null;
2535
2590
  const runtimeEvcsStoragePolicy = (sharedCaps && sharedCaps.evcsStoragePolicy && typeof sharedCaps.evcsStoragePolicy === 'object') ? sharedCaps.evcsStoragePolicy : null;
2536
- const runtimePolicyTs = Number(runtimeEvcsStoragePolicy && runtimeEvcsStoragePolicy.ts);
2537
- const runtimePolicyFresh = !!(runtimeEvcsStoragePolicy && runtimePolicyTs > 0 && (now - runtimePolicyTs) <= protectedEvcsMaxAgeMs);
2538
- // Same-cycle Snapshot verhindert, dass ein alter asynchroner Schutz-State noch einen Tick blockiert.
2539
- const policyValue = async (key, stateId) => runtimePolicyFresh
2540
- ? runtimeEvcsStoragePolicy[key]
2541
- : this._readOwnNumberFresh(stateId, protectedEvcsMaxAgeMs);
2542
- const protectedRaw = await policyValue('protectedLoadW', 'chargingManagement.control.storageProtectedLoadW');
2543
- const protectedBoxesRaw = await policyValue('protectedWallboxes', 'chargingManagement.control.storageProtectedWallboxes');
2544
- const assistRaw = await policyValue('assistRequestedLoadW', 'chargingManagement.control.storageAssistRequestedLoadW');
2545
- const evcsStorageProtectedLoadW = Math.max(0, Number(protectedRaw) || 0);
2546
- const evcsStorageProtectedWallboxes = Math.max(0, Math.round(Number(protectedBoxesRaw) || 0));
2547
- const evcsStorageAssistRequestedLoadW = Math.max(0, Number(assistRaw) || 0);
2548
- const evcsStoragePolicySource = runtimePolicyFresh ? String(runtimeEvcsStoragePolicy.source || 'ems-runtime') : 'state-fallback';
2591
+ let protectionSnapshot = runtimeEvcsStoragePolicy;
2592
+ if (!protectionSnapshot) {
2593
+ try {
2594
+ const json = await this._readOwnString('chargingManagement.control.storagePolicyJson');
2595
+ const parsed = json ? JSON.parse(json) : null;
2596
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) protectionSnapshot = parsed;
2597
+ } catch { /* malformed persisted diagnostics are not fresh policy */ }
2598
+ if (!protectionSnapshot) {
2599
+ // Compatibility for 1.0.4 installations: timestamp belongs to the
2600
+ // load sample, not to a later read/heartbeat of this state.
2601
+ const oldLoad = await this.adapter.getStateAsync('chargingManagement.control.storageProtectedLoadW').catch(() => null);
2602
+ if (oldLoad) protectionSnapshot = {
2603
+ protectedLoadW: oldLoad.val,
2604
+ protectedWallboxes: await this._readOwnNumber('chargingManagement.control.storageProtectedWallboxes'),
2605
+ assistRequestedLoadW: await this._readOwnNumberFresh('chargingManagement.control.storageAssistRequestedLoadW', protectedEvcsMaxAgeMs),
2606
+ ts: oldLoad.ts, source: 'state-fallback',
2607
+ };
2608
+ }
2609
+ }
2610
+ const configuredWallboxes = this.adapter.config.chargingManagement && this.adapter.config.chargingManagement.wallboxes;
2611
+ const policySnapshot = resolveEvcsStorageProtectionSnapshot(protectionSnapshot, {
2612
+ // State reads may await I/O while a newer policy completes. Compare
2613
+ // against read-time, not an older storage-tick start timestamp.
2614
+ now: Date.now(), maxAgeMs: protectedEvcsMaxAgeMs,
2615
+ configuredCandidates: Array.isArray(configuredWallboxes)
2616
+ ? configuredWallboxes.filter(w => w && w.storageAssistCustomerAllowed === true).length : 0,
2617
+ });
2618
+ const evcsStorageProtectedLoadW = policySnapshot.protectedLoadW;
2619
+ const evcsStorageProtectedWallboxes = policySnapshot.protectedWallboxes;
2620
+ const evcsStorageProtectedLoadUnknown = policySnapshot.protectedLoadUnknown;
2621
+ const evcsStorageProtectedUnknownWallboxes = policySnapshot.protectedUnknownWallboxes;
2622
+ const evcsStorageAssistRequestedLoadW = policySnapshot.assistRequestedLoadW;
2623
+ const evcsStoragePolicySource = policySnapshot.source;
2549
2624
  // Seit Baustein 7 wird die EVCS-Leistung nicht mehr als symmetrischer
2550
2625
  // NVP-Zieloffset verwendet. Ein solcher Offset erlaubte bei Teildeckung der
2551
2626
  // Wallbox faelschlich Speicherladung aus dem Netz. Die Schutzwirkung wird
@@ -2558,6 +2633,8 @@ class SpeicherRegelungModule extends BaseModule {
2558
2633
  await this._setIfChanged('speicher.regelung.evcsSpeicherMitnutzungLastW', Math.round(evcsStorageAssistRequestedLoadW));
2559
2634
  await this._setIfChanged('speicher.regelung.evcsSpeicherSchutzNvpZielOffsetW', Math.round(evcsStorageProtectedNvpTargetShiftW));
2560
2635
  await this._setIfChanged('speicher.regelung.evcsSpeicherSchutzQuelle', evcsStoragePolicySource);
2636
+ await this._setIfChanged('speicher.regelung.evcsSpeicherSchutzLastUnbekannt', evcsStorageProtectedLoadUnknown);
2637
+ await this._setIfChanged('speicher.regelung.evcsSpeicherSchutzUnbekannteWallboxen', evcsStorageProtectedUnknownWallboxes);
2561
2638
 
2562
2639
  const stripProtectedEvcsLoadW = (w) => Math.max(0, Math.max(0, Number(w) || 0) - evcsStorageProtectedLoadW);
2563
2640
 
@@ -5048,7 +5125,7 @@ const _prevRampW = (typeof this._lastTargetW === 'number' && Number.isFinite(thi
5048
5125
  // - Laden nur aus dem tatsaechlichen Gesamtueberschuss nach Haus UND EVCS.
5049
5126
  // Die Schranke liegt nach allen Herstellerprofilen, damit Sungrow, FENECON,
5050
5127
  // E3/DC, Signed-/Split-DP und Farm exakt dieselbe physikalische Regel erhalten.
5051
- if (evcsStorageProtectedLoadW > 0) {
5128
+ if (evcsStorageProtectedLoadW > 0 || evcsStorageProtectedLoadUnknown) {
5052
5129
  const lastActiveTargetW = Number.isFinite(Number(this._lastTargetW))
5053
5130
  ? Number(this._lastTargetW)
5054
5131
  : 0;
@@ -5142,6 +5219,7 @@ const _prevRampW = (typeof this._lastTargetW === 'number' && Number.isFinite(thi
5142
5219
  requestedTargetW: requestedBeforeProtectionW,
5143
5220
  lastTargetW: lastActiveTargetW,
5144
5221
  protectedEvcsLoadW: evcsStorageProtectedLoadW,
5222
+ protectedLoadUnknown: evcsStorageProtectedLoadUnknown,
5145
5223
  nvpW: protectionNvpW,
5146
5224
  targetNvpW: protectionTargetNvpW,
5147
5225
  storageActualW: protectionStorageActualW,
@@ -5156,6 +5234,10 @@ const _prevRampW = (typeof this._lastTargetW === 'number' && Number.isFinite(thi
5156
5234
  evcsProtectedChargeStop = evcsProtectionDiag.chargeStop === true;
5157
5235
  evcsProtectedDischargeStop = evcsProtectionDiag.dischargeStop === true;
5158
5236
  evcsProtectionChargeFromSurplus = evcsProtectionDiag.chargeFromSurplus === true;
5237
+ if (evcsStorageProtectedLoadUnknown) {
5238
+ dischargeDemandHardCapW = 0;
5239
+ dischargeDemandHardCapReason = 'EVCS-Speicherschutz: Fahrzeuglast unbekannt';
5240
+ }
5159
5241
 
5160
5242
  if (targetW < 0) {
5161
5243
  // Unter Speicherschutz ist jede verbleibende Beladung physikalisch
@@ -5206,11 +5288,12 @@ const _prevRampW = (typeof this._lastTargetW === 'number' && Number.isFinite(thi
5206
5288
  }
5207
5289
  }
5208
5290
 
5209
- await this._setIfChanged('speicher.regelung.evcsSpeicherSchutzAktiv', evcsStorageProtectedLoadW > 0);
5291
+ await this._setIfChanged('speicher.regelung.evcsSpeicherSchutzAktiv', evcsStorageProtectedLoadW > 0 || evcsStorageProtectedLoadUnknown);
5210
5292
  await this._setIfChanged('speicher.regelung.evcsSpeicherSchutzAktion', evcsProtectionDiag ? String(evcsProtectionDiag.action || '') : 'inactive');
5211
5293
  await this._setIfChanged('speicher.regelung.evcsSpeicherSchutzJson', JSON.stringify(evcsProtectionDiag || {
5212
5294
  active: false,
5213
5295
  protectedLoadW: Math.round(evcsStorageProtectedLoadW || 0),
5296
+ protectedLoadUnknown: evcsStorageProtectedLoadUnknown,
5214
5297
  targetW: Number(targetW) || 0,
5215
5298
  }));
5216
5299
 
@@ -5541,7 +5624,9 @@ const _prevRampW = (typeof this._lastTargetW === 'number' && Number.isFinite(thi
5541
5624
  : (evcsProtectedChargeStop
5542
5625
  ? 'Laden stoppen: EVCS-Speicherschutz – kein tatsaechlicher Gesamtueberschuss am NVP'
5543
5626
  : (evcsProtectedDischargeStop
5544
- ? 'Entladen stoppen: EVCS-Speicherschutz – nur geschuetzte E-Mobilitaet verursacht den Bedarf'
5627
+ ? (evcsStorageProtectedLoadUnknown
5628
+ ? 'Entladen stoppen: EVCS-Speicherschutz – Fahrzeuglast unbekannt'
5629
+ : 'Entladen stoppen: EVCS-Speicherschutz – nur geschuetzte E-Mobilitaet verursacht den Bedarf')
5545
5630
  : (dischargeSocStop
5546
5631
  ? `Entladen stoppen: SoC <= ${Math.max(hardDischargeMinSoc, selfMinSoc)}%`
5547
5632
  : (chargeSocStop
@@ -6164,6 +6249,8 @@ const _prevRampW = (typeof this._lastTargetW === 'number' && Number.isFinite(thi
6164
6249
  storageAssistReqW: (typeof evcsAssistReqW === 'number' && Number.isFinite(evcsAssistReqW)) ? Math.round(evcsAssistReqW) : 0,
6165
6250
  storageProtectedLoadW: Math.round(evcsStorageProtectedLoadW || 0),
6166
6251
  storageProtectedWallboxes: Math.round(evcsStorageProtectedWallboxes || 0),
6252
+ storageProtectedLoadUnknown: evcsStorageProtectedLoadUnknown,
6253
+ storageProtectedUnknownWallboxes: evcsStorageProtectedUnknownWallboxes,
6167
6254
  storageAssistRequestedLoadW: Math.round(evcsStorageAssistRequestedLoadW || 0),
6168
6255
  nvpTargetOffsetW: 0,
6169
6256
  protection: evcsProtectionDiag,
@@ -6423,7 +6510,7 @@ const _prevRampW = (typeof this._lastTargetW === 'number' && Number.isFinite(thi
6423
6510
  : (storageZeroWriteStatus || (sungrowNoWrite ? 'sungrow-hybrid:no-write' : 'storage:no-write'));
6424
6511
  await this._setHoldNoWriteTargetDiag(targetW, reason, source, noWriteStatus);
6425
6512
  } else {
6426
- await this._applyTargetW(targetW, reason, source, { evcsAssistReqW });
6513
+ await this._applyTargetW(targetW, reason, source, { evcsAssistReqW, evcsProtectedLoadUnknown: evcsStorageProtectedLoadUnknown });
6427
6514
  if (feneconHybridActive) this._feneconHybridWasExternal = true;
6428
6515
  }
6429
6516
 
@@ -9737,7 +9824,12 @@ const _prevRampW = (typeof this._lastTargetW === 'number' && Number.isFinite(thi
9737
9824
  };
9738
9825
  }
9739
9826
  } else if (controlMode === 'targetPower' && commandFamily === 'e3dc-rscp') {
9740
- const e3dcResult = await this._writeE3dcRscpTargetW(w, reason, source, cfg);
9827
+ // A telemetry-protection stop is a battery pause, not release to
9828
+ // native self-consumption. Use the existing IDLE mode for this
9829
+ // one command only; the configured default/normal paths stay intact.
9830
+ const e3dcCommandCfg = w === 0 && options.evcsProtectedLoadUnknown === true
9831
+ ? { ...cfg, e3dcZeroMode: 'idle' } : cfg;
9832
+ const e3dcResult = await this._writeE3dcRscpTargetW(w, reason, source, e3dcCommandCfg);
9741
9833
  primarySucceeded = !!(e3dcResult && e3dcResult.ok === true);
9742
9834
  primaryWroteAny = true;
9743
9835
  writeResult = primarySucceeded;
@@ -10401,6 +10493,8 @@ const _prevRampW = (typeof this._lastTargetW === 'number' && Number.isFinite(thi
10401
10493
  await mk('speicher.regelung.evcsSpeicherMitnutzungLastW', 'EVCS-Leistung mit Speicher-Mitnutzung (W)', 'number', 'value.power', 0);
10402
10494
  await mk('speicher.regelung.evcsSpeicherSchutzNvpZielOffsetW', 'Legacy NVP-Zieloffset durch EVCS-Speicher-Schutz (W, ab 0.8.133 immer 0)', 'number', 'value.power', 0);
10403
10495
  await mk('speicher.regelung.evcsSpeicherSchutzAktiv', 'Asymmetrischer EVCS-Speicherschutz aktiv', 'boolean', 'indicator', false);
10496
+ await mk('speicher.regelung.evcsSpeicherSchutzLastUnbekannt', 'Speicherschutz: Fahrzeuglast unbekannt, Entladung gesperrt', 'boolean', 'indicator', false);
10497
+ await mk('speicher.regelung.evcsSpeicherSchutzUnbekannteWallboxen', 'Geschützte Ladepunkte mit unbekannter Fahrzeuglast', 'number', 'value', 0);
10404
10498
  await mk('speicher.regelung.evcsSpeicherSchutzAktion', 'Asymmetrischer EVCS-Speicherschutz Aktion', 'string', 'text', '');
10405
10499
  await mk('speicher.regelung.evcsSpeicherSchutzJson', 'Asymmetrischer EVCS-Speicherschutz Diagnose', 'string', 'json', '');
10406
10500
  await mk('speicher.regelung.evcsSpeicherSchutzQuelle', 'Quelle der EVCS-Speicher-Policy', 'string', 'text', '');
@@ -10603,6 +10697,7 @@ function clamp(n, min, max) {
10603
10697
  module.exports = {
10604
10698
  SpeicherRegelungModule,
10605
10699
  resolveEvcsProtectedStorageTarget,
10700
+ resolveEvcsStorageProtectionSnapshot,
10606
10701
  resolveStorageAntiExportTarget,
10607
10702
  resolveStorageLicenseEdition,
10608
10703
  deriveStorageRatedPowerW,
package/io-package.json CHANGED
@@ -1,8 +1,13 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "nexowatt-ui",
4
- "version": "1.0.4",
4
+ "version": "1.0.5",
5
5
  "news": {
6
+ "1.0.5": {
7
+ "de": "Speicher schützen bleibt bei veralteter oder fehlender Wallbox-Telemetrie wirksam. Entladung pausiert bei unbekannter Fahrzeuglast; echter PV-Überschuss darf weiterhin laden. Frische Messwerte stellen die normale Regelung automatisch wieder her. Auto-PV-Priorität, Phasenlogik und Mitnutzung bleiben erhalten.",
8
+ "en": "Keep EV storage protection when wallbox telemetry is missing or stale. Pause discharge for unknown protected EV load while allowing real net-surplus charging. Restore normal control on fresh telemetry; retain Auto PV priority, phases and storage assistance.",
9
+ "nl": "Accubescherming blijft actief bij ontbrekende of verouderde laadpaalgegevens. Ontladen pauzeert bij onbekend voertuigverbruik; werkelijk PV-overschot kan blijven laden. Normale regeling hervat met geldige gegevens."
10
+ },
6
11
  "1.0.4": {
7
12
  "en": "Auto PV priority respects approved charging demand, actual phases and technical start power. Unusable PV remains available to storage. Per-point phase switch thresholds, manufacturer values and settling are preserved.",
8
13
  "de": "PV-Priorisierung berücksichtigt Auto-Ladebedarf, tatsächliche Phasen und Startleistung. Nicht nutzbarer PV-Anteil bleibt beim Speicher. Individuelle Phasenumschaltwerte, Wartezeiten und Einschwingzeit werden durchgängig berücksichtigt.",
@@ -32,11 +37,6 @@
32
37
  "de": "RC92 behebt ausschließlich die mobile Bedienung der Historienseite. Vertikales Scrollen bleibt auf Hauptchart, KPI-Karten und Preis-Chart nativ verfügbar; ein kurzer Tap zeigt auf Smartphones nun dieselben Leistungs- beziehungsweise Energiewerte wie am Desktop. Woche, Monat und Jahr zeigen pro ausgewähltem Balken kWh-Werte, die Tagesansicht kW-Werte. Tooltips bleiben nach dem Scrollen vollständig im sichtbaren Viewport, horizontales Tages-Zoomen bleibt erhalten und Canvas-Neuzeichnungen werden gebündelt. EMS-, NVP-, Lade-, Speicher-, Tarif-, §14a- und Hardware-Regelung bleiben unverändert.",
33
38
  "en": "RC92 fixes only the mobile interaction of the History page. Vertical scrolling remains native on the main chart, KPI cards and price chart; a short tap on smartphones now shows the same power or energy values as on desktop. Week, month and year show kWh values for the selected bar, while the day view shows kW values. Tooltips remain fully visible after scrolling, horizontal day zoom is preserved and canvas redraws are coalesced. EMS, grid, charging, storage, tariff, Section 14a and hardware control remain unchanged.",
34
39
  "nl": "RC92 corrigeert uitsluitend de mobiele bediening van de historiepagina. Verticaal scrollen blijft native op de hoofdgrafiek, KPI-kaarten en prijsgrafiek; een korte tik op smartphones toont nu dezelfde vermogens- of energiewaarden als op desktop. Week, maand en jaar tonen kWh-waarden voor de gekozen balk, de dagweergave toont kW-waarden. Tooltips blijven na scrollen volledig zichtbaar, horizontale dagzoom blijft behouden en canvas-hertekeningen worden gebundeld. EMS-, net-, laad-, opslag-, tarief-, §14a- en hardwarebesturing blijven ongewijzigd."
35
- },
36
- "0.8.216": {
37
- "de": "RC91 gleicht die App-Kataloge von Browser, Adapterstart, Installer, Save und Backup vollständig ab. Energy Ledger und Mesh/Microgrid behalten ihre Installiert-/Aktiv-Zustände jetzt auch beim Speichern anderer AppCenter-Reiter; das verborgene DC-Stationsdisplay bleibt erhalten, ohne doppelte App-Karte. Zusätzlich bleibt die textstabil erzeugte main.js strikt JavaScript-kompatibel. Die produktive NVP-, Lade-, Speicher-, Tarif-, §14a- und Safety-Regelung wurde nicht verändert.",
38
- "en": "RC91 fully aligns the app catalogues used by the browser, adapter startup, installer, save and backup paths. Energy Ledger and Mesh/Microgrid now preserve their installed/enabled state when unrelated App Center tabs are saved; the hidden DC station display is retained without creating a duplicate app card. The text-stable generated main.js is also kept strictly JavaScript-compatible. Productive grid, charging, storage, tariff, Section 14a and safety control logic is unchanged.",
39
- "nl": "RC91 brengt de appcatalogi van browser, adapterstart, installer, opslaan en back-up volledig met elkaar in overeenstemming. Energy Ledger en Mesh/Microgrid behouden nu hun geïnstalleerde/actieve status wanneer andere AppCenter-tabbladen worden opgeslagen; het verborgen DC-stationsdisplay blijft behouden zonder dubbele appkaart. Ook blijft de tekststabiel gegenereerde main.js strikt JavaScript-compatibel. De productieve net-, laad-, opslag-, tarief-, §14a- en veiligheidsregeling is niet gewijzigd."
40
40
  }
41
41
  },
42
42
  "title": "NexoWatt EOS",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.nexowatt-ui",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "NexoWatt EOS – local energy, charging and building control platform.",
5
5
  "author": "NexoWatt",
6
6
  "license": "UNLICENSED",
@@ -27,7 +27,7 @@
27
27
  "ioBroker:check": "node scripts/verify-publish.js",
28
28
  "typecheck": "tsc -p tsconfig.json --noEmit",
29
29
  "test:types": "npm run check:tsconfig-modern && npm run check:ts-source-syntax && npm run check:ts-source-integrity && npm run check:ts-canonical && npm run verify:ts-scaffold && npm run test:ts-script-mirrors && npm run test:ts-frontend-mirrors && npm run test:ts-backend-mirrors && npm run test:ts-adapter-mirrors && npm run test:frontend-mirror-runtime && npm run test:api-state-feature && npm run test:api-state-feature-runtime && npm run test:backend-api-state && npm run test:energy-flow-utils && npm run test:energy-flow-resolver && npm run test:energy-flow-mirrors && npm run test:energy-flow-regression && npm run test:energy-flow-regression-runtime && npm run test:ems-budget-heating-rod && npm run test:ems-budget-heating-rod-runtime && npm run test:ems-mirrors && npm run test:core-limits-reservations && npm run test:adapter-state-api && npm run test:adapter-state-api-runtime && npm run test:adapter-mirrors && npm run test:backend-api-state && npm run test:backend-api-state-runtime && npm run test:feature-visibility-resolver && npm run test:feature-visibility-resolver-runtime && npm run test:feature-visibility-shadow && npm run test:feature-visibility-shadow-runtime && npm run test:frontend-display && npm run test:feature-visibility-resolver && npm run test:feature-visibility-resolver-runtime && npm run test:feature-visibility-shadow && npm run test:feature-visibility-shadow-runtime && npm run test:frontend-display-runtime && npm run test:customer-feature-visibility && npm run test:customer-feature-visibility-runtime && npm run test:main-helpers && npm run typecheck && npm run typecheck:runtime-mirrors && npm run test:runtime-mirrors && npm run test:core-limits-runtime-typing && npm run test:heating-rod-runtime-typing && npm run test:shadow-bridges && npm run test:contracts && npm run test:feature-visibility-effective-runtime && npm run test:ai-advisor-runtime-typing && npm run test:history-runtime-typing && npm run test:smarthome-runtime-typing && npm run test:smarthome-config-runtime-typing && npm run test:ems-apps-runtime-typing && npm run test:app-runtime-typing && npm run test:main-runtime-typing && npm run test:adapter-helpers-mirrors && npm run test:main-runtime-helpers && npm run test:api-state-set-shadow && npm run test:live-dashboard-format-productive && npm run test:heating-rod-legacy-removal-candidate",
30
- "test:all": "npm run publish:check && npm run test:types && npm run check:ts-source-syntax && npm run test:ems-shadow-runtime && npm run test:ai-advisor-runtime-typing && npm run test:history-runtime-typing && npm run test:smarthome-runtime-typing && npm run test:smarthome-config-runtime-typing && npm run test:ems-apps-runtime-typing && npm run test:app-runtime-typing && npm run test:main-runtime-typing && npm run test:rc57-ocpp-stability && npm run test:rc58-ocpp-compact-mapping && npm run test:rc59-ocpp21-native-storage-safety && npm run test:rc60-universal-auto-orchestrator && npm run test:rc60-universal-auto-wallbox && npm run test:rc61-heating-night-lock && npm run test:rc61-evcs-hardening && npm run test:rc63-availability-storage-grid-gate && npm run test:rc64-storage-grid-charge-policy && npm run test:rc65-nt-price-target-override && npm run test:dc-station-display && npm run test:rc66-station-display-stable && npm run test:rc66-station-display-browser && npm run test:rc67-license-bootstrap-access && npm run test:rc68-para14a-communication-fallback && npm run test:dashboard-lp-status-typing && npm run test:rc69-dashboard-lp-feedback && npm run test:rc70-dashboard-lp-status-polish && npm run test:rc72-weather-pv-forecast-auto && npm run test:rc73-ems-admin-overview && npm run test:rc74-pv-forecast-customer-ui && npm run test:rc75-pv-forecast-admin-location && npm run test:rc76-pv-forecast-runtime-hardening && npm run test:rc77-pv-forecast-state-cache-bridge && npm run test:rc78-import-only-grid-budget && npm run test:rc79-import-soft-hard-zero-export && npm run test:rc80-soft-limit-fixed-ten-percent && npm run test:rc81-nvp-assignment-single-source && npm run test:rc82-permanent-grid-protection && npm run test:rc83-storage-cheap-only-log-object && npm run test:rc85 && npm run test:rc86 && npm run test:rc87 && npm run test:rc88 && npm run test:rc89 && npm run test:rc90 && npm run test:rc91 && npm run test:rc92 && npm run test:rc93 && npm run test:stable-1.0.2-health && npm run test:stable-1.0.3-home-appcenter && npm run test:stable-1.0.4-auto-pv && npm run test:stable-release",
30
+ "test:all": "npm run publish:check && npm run test:types && npm run check:ts-source-syntax && npm run test:ems-shadow-runtime && npm run test:ai-advisor-runtime-typing && npm run test:history-runtime-typing && npm run test:smarthome-runtime-typing && npm run test:smarthome-config-runtime-typing && npm run test:ems-apps-runtime-typing && npm run test:app-runtime-typing && npm run test:main-runtime-typing && npm run test:rc57-ocpp-stability && npm run test:rc58-ocpp-compact-mapping && npm run test:rc59-ocpp21-native-storage-safety && npm run test:rc60-universal-auto-orchestrator && npm run test:rc60-universal-auto-wallbox && npm run test:rc61-heating-night-lock && npm run test:rc61-evcs-hardening && npm run test:rc63-availability-storage-grid-gate && npm run test:rc64-storage-grid-charge-policy && npm run test:rc65-nt-price-target-override && npm run test:dc-station-display && npm run test:rc66-station-display-stable && npm run test:rc66-station-display-browser && npm run test:rc67-license-bootstrap-access && npm run test:rc68-para14a-communication-fallback && npm run test:dashboard-lp-status-typing && npm run test:rc69-dashboard-lp-feedback && npm run test:rc70-dashboard-lp-status-polish && npm run test:rc72-weather-pv-forecast-auto && npm run test:rc73-ems-admin-overview && npm run test:rc74-pv-forecast-customer-ui && npm run test:rc75-pv-forecast-admin-location && npm run test:rc76-pv-forecast-runtime-hardening && npm run test:rc77-pv-forecast-state-cache-bridge && npm run test:rc78-import-only-grid-budget && npm run test:rc79-import-soft-hard-zero-export && npm run test:rc80-soft-limit-fixed-ten-percent && npm run test:rc81-nvp-assignment-single-source && npm run test:rc82-permanent-grid-protection && npm run test:rc83-storage-cheap-only-log-object && npm run test:rc85 && npm run test:rc86 && npm run test:rc87 && npm run test:rc88 && npm run test:rc89 && npm run test:rc90 && npm run test:rc91 && npm run test:rc92 && npm run test:rc93 && npm run test:stable-1.0.2-health && npm run test:stable-1.0.3-home-appcenter && npm run test:stable-1.0.4-auto-pv && npm run test:stable-1.0.5-storage-protection && npm run test:stable-release",
31
31
  "release:check": "npm run test:all && npm run build:ts && npm run publish:check && npm run test:package-runtime-start-smoke && npm run test:package",
32
32
  "ci:check": "npm run test:all && npm run build:ts && npm pack --dry-run",
33
33
  "typecheck:contracts": "tsc -p tsconfig.contracts.json --noEmit",
@@ -482,7 +482,8 @@
482
482
  "test:stable-release": "node scripts/verify-stable-release.cjs",
483
483
  "test:stable-1.0.2-health": "node scripts/verify-stable-1.0.2-health-heartbeat.cjs",
484
484
  "test:stable-1.0.3-home-appcenter": "node scripts/verify-stable-1.0.3-home-appcenter-access.cjs",
485
- "test:stable-1.0.4-auto-pv": "node scripts/verify-stable-1.0.4-auto-pv-phases.cjs"
485
+ "test:stable-1.0.4-auto-pv": "node scripts/verify-stable-1.0.4-auto-pv-phases.cjs",
486
+ "test:stable-1.0.5-storage-protection": "node scripts/verify-stable-1.0.5-storage-protection-telemetry.cjs"
486
487
  },
487
488
  "dependencies": {
488
489
  "@iobroker/adapter-core": "^3.4.1",
@@ -828,7 +829,9 @@
828
829
  "www/year-report.js",
829
830
  "docs/STABLE_1_0_4_RELEASE_DE.md",
830
831
  "scripts/verify-stable-1.0.4-auto-pv-phases.cjs",
831
- "scripts/verify-rc60-universal-auto-wallbox.js"
832
+ "scripts/verify-rc60-universal-auto-wallbox.js",
833
+ "scripts/verify-stable-1.0.5-storage-protection-telemetry.cjs",
834
+ "docs/STABLE_1_0_5_RELEASE_DE.md"
832
835
  ],
833
836
  "devDependencies": {
834
837
  "@iobroker/adapter-dev": "^1.5.0",
@@ -0,0 +1,284 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ // Software-only regression. Real policy, charging tick, storage tick and output
4
+ // planner, using simulated ioBroker states and device writes. No hardware access.
5
+ const assert = require('node:assert/strict');
6
+ const {
7
+ resolveEvcsStoragePolicy, resolveEvcsStoragePolicyActualLoad, resolveEvcsEffectivePower,
8
+ } = require('../ems/modules/charging-management');
9
+ const {
10
+ SpeicherRegelungModule, resolveEvcsProtectedStorageTarget, resolveEvcsStorageProtectionSnapshot,
11
+ } = require('../ems/modules/storage-control');
12
+ const { makeHarness } = require('./verify-rc60-universal-auto-wallbox');
13
+ const { decideStorageZeroWrite } = require('../ems/services/storage-zero-write-policy');
14
+ let scenarios = 0;
15
+ const actualBase = { actualPowerW: 4500, meterFresh: true, online: true, enabled: true,
16
+ vehicleDemandConfirmed: true, vehicleStateNormalized: 'charging', activityThresholdW: 200 };
17
+ const protect = resolveEvcsStoragePolicy(true, false, 'auto');
18
+ const reading = (patch = {}, policy = protect) => resolveEvcsStoragePolicyActualLoad({
19
+ ...actualBase, storageProtectionRequested: policy.protectionRequested,
20
+ storageAssistRequested: policy.assistRequested, ...patch,
21
+ });
22
+ const snapshotFrom = rows => ({ ts: Date.now(), complete: true, source: 'charging-runtime',
23
+ protectedLoadW: rows.reduce((v, r) => v + r.protectedLoadW, 0),
24
+ protectedWallboxes: rows.filter(r => r.protectedWallbox).length,
25
+ protectedUnknownWallboxes: rows.filter(r => r.protectedLoadUnknown).length,
26
+ protectionRequestedWallboxes: rows.filter(r => r.protectionRequested).length,
27
+ assistRequestedLoadW: rows.reduce((v, r) => v + r.assistRequestedLoadW, 0),
28
+ });
29
+ const target = patch => resolveEvcsProtectedStorageTarget({
30
+ requestedTargetW: 6450, lastTargetW: 1950, nvpW: 4550, targetNvpW: 50,
31
+ storageActualW: 1950, protectedEvcsLoadW: 0, protectedLoadUnknown: true,
32
+ deadbandW: 50, ...patch,
33
+ });
34
+
35
+ for (const mode of ['auto', 'boost', 'minpv', 'pv']) {
36
+ for (const allowed of [false, true]) for (const assist of [false, true]) {
37
+ const policy = resolveEvcsStoragePolicy(allowed, assist, mode);
38
+ const fresh = reading({}, policy);
39
+ const stale = reading({ meterFresh: false }, policy);
40
+ assert.equal(fresh.protectedLoadW, policy.protectionRequested ? 4500 : 0);
41
+ assert.equal(fresh.protectedLoadUnknown, false);
42
+ assert.equal(stale.protectedLoadW, 0, 'old watts are not fresh physical load');
43
+ assert.equal(stale.protectedLoadUnknown, policy.protectionRequested);
44
+ assert.equal(stale.assistRequestedLoadW, 0, 'stale data must not fabricate assist');
45
+ scenarios++;
46
+ }
47
+ }
48
+ for (const patch of [{ meterFresh: false }, { online: false }, { enabled: false },
49
+ { actualPowerW: NaN }, { actualPowerW: null }, { actualPowerW: '' }, { actualPowerW: Infinity }]) {
50
+ assert.equal(reading(patch).protectedLoadUnknown, true);
51
+ scenarios++;
52
+ }
53
+ for (const power of [0, 69, 199]) {
54
+ const idle = reading({ actualPowerW: power, vehicleStateNormalized: 'ready_to_charge' });
55
+ assert.equal(idle.protectedLoadW, 0);
56
+ assert.equal(idle.protectedLoadUnknown, false, 'fresh standby must not interrupt house supply');
57
+ scenarios++;
58
+ }
59
+ assert.equal(reading({ online: false, meterFresh: false, physicalIdleConfirmed: true }).protectedLoadUnknown, false);
60
+ scenarios++;
61
+
62
+ const time = 100000;
63
+ for (const badTs of [time - 5001, time + 1, 0, null, NaN]) {
64
+ const old = resolveEvcsStorageProtectionSnapshot({ ...snapshotFrom([reading()]), ts: badTs }, { now: time });
65
+ assert.equal(old.protectedLoadW, 0);
66
+ assert.equal(old.protectedLoadUnknown, true, 'expired/future/invalid timestamp must not lift protection');
67
+ scenarios++;
68
+ }
69
+ const pending = resolveEvcsStorageProtectionSnapshot({ ts: time, complete: false, protectionRequestedWallboxes: 1 }, { now: time });
70
+ assert.equal(pending.protectedLoadUnknown, true);
71
+ const missing = resolveEvcsStorageProtectionSnapshot(null, { now: time, configuredCandidates: 1 });
72
+ assert.equal(missing.protectedLoadUnknown, true);
73
+ for (const corrupt of [{}, { ts: time, protectedLoadW: 'invalid', protectedWallboxes: 0 },
74
+ { ts: time, protectedLoadW: null, protectedWallboxes: 0 },
75
+ { ts: time, protectedLoadW: 0, protectedWallboxes: 0, protectedUnknownWallboxes: 'invalid', protectionRequestedWallboxes: 1 }]) {
76
+ assert.equal(resolveEvcsStorageProtectionSnapshot(corrupt, { now: time, configuredCandidates: 1 }).protectedLoadUnknown, true);
77
+ scenarios++;
78
+ }
79
+ const recovered = resolveEvcsStorageProtectionSnapshot(snapshotFrom([reading()]), { now: Date.now() });
80
+ assert.equal(recovered.protectedLoadW, 4500);
81
+ assert.equal(recovered.protectedLoadUnknown, false);
82
+ const changed = resolveEvcsStorageProtectionSnapshot({ ...snapshotFrom([]), ts: time }, { now: time });
83
+ assert.equal(changed.protectedLoadUnknown, false, 'explicit fresh mode change releases protection');
84
+ scenarios += 4;
85
+
86
+ for (const requestedTargetW of [0, 1500, 6450, -2500]) {
87
+ const result = target({ requestedTargetW });
88
+ assert.equal(result.targetW, 0, 'no storage discharge/grid charging while protected EV load unknown');
89
+ assert.equal(result.dischargeAllowanceW, 0);
90
+ assert.equal(result.houseDesiredW, null, 'unknown household split must not be presented as measured');
91
+ assert.equal(result.explicitStop, true);
92
+ const zero = decideStorageZeroWrite({ targetW: result.targetW, lastTargetW: 1950,
93
+ explicitStop: result.explicitStop, reason: result.reason, nvpW: 4550, nvpTargetW: 50, nvpDeadbandW: 50 });
94
+ assert.equal(zero.action, 'write-stop', 'no-write firewall may not hold an old discharge');
95
+ scenarios++;
96
+ }
97
+ assert.equal(target({ nvpW: -2500, storageActualW: 0, requestedTargetW: -2000, lastTargetW: 0 }).targetW, -2000);
98
+ assert.equal(target({ nvpW: 50, storageActualW: -2000, requestedTargetW: -2000, lastTargetW: -2000 }).targetW, -2000,
99
+ 'existing physical PV charge must remain stable');
100
+ assert.equal(target({ nvpW: -1950, storageActualW: 1950, requestedTargetW: -2000 }).targetW, 0,
101
+ 'export manufactured by storage discharge is not chargeable PV');
102
+ scenarios += 3;
103
+
104
+ // Deterministic property grid: all combinations are bounded, no accidental
105
+ // discharge, and charge can never exceed total physical surplus.
106
+ let properties = 0;
107
+ for (const nvpW of [-12000, -3000, -50, 0, 50, 2500, 6500, 30000]) {
108
+ for (const storageActualW of [-8000, -1950, 0, 1950, 8000, null]) {
109
+ for (const lastTargetW of [-8000, 0, 1950, 8000]) {
110
+ for (const requestedTargetW of [-10000, -500, 0, 500, 10000]) {
111
+ const out = target({ nvpW, storageActualW, lastTargetW, requestedTargetW });
112
+ assert(out.targetW <= 0);
113
+ if (out.targetW < 0) assert(-out.targetW <= out.chargeAllowanceW + 1e-8);
114
+ properties++;
115
+ }
116
+ }
117
+ }
118
+ }
119
+
120
+ // OCPP's existing event-driven contract is retained: session/connector evidence
121
+ // may validate an unchanged meter value; offline is NOT a physical stop proof.
122
+ const held = resolveEvcsEffectivePower({ telemetryProfile: 'ocpp-1.6-event-driven', rawPowerW: 4500,
123
+ rawMeterStale: true, online: true, enabled: true, transactionKnown: true, transactionActive: true,
124
+ normalizedState: 'charging', statusAuthoritative: true });
125
+ assert.equal(held.effectiveMeterStale, false);
126
+ assert.equal(reading({ actualPowerW: held.effectivePowerW, meterFresh: !held.effectiveMeterStale }).protectedLoadW, 4500);
127
+ const ended = resolveEvcsEffectivePower({ telemetryProfile: 'ocpp-1.6-event-driven', rawPowerW: 4500,
128
+ rawMeterStale: true, online: true, enabled: true, transactionKnown: true, transactionActive: false,
129
+ normalizedState: 'finishing', statusAuthoritative: true });
130
+ assert.equal(reading({ actualPowerW: ended.effectivePowerW, meterFresh: !ended.effectiveMeterStale,
131
+ vehicleDemandConfirmed: false, vehicleStateNormalized: 'finishing' }).protectedLoadUnknown, false);
132
+ scenarios += 2;
133
+
134
+ class FakeDp {
135
+ constructor(entries) { this.entries = entries; this.writes = []; }
136
+ getEntry(key) { return this.entries[key] || null; }
137
+ getAgeMs(key) { const r = this.getEntry(key); return r ? Date.now() - r.ts : null; }
138
+ getNumber(key, fallback = null) { const r = this.getEntry(key); return r && Number.isFinite(Number(r.val)) ? Number(r.val) : fallback; }
139
+ getNumberFresh(key, age, fallback = null) { return this.getAgeMs(key) > age ? fallback : this.getNumber(key, fallback); }
140
+ getBoolean(key, fallback = false) { const r = this.getEntry(key); return r ? r.val === true : fallback; }
141
+ async writeNumber(key, value) { this.writes.push({ key, value }); return true; }
142
+ async writeBoolean(key, value) { this.writes.push({ key, value }); return true; }
143
+ }
144
+ async function storageTick({ policy, persistedPolicy, legacyPolicy, gridW = 6500, batteryW = 0,
145
+ lastTargetW = 0, profile = 'generic', configuredCandidates = 0 } = {}) {
146
+ const now = Date.now();
147
+ const entry = (val, id) => ({ val, objectId: id, ts: now });
148
+ const entries = { 'grid.powerW': entry(gridW, 'grid.filtered'), 'grid.powerRawW': entry(gridW, 'grid.raw'),
149
+ 'st.socPct': entry(80, 'battery.soc'), 'st.batteryPowerW': entry(batteryW, 'battery.actual') };
150
+ if (profile === 'generic') entries['st.targetPowerW'] = entry(0, 'battery.target');
151
+ else if (profile === 'e3dc') {
152
+ entries['st.e3dcSetPowerMode'] = entry(0, 'e3dc.0.EMS.SET_POWER_MODE');
153
+ entries['st.e3dcSetPowerValueW'] = entry(0, 'e3dc.0.EMS.SET_POWER_VALUE');
154
+ } else {
155
+ entries['st.targetChargePowerW'] = entry(0, 'battery.charge');
156
+ entries['st.targetDischargePowerW'] = entry(0, 'battery.discharge');
157
+ entries['st.run'] = entry(false, 'battery.run');
158
+ entries['st.dcPvPowerW'] = entry(Math.max(0, -gridW), 'pv.dc');
159
+ }
160
+ const dp = new FakeDp(entries);
161
+ const states = new Map();
162
+ if (persistedPolicy) states.set('chargingManagement.control.storagePolicyJson', entry(JSON.stringify(persistedPolicy), 'policy'));
163
+ if (legacyPolicy) states.set('chargingManagement.control.storageProtectedLoadW', { val: 4500, ts: now - 6000 });
164
+ const adapter = {
165
+ config: { enableStorageControl: true, enableStorageFarm: false, enableMultiUse: false,
166
+ enablePeakShaving: false, enableGridConstraints: false,
167
+ chargingManagement: { wallboxes: Array.from({ length: configuredCandidates }, () => ({ storageAssistCustomerAllowed: true })) },
168
+ storage: { controlMode: 'targetPower',
169
+ vendorProfile: profile === 'sungrow' ? 'sungrow-hybrid' : profile === 'e3dc' ? 'e3dc-rscp' : 'generic',
170
+ e3dcZeroMode: 'normal',
171
+ coupling: profile === 'sungrow' ? 'dc' : 'ac',
172
+ staleTimeoutSec: 15, maxDeltaWPerTick: 10000, pvMaxDeltaWPerTick: 10000,
173
+ stepW: 1, pvEnabled: true, pvExportThresholdW: 50, selfTargetGridImportW: 50,
174
+ selfImportThresholdW: 50, selfMinSocPct: 20, selfMaxSocPct: 100 } },
175
+ _emsCaps: policy ? { evcsStoragePolicy: policy } : {}, stateCache: {},
176
+ log: { warn() {}, info() {}, debug() {}, error() {} },
177
+ async setObjectNotExistsAsync() {},
178
+ async setStateAsync(id, val) { states.set(id, { val, ts: Date.now() }); },
179
+ async getStateAsync(id) { return states.get(id) || null; },
180
+ _nwGetNumberFromCache() { return null; },
181
+ };
182
+ const mod = new SpeicherRegelungModule(adapter, dp);
183
+ mod._lastTargetW = lastTargetW;
184
+ mod._lastSource = lastTargetW < 0 ? 'pv' : 'eigenverbrauch';
185
+ await mod.tick();
186
+ const diag = JSON.parse(states.get('speicher.regelung.evcsSpeicherSchutzJson')?.val || '{}');
187
+ return { diag, writes: dp.writes, states, configuredZeroMode: adapter.config.storage.e3dcZeroMode,
188
+ signed: dp.writes.filter(w => w.key === 'st.targetPowerW').at(-1)?.value,
189
+ splitDischarge: dp.writes.filter(w => w.key === 'st.targetDischargePowerW').at(-1)?.value };
190
+ }
191
+
192
+ async function main() {
193
+ let out = await storageTick({ policy: snapshotFrom([reading()]) });
194
+ assert.equal(out.signed, 1950, 'fresh: only 2kW house minus 50W grid target');
195
+ scenarios++;
196
+ const unknown = snapshotFrom([reading({ meterFresh: false })]);
197
+ for (const context of [
198
+ { policy: unknown },
199
+ { policy: unknown, batteryW: 1950, gridW: 4550, lastTargetW: 1950 },
200
+ { policy: { ...snapshotFrom([reading()]), ts: Date.now() - 20000 } },
201
+ { persistedPolicy: unknown },
202
+ { persistedPolicy: { ...snapshotFrom([reading()]), ts: Date.now() - 60000 } },
203
+ { legacyPolicy: true },
204
+ { configuredCandidates: 1 },
205
+ { policy: snapshotFrom([reading(), reading({ meterFresh: false })]) },
206
+ ]) {
207
+ out = await storageTick(context);
208
+ assert.equal(out.signed, 0, JSON.stringify({ context, diag: out.diag, writes: out.writes }));
209
+ assert.equal(out.diag.protectedLoadUnknown, true);
210
+ assert.equal(out.states.get('speicher.regelung.evcsSpeicherSchutzLastUnbekannt')?.val, true);
211
+ scenarios++;
212
+ }
213
+ for (const profile of ['generic', 'split', 'sungrow']) {
214
+ out = await storageTick({ policy: unknown, profile, lastTargetW: 1950, batteryW: 1950, gridW: 4550 });
215
+ assert.equal(profile === 'generic' ? out.signed : out.splitDischarge, 0, JSON.stringify(out.writes));
216
+ out = await storageTick({ policy: unknown, profile, gridW: -2500 });
217
+ assert(out.diag.targetW < 0, JSON.stringify(out.diag));
218
+ assert(out.writes.every(w => w.key !== 'st.targetDischargePowerW' || w.value <= 0));
219
+ scenarios += 2;
220
+ }
221
+ // E3/DC NORMAL releases control to its own self-consumption logic. An
222
+ // unknown-protected-load stop must instead use the existing IDLE=1 command,
223
+ // without changing the installer's normal zero-mode preference permanently.
224
+ out = await storageTick({ policy: unknown, profile: 'e3dc', gridW: 4550, batteryW: 1950, lastTargetW: 1950 });
225
+ assert.equal(out.writes.filter(w => w.key === 'st.e3dcSetPowerMode').at(-1)?.value, 1);
226
+ assert.equal(out.writes.filter(w => w.key === 'st.e3dcSetPowerValueW').at(-1)?.value, 0);
227
+ assert.equal(out.configuredZeroMode, 'normal');
228
+ out = await storageTick({ policy: unknown, profile: 'e3dc', gridW: -2500 });
229
+ assert.equal(out.writes.filter(w => w.key === 'st.e3dcSetPowerMode').at(-1)?.value, 3);
230
+ assert(out.writes.filter(w => w.key === 'st.e3dcSetPowerValueW').at(-1)?.value > 0);
231
+ out = await storageTick({ policy: snapshotFrom([reading()]), profile: 'e3dc' });
232
+ assert.equal(out.writes.filter(w => w.key === 'st.e3dcSetPowerMode').at(-1)?.value, 2);
233
+ assert.equal(out.writes.filter(w => w.key === 'st.e3dcSetPowerValueW').at(-1)?.value, 1950);
234
+ scenarios += 3;
235
+ out = await storageTick({ policy: snapshotFrom([reading()]), persistedPolicy: unknown });
236
+ assert.equal(out.signed, 1950, 'fresh runtime supersedes an old persisted unknown state');
237
+ out = await storageTick({ policy: snapshotFrom([reading({}, resolveEvcsStoragePolicy(true, true, 'auto'))]) });
238
+ assert.equal(out.signed, 6450, 'assist stays normal storage self-consumption');
239
+ out = await storageTick({ policy: snapshotFrom([reading({ actualPowerW: 69 })]), gridW: 2069 });
240
+ assert.equal(out.signed, 2019, 'fresh idle does not block house supply');
241
+ scenarios += 3;
242
+
243
+ // Full live charging -> same-cycle policy -> storage output, then recovery and
244
+ // deliberate mode change. Enable real final allocation/phase/executor methods.
245
+ for (const mode of ['auto', 'boost', 'minpv', 'pv']) {
246
+ const h = makeHarness({ userMode: mode, actualPowerW: 4500, status: 'C2', vehicleConnected: true,
247
+ chargeDemand: true, gridAllowed: true, wallbox: { storageAssistCustomerAllowed: true } });
248
+ try {
249
+ delete h.module._publishChargingAllocationTsShadow;
250
+ delete h.module._publishChargingPhaseSelectionRuntimeStates;
251
+ delete h.module._publishChargingStationDiagnosticsFromAllocationPlan;
252
+ await h.tick();
253
+ assert.equal(h.adapter._emsCaps.evcsStoragePolicy.protectedLoadW, mode === 'pv' ? 0 : 4500);
254
+ h.setObject(h.wallbox.dataFreshId, false);
255
+ h.setObject(h.wallbox.actualPowerWId, 4500, Date.now() - 360000);
256
+ await h.tick();
257
+ const stale = h.adapter._emsCaps.evcsStoragePolicy;
258
+ assert.equal(stale.protectedUnknownWallboxes, mode === 'pv' ? 0 : 1);
259
+ if (mode !== 'pv') {
260
+ out = await storageTick({ policy: stale });
261
+ assert.equal(out.signed, 0);
262
+ }
263
+ h.setObject(h.wallbox.dataFreshId, true);
264
+ h.setObject(h.wallbox.actualPowerWId, 4500);
265
+ await h.tick();
266
+ assert.equal(h.adapter._emsCaps.evcsStoragePolicy.protectedUnknownWallboxes, 0);
267
+ h.setLocal('chargingManagement.wallboxes.lp1.userStorageAssistEnabled', true);
268
+ await h.tick();
269
+ assert.equal(h.adapter._emsCaps.evcsStoragePolicy.protectionRequestedWallboxes, 0);
270
+ scenarios += 4;
271
+ } finally { h.stop(); }
272
+ }
273
+ const interrupted = makeHarness({ wallbox: { storageAssistCustomerAllowed: true } });
274
+ try {
275
+ interrupted.module._ensureWallboxChannel = async () => { throw Error('simulated state read failure'); };
276
+ await assert.rejects(interrupted.tick(), /simulated state read failure/);
277
+ assert.equal(interrupted.adapter._emsCaps.evcsStoragePolicy.complete, false);
278
+ out = await storageTick({ policy: interrupted.adapter._emsCaps.evcsStoragePolicy });
279
+ assert.equal(out.signed, 0, 'incomplete tick may not publish a false protection release');
280
+ scenarios++;
281
+ } finally { interrupted.stop(); }
282
+ console.log(`[stable-1.0.5-storage-protection-telemetry] OK: ${scenarios} scenario groups + ${properties} deterministic bound checks; fresh/stale/recovery, modes, OCPP, persisted policy and real charging/storage ticks.`);
283
+ }
284
+ main().catch(error => { console.error(error.stack || error); process.exitCode = 1; });
@@ -48,6 +48,7 @@ for (const required of [
48
48
  'scripts/verify-stable-1.0.2-health-heartbeat.cjs',
49
49
  'scripts/verify-stable-1.0.3-home-appcenter-access.cjs',
50
50
  'scripts/verify-stable-1.0.4-auto-pv-phases.cjs',
51
+ 'scripts/verify-stable-1.0.5-storage-protection-telemetry.cjs',
51
52
  'scripts/verify-rc60-universal-auto-wallbox.js',
52
53
  ]) {
53
54
  if (!files.includes(required)) fail(`Stable-Paketdatei fehlt in package.json files: ${required}`);
@@ -111,7 +112,7 @@ for (const relativePath of ['src-ts/runtime-executables/www/ems-apps.ts', 'src-t
111
112
  }
112
113
  for (const relativePath of ['src-ts/runtime-executables/www/sw.ts', 'src-ts/runtime-mirrors/www/sw.ts', 'www/sw.js']) {
113
114
  const text = read(relativePath);
114
- if (!text.includes("const CACHE_NAME = 'nexowatt-cache-v504';")) fail(`PWA-Cache-Bump fehlt in ${relativePath}.`);
115
+ if (!text.includes("const CACHE_NAME = 'nexowatt-cache-v505';")) fail(`PWA-Cache-Bump fehlt in ${relativePath}.`);
115
116
  }
116
117
 
117
118
 
@@ -221,9 +222,19 @@ if (/versionParts\[0\]\s*!==\s*0/.test(rc66Verifier)) {
221
222
  fail('RC66-Prüfer enthält noch eine auf 0.8.x fest verdrahtete Major-Version.');
222
223
  }
223
224
 
224
- console.log(`[stable-release] OK: ${pkg.name}@${version} ist konsistent als Official Stable versiegelt.`);
225
- console.log('[stable-release] OK: 1.0.3-Home-AppCenter-Auth, 1.0.2-Liveness, 1.0.1-Memory/SSE und RC93-Regelungsbaseline sind synchron.');
226
225
 
227
226
  if (!String(pkg.scripts?.['test:all'] || '').includes('npm run test:stable-1.0.4-auto-pv')) {
228
227
  fail('Auto-PV-/Phasenregression ist nicht Bestandteil von test:all.');
229
228
  }
229
+
230
+ // 1.0.5 must remain part of every full release validation.
231
+ if (pkg.scripts?.['test:stable-1.0.5-storage-protection'] !== 'node scripts/verify-stable-1.0.5-storage-protection-telemetry.cjs'
232
+ || !String(pkg.scripts?.['test:all'] || '').includes('npm run test:stable-1.0.5-storage-protection')) {
233
+ fail('1.0.5-Speicherschutz-Regression fehlt in der Freigabekette.');
234
+ }
235
+ for (const token of ['protectedLoadUnknown', 'resolveEvcsStorageProtectionSnapshot', 'stop-discharge-evcs-load-unknown']) {
236
+ if (!read('src-ts/runtime-executables/ems/modules/storage-control.ts').includes(token)) fail(`1.0.5-Speicherschutz fehlt: ${token}`);
237
+ }
238
+
239
+ console.log(`[stable-release] OK: ${pkg.name}@${version} ist konsistent als Official Stable versiegelt.`);
240
+ console.log('[stable-release] OK: 1.0.5-Speicherschutz, 1.0.4-Auto/PV/Phasen und bisherige Home-/Liveness-/Memory-/Regelungsregressionen sind eingebunden.');
@@ -44,6 +44,6 @@
44
44
  "purpose": "maskable"
45
45
  }
46
46
  ],
47
- "version": "1.0.4",
48
- "appVersion": "1.0.4"
47
+ "version": "1.0.5",
48
+ "appVersion": "1.0.5"
49
49
  }
package/www/sw.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * AUTO-GENERATED RUNTIME FILE - NICHT MANUELL BEARBEITEN.
3
3
  *
4
4
  * Quelle: src-ts/runtime-executables/www/sw.ts
5
- * Quell-Hash: sha256:7e6d2bfba973635971d54ef3cdd876cd4e69370bec5d890339c455ca21495d15
5
+ * Quell-Hash: sha256:b3be6d202aa915955cb159723dde4f3d281c0b1943217fdf31caee9d1a0914f9
6
6
  * Erzeugung: npm run sync:ts-runtime-executables
7
7
  *
8
8
  * Zweck:
@@ -43,7 +43,7 @@
43
43
  // Increment cache name on releases so browser updates JS/HTML reliably.
44
44
  // NOTE: Keep this monotonic to force SW updates on hotfixes.
45
45
  // 1.0.0 Stable: force all existing PWA clients onto the official stable shell.
46
- const CACHE_NAME = 'nexowatt-cache-v504';
46
+ const CACHE_NAME = 'nexowatt-cache-v505';
47
47
 
48
48
  const OFFLINE_URLS = [
49
49
  './',