iobroker.nexowatt-ui 1.0.1 → 1.0.2

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.1` (2026-09-09)
5
+ **Current stable release:** `1.0.2` (2026-09-09)
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,72 @@
1
+ # NexoWatt EOS 1.0.2 – offizielle Stable-Version
2
+
3
+ **Veröffentlichungsdatum:** 2026-09-09
4
+ **Status:** Official Stable Patch / produktiver Verkaufsstand
5
+
6
+ ## Zweck des Patches
7
+
8
+ NexoWatt EOS 1.0.2 beseitigt die nach 1.0.1 weiterhin beobachtete zyklische Anzeige „Offline / veraltet“ in der EOS-Admin-Übersicht. Der Fehler lag nicht mehr im RC88-Speicherwächter oder im SSE-Livekanal. Es bestand ein eigenständiger Timing-Konflikt zwischen dem ungefähr 20 Sekunden großen Frischefenster der Oberfläche, dem bisherigen 30-Sekunden-Heartbeat von `info.connection` und EMS-/Diagnosezyklen, die innerhalb ihrer Watchdoggrenzen länger als 20 Sekunden laufen dürfen.
9
+
10
+ Der Feldfall zeigte gleichzeitig einen erreichbaren Adapter, einen 25 Sekunden alten Tick-Start und eine vorherige Zyklusdauer von 2608 ms. Ein noch laufender, nicht festhängender Zyklus wurde dabei irrtümlich wie ein nicht erreichbarer Adapter dargestellt.
11
+
12
+ ## Neuer Zustandsvertrag
13
+
14
+ Die Übersicht unterscheidet jetzt vier technisch getrennte Signale:
15
+
16
+ | Signal | Takt / Grenze | Bedeutung |
17
+ |---|---:|---|
18
+ | Adapter-/HTTP-Erreichbarkeit | 4 s | `info.connection` wird aus dem realen Serverzustand bestätigt |
19
+ | EMS-Scheduler-Liveness | 4 s | Schedulerprozess lebt unabhängig vom vollständigen Regelzyklus |
20
+ | EMS-Regelzyklus | Watchdog 30 s, konfigurierbar | laufend, aktuell oder tatsächlich festhängend |
21
+ | Diagnose-Publisher | 4 s Liveness, 5 s Vollsnapshot | Übersichtspfad lebt; vollständige Diagnose kann separat verzögert sein |
22
+
23
+ ### Normalbetrieb
24
+
25
+ Adapter, Scheduler und Regelzyklus sind aktuell. Die Übersicht bleibt online und wechselt nicht aufgrund eines 20–30 Sekunden laufenden Zyklus auf „veraltet“.
26
+
27
+ ### Verzögerter Regelzyklus
28
+
29
+ Ist der Adapter erreichbar und der Scheduler-Heartbeat frisch, läuft der aktuelle Regelzyklus aber länger als die Watchdoggrenze, erscheint eine Warnung:
30
+
31
+ ```text
32
+ Adapter online – EMS-Regelzyklus überschreitet Zeitlimit
33
+ ```
34
+
35
+ Dies ist ausdrücklich kein Adapter-Offlinezustand.
36
+
37
+ ### Tatsächlicher Offlinefall
38
+
39
+ Meldet der reale HTTP-Server nicht mehr `listening`, wird `info.connection=false` geschrieben. Bei Prozessabbruch enden alle Heartbeats und überschreiten das Frischefenster. Beide Fälle werden weiterhin zuverlässig als offline erkannt. Ein frischer Scheduler- oder alter Summary-Wert darf `info.connection=false` nicht überdecken.
40
+
41
+ ## Last- und Ressourcenverhalten
42
+
43
+ Der vollständige Diagnose-Snapshot bleibt im Fünf-Sekunden-Takt. Der unabhängige Liveness-Timer aktualisiert kleine Health-States alle vier Sekunden. `summaryJson` wird vom Zusatzheartbeat nur dann erneuert, wenn der normale Vollsnapshot bereits länger ausbleibt; dadurch wird die übliche Snapshotlast nicht verdoppelt. Alle Timer werden beim Adapter-Unload explizit beendet.
44
+
45
+ ## Regressionstests
46
+
47
+ Die Stable-Prüfung enthält folgende Szenarien:
48
+
49
+ - 25 Sekunden laufender Regelzyklus, frischer Scheduler, vorherige Zyklusdauer 2608 ms: online, kein Stall, keine Veraltet-Anzeige;
50
+ - 35 Sekunden laufender Regelzyklus bei frischem Scheduler: Warnung `tick-stalled`, aber Adapter online;
51
+ - Scheduler-Heartbeat älter als seine Grenze bei weiterhin verbundenem Adapter: Scheduler-Warnung, nicht Adapter offline;
52
+ - `info.connection=false` trotz frischer anderer Werte: sofortiger echter Offlinezustand;
53
+ - unabhängiger Vier-Sekunden-Heartbeat während eines laufenden vollständigen Diagnosezyklus;
54
+ - korrekter Shutdown aller neuen Timer;
55
+ - Auswahl des neuesten statt des ersten vorhandenen Aktivitätszeitstempels.
56
+
57
+ ## Unveränderte Regelungsfunktionen
58
+
59
+ Der Patch betrifft ausschließlich Statusermittlung, Heartbeats und Diagnosepublikation. Unverändert bleiben insbesondere:
60
+
61
+ - signierter NVP und Netzanschlussgrenzen;
62
+ - Lade- und Lastmanagement;
63
+ - Speicher- und Multi-Use-Regelung;
64
+ - Netzlimit, feste Einspeisebegrenzung und Nulleinspeisung;
65
+ - Export Guard und Single-Writer-Struktur;
66
+ - §14a, Tarife und Prognosen;
67
+ - EZA-/Parkregler-Priorität und deren Fallbacks;
68
+ - sämtliche produktiven Hardware-Writer.
69
+
70
+ ## Feldprüfung nach Update
71
+
72
+ Nach Installation aus einem frischen Ordner ist der Adapter vollständig neu zu starten und der Browser einmal mit `Strg+F5` zu laden. Die EOS-Übersicht sollte mindestens 30 Minuten geöffnet bleiben. Im Normalbetrieb darf sie nicht mehr rhythmisch zwischen online und „Offline / veraltet“ wechseln. Für einen Gegencheck kann die Adapterinstanz kontrolliert gestoppt werden; nach dem Frischefenster muss die Übersicht eindeutig offline anzeigen.
package/ems/engine.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * AUTO-GENERATED RUNTIME FILE - NICHT MANUELL BEARBEITEN.
3
3
  *
4
4
  * Quelle: src-ts/runtime-executables/ems/engine.ts
5
- * Quell-Hash: sha256:39e9a577a619aebd1cda1e43ddb58f9cc7d647d71b568b8e6a06e04f272c0543
5
+ * Quell-Hash: sha256:d8f7bab38ff19e7fa52d306e498c09f5fbe229bf47f12bb425c7e2ba8c5c8951
6
6
  * Erzeugung: npm run sync:ts-runtime-executables
7
7
  *
8
8
  * Zweck:
@@ -107,6 +107,13 @@ class EmsEngine {
107
107
  this.mm = null;
108
108
  this._timer = null;
109
109
  this._intervalMs = 1000;
110
+ // Independent scheduler liveness. It is deliberately separate from the
111
+ // complete EMS tick, because a legitimate long-running module must not make
112
+ // EOS Admin classify the whole adapter as offline.
113
+ this._schedulerHeartbeatTimer = null;
114
+ this._schedulerHeartbeatRunning = false;
115
+ this._schedulerHeartbeatIntervalMs = 4000;
116
+ this._schedulerHeartbeatSequence = 0;
110
117
  // Reaktionspfad für Bedienänderungen: Ein Moduswechsel im Kundenfrontend
111
118
  // soll nicht bis zum nächsten regulären Scheduler-Tick warten. Der kurze
112
119
  // Debounce fasst API-Write und nachfolgenden StateChange zu genau einem
@@ -333,6 +340,42 @@ class EmsEngine {
333
340
  },
334
341
  native: {},
335
342
  });
343
+ await a.setObjectNotExistsAsync('ems.core.schedulerHeartbeatAt', {
344
+ type: 'state',
345
+ common: {
346
+ name: 'Independent EMS scheduler heartbeat (ts)',
347
+ type: 'number',
348
+ role: 'value.time',
349
+ read: true,
350
+ write: false,
351
+ def: 0,
352
+ },
353
+ native: {},
354
+ });
355
+ await a.setObjectNotExistsAsync('ems.core.schedulerHeartbeatSequence', {
356
+ type: 'state',
357
+ common: {
358
+ name: 'Independent EMS scheduler heartbeat sequence',
359
+ type: 'number',
360
+ role: 'value',
361
+ read: true,
362
+ write: false,
363
+ def: 0,
364
+ },
365
+ native: {},
366
+ });
367
+ await a.setObjectNotExistsAsync('ems.core.schedulerAlive', {
368
+ type: 'state',
369
+ common: {
370
+ name: 'EMS scheduler process alive',
371
+ type: 'boolean',
372
+ role: 'indicator.connected',
373
+ read: true,
374
+ write: false,
375
+ def: false,
376
+ },
377
+ native: {},
378
+ });
336
379
  await a.setObjectNotExistsAsync('ems.core.tickSkipCount', {
337
380
  type: 'state',
338
381
  common: {
@@ -987,6 +1030,55 @@ class EmsEngine {
987
1030
  catch (_e) { }
988
1031
  return { anyControl, chargingCfg, stationGroups, stationGroupMap };
989
1032
  }
1033
+ /**
1034
+ * Publishes scheduler liveness independently from a full EMS control cycle.
1035
+ * The local process object is updated even if a previous ioBroker state write
1036
+ * is delayed, so the co-located Admin overview can still distinguish a live
1037
+ * scheduler from a stalled regulation tick.
1038
+ */
1039
+ async _publishSchedulerHeartbeat(reason = 'timer') {
1040
+ if (!this.adapter || this.adapter._nwShuttingDown)
1041
+ return;
1042
+ const now = Date.now();
1043
+ const configuredStaleMs = clampNumber(this.adapter?.config?.diagnostics?.emsTickStaleAfterMs, 15000, 300000, this._tickStaleAfterMs);
1044
+ const activeTickAgeMs = this._tickRunning && this._lastTickStartMs > 0
1045
+ ? Math.max(0, now - this._lastTickStartMs)
1046
+ : 0;
1047
+ const tickStalled = this._tickRunning && activeTickAgeMs > configuredStaleMs;
1048
+ this._schedulerHeartbeatSequence += 1;
1049
+ this.adapter._nwEmsSchedulerHealth = {
1050
+ heartbeatAt: now,
1051
+ sequence: this._schedulerHeartbeatSequence,
1052
+ reason: String(reason || 'timer'),
1053
+ tickRunning: this._tickRunning === true,
1054
+ activeTickAgeMs,
1055
+ tickStalled,
1056
+ tickStaleAfterMs: configuredStaleMs,
1057
+ lastTickStartMs: this._lastTickStartMs,
1058
+ lastTickEndMs: this._lastTickEndMs,
1059
+ };
1060
+ if (this._schedulerHeartbeatRunning)
1061
+ return;
1062
+ this._schedulerHeartbeatRunning = true;
1063
+ try {
1064
+ await Promise.allSettled([
1065
+ this.adapter.setStateAsync('ems.core.schedulerHeartbeatAt', { val: now, ack: true }),
1066
+ this.adapter.setStateAsync('ems.core.schedulerHeartbeatSequence', { val: Math.round(this._schedulerHeartbeatSequence), ack: true }),
1067
+ this.adapter.setStateAsync('ems.core.schedulerAlive', { val: true, ack: true }),
1068
+ ]);
1069
+ }
1070
+ finally {
1071
+ this._schedulerHeartbeatRunning = false;
1072
+ }
1073
+ }
1074
+ _startSchedulerHeartbeat() {
1075
+ if (!this.adapter || this.adapter._nwShuttingDown || this._schedulerHeartbeatTimer)
1076
+ return;
1077
+ this._publishSchedulerHeartbeat('startup').catch(() => { });
1078
+ this._schedulerHeartbeatTimer = this._setInterval(() => {
1079
+ this._publishSchedulerHeartbeat('timer').catch(() => { });
1080
+ }, this._schedulerHeartbeatIntervalMs);
1081
+ }
990
1082
  /**
991
1083
  * Code-Teil: Methode `init`
992
1084
  * Zweck: initialisiert UI/Modul, bindet Events oder bereitet Startzustände vor.
@@ -1002,6 +1094,7 @@ class EmsEngine {
1002
1094
  async init() {
1003
1095
  const adapter = this.adapter;
1004
1096
  await this._ensureInternalStates();
1097
+ this._startSchedulerHeartbeat();
1005
1098
  // Scheduler interval from config (Admin UI / jsonConfig)
1006
1099
  const cfgInterval = adapter.config && adapter.config.schedulerIntervalMs;
1007
1100
  // Aktor- und Speicher-Watchdogs muessen spaetestens sekündlich erneuert werden.
@@ -1238,6 +1331,7 @@ class EmsEngine {
1238
1331
  this._activeTickId = tickId;
1239
1332
  const tickStart = Date.now();
1240
1333
  this._lastTickStartMs = tickStart;
1334
+ this._publishSchedulerHeartbeat('tick-start').catch(() => { });
1241
1335
  try {
1242
1336
  try {
1243
1337
  await this.adapter.setStateAsync('ems.core.tickRunning', { val: true, ack: true });
@@ -1366,6 +1460,7 @@ class EmsEngine {
1366
1460
  }
1367
1461
  const dur = Date.now() - tickStart;
1368
1462
  this._lastTickEndMs = Date.now();
1463
+ this._publishSchedulerHeartbeat('tick-end').catch(() => { });
1369
1464
  try {
1370
1465
  if (ownsTickLock)
1371
1466
  await this.adapter.setStateAsync('ems.core.tickRunning', { val: false, ack: true });
@@ -1397,6 +1492,20 @@ class EmsEngine {
1397
1492
  * TypeScript: Parameter, Rückgabewert und verwendete Config-/State-Objekte später explizit typisieren.
1398
1493
  */
1399
1494
  stop() {
1495
+ if (this._schedulerHeartbeatTimer) {
1496
+ this._clearInterval(this._schedulerHeartbeatTimer);
1497
+ this._schedulerHeartbeatTimer = null;
1498
+ }
1499
+ this._schedulerHeartbeatRunning = false;
1500
+ try {
1501
+ this.adapter._nwEmsSchedulerHealth = {
1502
+ ...(this.adapter._nwEmsSchedulerHealth || {}),
1503
+ heartbeatAt: Date.now(),
1504
+ alive: false,
1505
+ reason: 'stopped',
1506
+ };
1507
+ }
1508
+ catch (_error) { }
1400
1509
  if (this._timer) {
1401
1510
  this._clearInterval(this._timer);
1402
1511
  this._timer = null;
@@ -2,7 +2,7 @@
2
2
  * AUTO-GENERATED RUNTIME FILE - NICHT MANUELL BEARBEITEN.
3
3
  *
4
4
  * Quelle: src-ts/runtime-executables/ems/services/admin-overview-publisher.ts
5
- * Quell-Hash: sha256:cedb794bcc6ac1f264c001ec0ee389db6e580e7b69c6dab77ee680615bf906db
5
+ * Quell-Hash: sha256:fd388bdb3b70b86fed01cf8dae1a28bb5f8002b986083f426b0fe67fc674bc23
6
6
  * Erzeugung: npm run sync:ts-runtime-executables
7
7
  *
8
8
  * Zweck:
@@ -17,6 +17,10 @@
17
17
  */
18
18
  'use strict';
19
19
  const DEFAULT_PUBLISH_INTERVAL_MS = 5000;
20
+ // EOS Admin treats an instance without fresh liveness data after roughly
21
+ // 20 seconds as unavailable. A dedicated four-second heartbeat therefore runs
22
+ // independently from the potentially longer diagnostic collection cycle.
23
+ const DEFAULT_HEARTBEAT_INTERVAL_MS = 4000;
20
24
  const DEFAULT_STATE_READ_TIMEOUT_MS = 1200;
21
25
  const DEFAULT_STATE_WRITE_TIMEOUT_MS = 1200;
22
26
  const DEFAULT_OBJECT_TIMEOUT_MS = 2500;
@@ -26,6 +30,7 @@ const DEFAULT_IO_CONCURRENCY = 8;
26
30
  // adapter "offline". Tick freshness is still exposed separately and becomes a
27
31
  // visible warning once this threshold is exceeded.
28
32
  const DEFAULT_TICK_FRESH_THRESHOLD_MS = 30000;
33
+ const DEFAULT_SCHEDULER_FRESH_THRESHOLD_MS = 12000;
29
34
  class AdminOverviewTimeoutError extends Error {
30
35
  constructor(label, timeoutMs) {
31
36
  super(`${label} timed out after ${timeoutMs} ms`);
@@ -139,6 +144,21 @@ function firstValue(adapter, keys, fallback = null) {
139
144
  }
140
145
  return fallback;
141
146
  }
147
+ /**
148
+ * Returns the newest numeric timestamp instead of the first populated state.
149
+ * A running EMS tick can have an older start timestamp while another module or
150
+ * the scheduler has already published newer activity. Choosing the first key
151
+ * caused a healthy installation to oscillate between online and stale.
152
+ */
153
+ function newestTimestamp(adapter, keys, fallback = 0) {
154
+ let newest = Math.max(0, Math.round(finite(fallback, 0)));
155
+ for (const key of keys) {
156
+ const candidate = Math.max(0, Math.round(finite(stateValue(adapter, key, 0), 0)));
157
+ if (candidate > newest)
158
+ newest = candidate;
159
+ }
160
+ return newest;
161
+ }
142
162
  function severityRank(value) {
143
163
  return value === 'error' ? 3 : value === 'warning' ? 2 : value === 'info' ? 1 : 0;
144
164
  }
@@ -366,20 +386,39 @@ function buildOverviewContract(adapter, now = Date.now()) {
366
386
  ? adapter._nwAdminOverviewPublisherHealth
367
387
  : {};
368
388
  const tickFreshThresholdMs = Math.max(10000, Math.round(finite(publisherHealth.tickFreshThresholdMs, DEFAULT_TICK_FRESH_THRESHOLD_MS)));
389
+ const schedulerFreshThresholdMs = Math.max(8000, Math.round(finite(publisherHealth.schedulerFreshThresholdMs, DEFAULT_SCHEDULER_FRESH_THRESHOLD_MS)));
369
390
  const adapterOnline = bool(firstValue(adapter, ['info.connection'], true), true);
370
- const lastTickTs = Math.max(0, Math.round(finite(firstValue(adapter, [
391
+ const schedulerHealth = adapter && adapter._nwEmsSchedulerHealth && typeof adapter._nwEmsSchedulerHealth === 'object'
392
+ ? adapter._nwEmsSchedulerHealth
393
+ : {};
394
+ const schedulerHeartbeatAt = Math.max(newestTimestamp(adapter, ['ems.core.schedulerHeartbeatAt'], 0), Math.max(0, Math.round(finite(schedulerHealth.heartbeatAt, 0))));
395
+ const schedulerHeartbeatAgeMs = schedulerHeartbeatAt > 0 ? Math.max(0, now - schedulerHeartbeatAt) : null;
396
+ const schedulerKnown = schedulerHeartbeatAgeMs !== null;
397
+ const schedulerFresh = !schedulerKnown
398
+ || (schedulerHeartbeatAgeMs !== null && schedulerHeartbeatAgeMs <= schedulerFreshThresholdMs);
399
+ const lastTickStartTs = newestTimestamp(adapter, ['ems.core.lastTickStart'], schedulerHealth.lastTickStartMs);
400
+ const lastTickEndTs = newestTimestamp(adapter, ['ems.core.lastTickEnd'], schedulerHealth.lastTickEndMs);
401
+ const lastTickTs = newestTimestamp(adapter, [
371
402
  'ems.core.lastTickStart',
372
403
  'ems.core.lastTickEnd',
404
+ 'ems.core.lastModuleStartedAt',
405
+ 'ems.core.lastModuleCompletedAt',
373
406
  'chargingManagement.summary.lastUpdate',
374
407
  'ems.budget.lastUpdate',
375
- ], audit && audit.ts), finite(audit && audit.ts, 0))));
408
+ ], audit && audit.ts);
409
+ const tickRunning = bool(firstValue(adapter, ['ems.core.tickRunning'], schedulerHealth.tickRunning), Boolean(schedulerHealth.tickRunning));
410
+ const activeTickAgeMs = tickRunning && lastTickStartTs > 0 ? Math.max(0, now - lastTickStartTs) : 0;
411
+ const tickStalled = tickRunning && activeTickAgeMs > tickFreshThresholdMs;
376
412
  const lastTickDurationMs = Math.max(0, Math.round(finite(stateValue(adapter, 'ems.core.lastTickDurationMs', 0), 0)));
377
413
  const lastTickError = text(stateValue(adapter, 'ems.core.lastTickError', ''), '', 220);
378
414
  const lastTickAgeMs = lastTickTs > 0 ? Math.max(0, now - lastTickTs) : null;
415
+ const lastCompletedTickAgeMs = lastTickEndTs > 0 ? Math.max(0, now - lastTickEndTs) : null;
379
416
  const tickKnown = lastTickAgeMs !== null;
380
- // Some installations do not enable every EMS module. Missing tick telemetry is
381
- // therefore an informational startup/idle state, not an adapter failure.
382
- const tickFresh = !tickKnown || (lastTickAgeMs !== null && lastTickAgeMs <= tickFreshThresholdMs);
417
+ // A currently running cycle remains healthy until the EMS watchdog threshold.
418
+ // Scheduler liveness is assessed independently, so a 20–30 s cycle is never
419
+ // mislabelled as an offline adapter.
420
+ const tickFresh = !tickKnown
421
+ || (tickRunning ? !tickStalled : (lastTickAgeMs !== null && lastTickAgeMs <= tickFreshThresholdMs));
383
422
  const publisherStatus = text(publisherHealth.status, 'ok', 40).toLowerCase();
384
423
  const publisherDegraded = !['', 'ok', 'healthy'].includes(publisherStatus);
385
424
  const auditLimiterRaw = normalizeLimiter(firstValue(adapter, [
@@ -414,7 +453,7 @@ function buildOverviewContract(adapter, now = Date.now()) {
414
453
  const safetyStop = safetyStage.toUpperCase() === 'EOS-SAFETY-STOP';
415
454
  const status = maxSeverity(statusFromAudit({ ...audit, activeLimiter: auditLimiter, safetyStage }, paraFallback, storageWriteOk, forecastFresh), (!adapterOnline || !safetyValid || safetyEmergencyStop || safetyStop || lastTickError)
416
455
  ? 'error'
417
- : (!tickFresh || publisherDegraded || safetyActive ? 'warning' : (!tickKnown ? 'info' : 'ok')),
456
+ : (!schedulerFresh || tickStalled || !tickFresh || publisherDegraded || safetyActive ? 'warning' : (!tickKnown ? 'info' : 'ok')),
418
457
  // A single unavailable charge point is a local partial fault. It remains
419
458
  // visible in the charge-point tile but must not label the complete EMS as
420
459
  // offline while NVP monitoring and the remaining devices continue safely.
@@ -435,6 +474,10 @@ function buildOverviewContract(adapter, now = Date.now()) {
435
474
  let headline = 'EMS arbeitet normal';
436
475
  if (!adapterOnline)
437
476
  headline = 'NexoWatt UI ist offline';
477
+ else if (schedulerKnown && !schedulerFresh)
478
+ headline = 'Adapter online – EMS-Scheduler reagiert nicht';
479
+ else if (tickStalled)
480
+ headline = 'Adapter online – EMS-Regelzyklus überschreitet Zeitlimit';
438
481
  else if (!tickKnown)
439
482
  headline = 'EMS-Diagnose bereit – noch kein aktiver Regeltick';
440
483
  else if (!tickFresh)
@@ -475,6 +518,12 @@ function buildOverviewContract(adapter, now = Date.now()) {
475
518
  if (!adapterOnline) {
476
519
  overviewReason = 'Die Adapterinstanz meldet info.connection=false. Diagnose- und Regelwerte sind deshalb nicht als aktuell zu behandeln.';
477
520
  }
521
+ else if (schedulerKnown && !schedulerFresh) {
522
+ overviewReason = `Der Adapter ist online, aber das unabhängige EMS-Scheduler-Lebenszeichen ist älter als ${Math.round(schedulerFreshThresholdMs / 1000)} Sekunden.`;
523
+ }
524
+ else if (tickStalled) {
525
+ overviewReason = `Der Adapter und Scheduler sind online, aber der aktuelle EMS-Regelzyklus läuft seit mehr als ${Math.round(tickFreshThresholdMs / 1000)} Sekunden.`;
526
+ }
478
527
  else if (tickKnown && !tickFresh) {
479
528
  overviewReason = `Der Adapter ist online, aber der letzte EMS-Regelzyklus ist älter als ${Math.round(tickFreshThresholdMs / 1000)} Sekunden.`;
480
529
  }
@@ -515,6 +564,8 @@ function buildOverviewContract(adapter, now = Date.now()) {
515
564
  healthy: !publisherDegraded,
516
565
  heartbeatAt: Math.max(0, Math.round(finite(publisherHealth.heartbeatAt, 0))),
517
566
  lastSuccessAt: Math.max(0, Math.round(finite(publisherHealth.lastSuccessAt, 0))),
567
+ fullSnapshotAt: Math.max(0, Math.round(finite(publisherHealth.fullSnapshotAt, now))),
568
+ snapshotAgeMs: Math.max(0, now - Math.max(0, Math.round(finite(publisherHealth.fullSnapshotAt, now)))),
518
569
  cycleDurationMs: Math.max(0, Math.round(finite(publisherHealth.cycleDurationMs, 0))),
519
570
  readTimeouts: Math.max(0, Math.round(finite(publisherHealth.readTimeouts, 0))),
520
571
  writeTimeouts: Math.max(0, Math.round(finite(publisherHealth.writeTimeouts, 0))),
@@ -526,14 +577,27 @@ function buildOverviewContract(adapter, now = Date.now()) {
526
577
  ems: {
527
578
  active: adapterOnline && bool(firstValue(adapter, ['chargingManagement.control.active', 'ems.budget.active'], true), true),
528
579
  online: adapterOnline,
580
+ schedulerKnown,
581
+ schedulerFresh,
582
+ schedulerFreshThresholdMs,
583
+ schedulerHeartbeatAt,
584
+ schedulerHeartbeatAgeMs,
585
+ tickRunning,
529
586
  tickFresh,
530
587
  tickKnown,
588
+ tickStalled,
531
589
  tickFreshThresholdMs,
532
- health: !adapterOnline ? 'offline' : (tickFresh ? 'ok' : 'tick-stale'),
590
+ activeTickAgeMs,
591
+ health: !adapterOnline
592
+ ? 'offline'
593
+ : (!schedulerFresh ? 'scheduler-stale' : (tickStalled ? 'tick-stalled' : (tickFresh ? 'ok' : 'tick-stale'))),
533
594
  mode: controlMode || centralBudgetMode,
534
595
  status: controlStatus,
535
596
  lastTickTs,
597
+ lastTickStartTs,
598
+ lastTickEndTs,
536
599
  lastTickAgeMs,
600
+ lastCompletedTickAgeMs,
537
601
  cycleMs: lastTickDurationMs,
538
602
  lastError: lastTickError,
539
603
  safetyStage,
@@ -746,6 +810,8 @@ function normalizeAuditEvent(event) {
746
810
  class AdminOverviewPublisher {
747
811
  constructor(adapter, options = {}) {
748
812
  this.timer = null;
813
+ this.heartbeatTimer = null;
814
+ this.heartbeatRunning = false;
749
815
  this.running = false;
750
816
  this.runningSince = 0;
751
817
  this.stopped = false;
@@ -755,6 +821,10 @@ class AdminOverviewPublisher {
755
821
  this.maxEvents = 60;
756
822
  this.inFlight = new Map();
757
823
  this.lastSuccessAt = 0;
824
+ this.fullSnapshotAt = 0;
825
+ this.lastHeartbeatAt = 0;
826
+ this.lastSummaryRefreshAt = 0;
827
+ this.lastContract = null;
758
828
  this.lastWarningAt = 0;
759
829
  this.cycleReadTimeouts = 0;
760
830
  this.cycleWriteTimeouts = 0;
@@ -763,19 +833,25 @@ class AdminOverviewPublisher {
763
833
  this.cycleLastError = '';
764
834
  this.adapter = adapter;
765
835
  this.intervalMs = Math.max(1000, Math.round(finite(options.intervalMs, DEFAULT_PUBLISH_INTERVAL_MS)));
836
+ this.heartbeatIntervalMs = Math.max(500, Math.round(finite(options.heartbeatIntervalMs, DEFAULT_HEARTBEAT_INTERVAL_MS)));
766
837
  this.readTimeoutMs = Math.max(20, Math.round(finite(options.readTimeoutMs, DEFAULT_STATE_READ_TIMEOUT_MS)));
767
838
  this.writeTimeoutMs = Math.max(20, Math.round(finite(options.writeTimeoutMs, DEFAULT_STATE_WRITE_TIMEOUT_MS)));
768
839
  this.objectTimeoutMs = Math.max(50, Math.round(finite(options.objectTimeoutMs, DEFAULT_OBJECT_TIMEOUT_MS)));
769
840
  this.ioConcurrency = Math.max(1, Math.min(16, Math.round(finite(options.ioConcurrency, DEFAULT_IO_CONCURRENCY))));
770
841
  this.tickFreshThresholdMs = Math.max(10000, Math.round(finite(options.tickFreshThresholdMs, DEFAULT_TICK_FRESH_THRESHOLD_MS)));
842
+ this.schedulerFreshThresholdMs = Math.max(8000, Math.round(finite(options.schedulerFreshThresholdMs, DEFAULT_SCHEDULER_FRESH_THRESHOLD_MS)));
771
843
  }
772
844
  async initialize() {
773
845
  await this.ensureStates();
846
+ this.updateInternalHealth(Date.now(), 'initializing');
847
+ await this.heartbeat('startup', true);
848
+ this.startHeartbeatTimer();
774
849
  await this.restoreEvents();
775
850
  for (const pattern of [
776
851
  'chargingManagement.audit.*',
777
852
  'chargingManagement.control.*',
778
853
  'chargingManagement.summary.*',
854
+ 'ems.core.*',
779
855
  'ems.budget.*',
780
856
  'speicher.regelung.*',
781
857
  'para14a.*',
@@ -796,20 +872,33 @@ class AdminOverviewPublisher {
796
872
  ? this.adapter._nwSetInterval(callback, this.intervalMs)
797
873
  : (typeof this.adapter.setInterval === 'function' ? this.adapter.setInterval(callback, this.intervalMs) : setInterval(callback, this.intervalMs));
798
874
  }
799
- stop() {
800
- this.stopped = true;
801
- if (!this.timer)
875
+ startHeartbeatTimer() {
876
+ if (this.stopped || this.heartbeatTimer || this.adapter._nwShuttingDown)
877
+ return;
878
+ const callback = () => { this.heartbeat('timer').catch(() => { }); };
879
+ this.heartbeatTimer = typeof this.adapter._nwSetInterval === 'function'
880
+ ? this.adapter._nwSetInterval(callback, this.heartbeatIntervalMs)
881
+ : (typeof this.adapter.setInterval === 'function' ? this.adapter.setInterval(callback, this.heartbeatIntervalMs) : setInterval(callback, this.heartbeatIntervalMs));
882
+ }
883
+ clearTimer(timer) {
884
+ if (!timer)
802
885
  return;
803
886
  try {
804
887
  if (typeof this.adapter._nwClearInterval === 'function')
805
- this.adapter._nwClearInterval(this.timer);
888
+ this.adapter._nwClearInterval(timer);
806
889
  else if (typeof this.adapter.clearInterval === 'function')
807
- this.adapter.clearInterval(this.timer);
890
+ this.adapter.clearInterval(timer);
808
891
  else
809
- clearInterval(this.timer);
892
+ clearInterval(timer);
810
893
  }
811
894
  catch (_error) { }
895
+ }
896
+ stop() {
897
+ this.stopped = true;
898
+ this.clearTimer(this.timer);
899
+ this.clearTimer(this.heartbeatTimer);
812
900
  this.timer = null;
901
+ this.heartbeatTimer = null;
813
902
  // In-flight ioBroker Promises cannot always be cancelled. Clearing our
814
903
  // bounded registry removes the publisher's own references during adapter
815
904
  // shutdown; no follow-up operation is started because `stopped` is true.
@@ -822,15 +911,16 @@ class AdminOverviewPublisher {
822
911
  this.runningSince = Date.now();
823
912
  this.resetCycleDiagnostics();
824
913
  try {
825
- // `updatedAt` acts as the lightweight publisher heartbeat consumed by
826
- // older EOS-Admin versions. It is intentionally written before the more
827
- // expensive state refresh, so a delayed diagnostic read can never be
828
- // mistaken for an offline adapter.
829
- await this.setIfChanged('info.adminOverview.updatedAt', this.runningSince, true);
914
+ // Independent liveness heartbeat: this call is not tied to the full
915
+ // diagnostic refresh and therefore remains current even when a module or
916
+ // ioBroker read takes longer than the Admin stale window.
917
+ await this.heartbeat(`cycle-${reason}`, false);
830
918
  await this.primeVolatileStates();
831
919
  const now = Date.now();
832
920
  this.updateInternalHealth(now, this.cycleReadTimeouts || this.cycleReadErrors ? 'degraded' : 'ok');
833
921
  const contract = buildOverviewContract(this.adapter, now);
922
+ this.fullSnapshotAt = now;
923
+ this.lastContract = contract;
834
924
  this.ingestAuditEvents();
835
925
  const signature = eventSignature(contract);
836
926
  if (signature !== this.lastSignature) {
@@ -854,11 +944,72 @@ class AdminOverviewPublisher {
854
944
  : 'ok';
855
945
  this.updateInternalHealth(finishedAt, healthStatus, cycleDurationMs);
856
946
  await this.publishHealthStates(finishedAt, healthStatus, cycleDurationMs, reason);
947
+ await this.heartbeat(`cycle-finished-${reason}`, false);
857
948
  this.logCycleDegradation(finishedAt, healthStatus, reason);
858
949
  this.running = false;
859
950
  this.runningSince = 0;
860
951
  }
861
952
  }
953
+ /**
954
+ * Independent compatibility heartbeat for EOS Admin.
955
+ *
956
+ * It deliberately does not use the full-cycle `running` lock. This prevents a
957
+ * healthy adapter from becoming "Offline / veraltet" while a legitimate EMS
958
+ * cycle or a bounded diagnostic read is still in progress. A dead process or
959
+ * stopped HTTP server still stops this heartbeat and is therefore detected.
960
+ */
961
+ async heartbeat(reason = 'manual', forceSummary = false) {
962
+ if (this.stopped || this.heartbeatRunning || this.adapter._nwShuttingDown)
963
+ return;
964
+ this.heartbeatRunning = true;
965
+ const now = Date.now();
966
+ this.lastHeartbeatAt = now;
967
+ try {
968
+ const currentStatus = text(this.adapter?._nwAdminOverviewPublisherHealth?.status, this.running ? 'refreshing' : 'ok', 40);
969
+ this.updateInternalHealth(now, currentStatus, this.running && this.runningSince > 0 ? now - this.runningSince : 0);
970
+ const health = buildOverviewContract(this.adapter, now);
971
+ health.updatedAt = now;
972
+ health.generatedAt = now;
973
+ if (health.publisher && typeof health.publisher === 'object') {
974
+ health.publisher.heartbeatAt = now;
975
+ health.publisher.fullSnapshotAt = this.fullSnapshotAt;
976
+ health.publisher.snapshotAgeMs = this.fullSnapshotAt > 0 ? Math.max(0, now - this.fullSnapshotAt) : 0;
977
+ }
978
+ this.lastContract = health;
979
+ try {
980
+ this.adapter._nwAdminOverview = health;
981
+ }
982
+ catch (_error) { }
983
+ const adapterOnline = health.adapter?.online === true;
984
+ const values = [
985
+ ['updatedAt', now, true],
986
+ ['publisherHeartbeatAt', now, true],
987
+ ['adapterOnline', adapterOnline, true],
988
+ ['emsSchedulerFresh', health.ems?.schedulerFresh !== false, true],
989
+ ['emsSchedulerHeartbeatAt', finite(health.ems?.schedulerHeartbeatAt, 0), true],
990
+ ['emsSchedulerHeartbeatAgeMs', finite(health.ems?.schedulerHeartbeatAgeMs, 0), true],
991
+ ['emsTickRunning', health.ems?.tickRunning === true, true],
992
+ ['emsTickStalled', health.ems?.tickStalled === true, true],
993
+ ['emsTickFresh', health.ems?.tickFresh !== false, true],
994
+ ['emsTickAgeMs', finite(health.ems?.lastTickAgeMs, 0), true],
995
+ ];
996
+ await mapWithConcurrency(values, Math.min(4, this.ioConcurrency), async ([id, value, force]) => (this.setIfChanged(`info.adminOverview.${id}`, value, Boolean(force))));
997
+ // Normally the full five-second snapshot refreshes summaryJson. Only when
998
+ // that cycle is delayed do we refresh the compact payload from the live
999
+ // state cache. This keeps compatibility with Admin versions that inspect
1000
+ // the JSON timestamp, without doubling normal state traffic.
1001
+ const summaryRefreshThresholdMs = Math.max(7000, this.heartbeatIntervalMs * 2);
1002
+ if (forceSummary || this.lastSummaryRefreshAt <= 0 || now - this.lastSummaryRefreshAt >= summaryRefreshThresholdMs) {
1003
+ const summaryWritten = await this.setIfChanged('info.adminOverview.summaryJson', JSON.stringify(health), true);
1004
+ if (summaryWritten)
1005
+ this.lastSummaryRefreshAt = now;
1006
+ }
1007
+ await this.setIfChanged('info.adminOverview.publisherLastReason', text(`heartbeat-${reason}`, 'heartbeat', 40));
1008
+ }
1009
+ finally {
1010
+ this.heartbeatRunning = false;
1011
+ }
1012
+ }
862
1013
  resetCycleDiagnostics() {
863
1014
  this.cycleReadTimeouts = 0;
864
1015
  this.cycleWriteTimeouts = 0;
@@ -896,6 +1047,8 @@ class AdminOverviewPublisher {
896
1047
  pendingOperations: this.inFlight.size,
897
1048
  lastError: this.cycleLastError,
898
1049
  tickFreshThresholdMs: this.tickFreshThresholdMs,
1050
+ schedulerFreshThresholdMs: this.schedulerFreshThresholdMs,
1051
+ fullSnapshotAt: this.fullSnapshotAt,
899
1052
  };
900
1053
  }
901
1054
  logCycleDegradation(now, status, reason) {
@@ -949,16 +1102,10 @@ class AdminOverviewPublisher {
949
1102
  throw new Error(`Admin overview object ${id} could not be ensured: ${result.error}`);
950
1103
  }
951
1104
  async publishHealthStates(now, status, cycleDurationMs, reason) {
952
- const lastTickTs = Math.max(0, Math.round(finite(firstValue(this.adapter, [
953
- // Prefer the canonical EMS timestamps. `lastTickEnd` is important on
954
- // installations where the start timestamp is not mirrored every cycle.
955
- 'ems.core.lastTickStart',
956
- 'ems.core.lastTickEnd',
957
- 'chargingManagement.summary.lastUpdate',
958
- 'ems.budget.lastUpdate',
959
- ], 0), 0)));
1105
+ const health = buildOverviewContract(this.adapter, now);
1106
+ const lastTickTs = Math.max(0, Math.round(finite(health.ems?.lastTickTs, 0)));
960
1107
  const tickAgeMs = lastTickTs > 0 ? Math.max(0, now - lastTickTs) : 0;
961
- const adapterOnline = bool(firstValue(this.adapter, ['info.connection'], true), true);
1108
+ const adapterOnline = health.adapter?.online === true;
962
1109
  const values = [
963
1110
  ['publisherHeartbeatAt', now, true],
964
1111
  ['publisherLastSuccessAt', this.lastSuccessAt, true],
@@ -970,7 +1117,12 @@ class AdminOverviewPublisher {
970
1117
  ['publisherLastError', this.cycleLastError],
971
1118
  ['publisherLastReason', text(reason, 'timer', 40)],
972
1119
  ['adapterOnline', adapterOnline, true],
973
- ['emsTickFresh', lastTickTs <= 0 || tickAgeMs <= this.tickFreshThresholdMs, true],
1120
+ ['emsSchedulerFresh', health.ems?.schedulerFresh !== false, true],
1121
+ ['emsSchedulerHeartbeatAt', finite(health.ems?.schedulerHeartbeatAt, 0), true],
1122
+ ['emsSchedulerHeartbeatAgeMs', finite(health.ems?.schedulerHeartbeatAgeMs, 0), true],
1123
+ ['emsTickRunning', health.ems?.tickRunning === true, true],
1124
+ ['emsTickStalled', health.ems?.tickStalled === true, true],
1125
+ ['emsTickFresh', health.ems?.tickFresh !== false, true],
974
1126
  ['emsTickAgeMs', tickAgeMs, true],
975
1127
  ];
976
1128
  await mapWithConcurrency(values, Math.min(4, this.ioConcurrency), async ([id, value, force]) => (this.setIfChanged(`info.adminOverview.${id}`, value, Boolean(force))));
@@ -1000,8 +1152,13 @@ class AdminOverviewPublisher {
1000
1152
  // the read-only publisher lifecycle distinguishable for current and future
1001
1153
  // EOS-Admin versions. None of these states participates in EMS arbitration.
1002
1154
  await ensure('adapterOnline', 'Adapter/Web-API online', 'boolean', 'indicator.connected', false);
1155
+ await ensure('emsSchedulerFresh', 'EMS-Scheduler-Lebenszeichen aktuell', 'boolean', 'indicator', false);
1156
+ await ensure('emsSchedulerHeartbeatAt', 'Letztes EMS-Scheduler-Lebenszeichen', 'number', 'value.time', 0);
1157
+ await ensure('emsSchedulerHeartbeatAgeMs', 'Alter des EMS-Scheduler-Lebenszeichens', 'number', 'value.interval', 0);
1158
+ await ensure('emsTickRunning', 'EMS-Regelzyklus läuft', 'boolean', 'indicator.working', false);
1159
+ await ensure('emsTickStalled', 'EMS-Regelzyklus überschreitet Zeitlimit', 'boolean', 'indicator', false);
1003
1160
  await ensure('emsTickFresh', 'EMS-Regeltick aktuell', 'boolean', 'indicator', false);
1004
- await ensure('emsTickAgeMs', 'Alter des letzten EMS-Regelticks', 'number', 'value.interval', 0);
1161
+ await ensure('emsTickAgeMs', 'Alter der jüngsten EMS-Aktivität', 'number', 'value.interval', 0);
1005
1162
  await ensure('publisherHeartbeatAt', 'Diagnose-Publisher Heartbeat', 'number', 'value.time', 0);
1006
1163
  await ensure('publisherLastSuccessAt', 'Letzte vollständig veröffentlichte Diagnose', 'number', 'value.time', 0);
1007
1164
  await ensure('publisherStatus', 'Status des Diagnose-Publishers', 'string', 'text', 'initializing');
@@ -1051,7 +1208,8 @@ class AdminOverviewPublisher {
1051
1208
  'chargingManagement.wallboxCount', 'chargingManagement.summary.totalPowerW', 'chargingManagement.summary.totalTargetPowerW', 'chargingManagement.summary.totalReservedPowerW', 'chargingManagement.summary.lastUpdate',
1052
1209
  'chargingManagement.control.active', 'chargingManagement.control.status', 'chargingManagement.control.mode', 'chargingManagement.control.budgetW', 'chargingManagement.control.usedW', 'chargingManagement.control.remainingW',
1053
1210
  'chargingManagement.control.gridCapBinding', 'chargingManagement.control.phaseCapBinding', 'chargingManagement.control.para14aActive', 'chargingManagement.control.para14aBinding',
1054
- 'info.connection', 'ems.core.lastTickStart', 'ems.core.lastTickEnd', 'ems.core.lastTickDurationMs', 'ems.core.lastTickError',
1211
+ 'info.connection', 'ems.core.schedulerHeartbeatAt', 'ems.core.schedulerHeartbeatSequence', 'ems.core.schedulerAlive',
1212
+ 'ems.core.tickRunning', 'ems.core.lastTickStart', 'ems.core.lastTickEnd', 'ems.core.lastTickDurationMs', 'ems.core.lastTickError',
1055
1213
  'ems.safety.valid', 'ems.safety.emergencyStop', 'ems.safety.reason', 'ems.safety.gridHeadroomW', 'ems.safety.evcsCapW',
1056
1214
  'ems.budget.active', 'ems.budget.mode', 'ems.budget.source', 'ems.budget.lastUpdate', 'ems.budget.totalBudgetW', 'ems.budget.remainingTotalW', 'ems.budget.flexUsedW',
1057
1215
  'ems.budget.binding', 'ems.budget.gridW', 'ems.budget.gridImportW', 'ems.budget.gridExportW', 'ems.budget.pvPowerW',
@@ -1070,7 +1228,8 @@ class AdminOverviewPublisher {
1070
1228
  async primeVolatileStates() {
1071
1229
  const keys = [
1072
1230
  'chargingManagement.audit.snapshotJson', 'chargingManagement.audit.recentEventsJson',
1073
- 'info.connection', 'ems.core.lastTickStart', 'ems.core.lastTickEnd', 'ems.core.lastTickDurationMs', 'ems.core.lastTickError',
1231
+ 'info.connection', 'ems.core.schedulerHeartbeatAt', 'ems.core.schedulerHeartbeatSequence', 'ems.core.schedulerAlive',
1232
+ 'ems.core.tickRunning', 'ems.core.lastTickStart', 'ems.core.lastTickEnd', 'ems.core.lastTickDurationMs', 'ems.core.lastTickError',
1074
1233
  'ems.safety.valid', 'ems.safety.emergencyStop', 'ems.safety.reason',
1075
1234
  'ems.budget.totalBudgetW', 'ems.budget.remainingTotalW', 'ems.budget.flexUsedW', 'ems.budget.binding', 'ems.budget.remainingPvW',
1076
1235
  'gridConstraints.exportLimit.enabled', 'gridConstraints.exportLimit.diagnosticOnly', 'gridConstraints.exportLimit.exportOverLimitW', 'gridConstraints.exportLimit.statusLabel',
@@ -1125,6 +1284,13 @@ class AdminOverviewPublisher {
1125
1284
  .slice(-this.maxEvents);
1126
1285
  }
1127
1286
  async publish(contract) {
1287
+ contract.updatedAt = Math.max(contract.updatedAt, this.lastHeartbeatAt);
1288
+ if (contract.publisher && typeof contract.publisher === 'object') {
1289
+ contract.publisher.heartbeatAt = Math.max(finite(contract.publisher.heartbeatAt, 0), this.lastHeartbeatAt);
1290
+ contract.publisher.fullSnapshotAt = this.fullSnapshotAt || contract.generatedAt;
1291
+ contract.publisher.snapshotAgeMs = 0;
1292
+ }
1293
+ this.lastContract = contract;
1128
1294
  try {
1129
1295
  this.adapter._nwAdminOverview = contract;
1130
1296
  }
@@ -1150,7 +1316,9 @@ class AdminOverviewPublisher {
1150
1316
  // `updatedAt` heartbeat has already proven publisher liveness at cycle start.
1151
1317
  const summaryWritten = results.some((entry) => entry.key === 'summaryJson' && entry.ok);
1152
1318
  if (summaryWritten) {
1153
- await this.setIfChanged('info.adminOverview.publisherLastSuccessAt', Date.now(), true);
1319
+ const completedAt = Date.now();
1320
+ this.lastSummaryRefreshAt = completedAt;
1321
+ await this.setIfChanged('info.adminOverview.publisherLastSuccessAt', completedAt, true);
1154
1322
  }
1155
1323
  return summaryWritten;
1156
1324
  }
@@ -1176,4 +1344,5 @@ module.exports = {
1176
1344
  isInformationalLimiter,
1177
1345
  activeLimiterForDisplay,
1178
1346
  humanizeLimiter,
1347
+ newestTimestamp,
1179
1348
  };
package/io-package.json CHANGED
@@ -1,8 +1,13 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "nexowatt-ui",
4
- "version": "1.0.1",
4
+ "version": "1.0.2",
5
5
  "news": {
6
+ "1.0.2": {
7
+ "de": "Stable 1.0.2 trennt Adapter-Erreichbarkeit, EMS-Scheduler, Regelzyklus und Diagnose-Publisher eindeutig. Unabhängige 4-Sekunden-Heartbeats verhindern die falsche Anzeige „Offline / veraltet“ bei legitimen 20–30-Sekunden-Regelzyklen. Ein über 30 Sekunden laufender Zyklus wird als Warnung „Regelzyklus überschreitet Zeitlimit“ angezeigt, während ein gestoppter Adapter oder HTTP-Dienst weiterhin zuverlässig offline wird. Netzlimit, Nulleinspeisung, Lade-, Speicher-, §14a-, Tarif-, Export-Guard- und Hardware-Regelung bleiben unverändert.",
8
+ "en": "Stable 1.0.2 clearly separates adapter connectivity, EMS scheduler liveness, regulation-cycle health and the diagnostic publisher. Independent four-second heartbeats prevent false Offline/Stale indications during legitimate 20–30 second control cycles. A cycle running beyond 30 seconds is shown as a regulation timeout warning, while a stopped adapter or HTTP service is still reliably reported offline. Grid limit, zero export, charging, storage, §14a, tariff, export guard and hardware control remain unchanged.",
9
+ "nl": "Stable 1.0.2 scheidt adapterbereikbaarheid, EMS-scheduler, regelcyclus en diagnosepublisher duidelijk. Onafhankelijke heartbeats van vier seconden voorkomen onterechte Offline/Verouderd-meldingen tijdens legitieme regelcycli van 20–30 seconden. Een cyclus langer dan 30 seconden verschijnt als waarschuwing voor overschrijding van de tijdslimiet, terwijl een gestopte adapter of HTTP-dienst nog steeds betrouwbaar offline wordt gemeld. Netlimiet, nulinvoeding, laad-, opslag-, §14a-, tarief-, exportguard- en hardware-regeling blijven ongewijzigd."
10
+ },
6
11
  "1.0.1": {
7
12
  "de": "Stable 1.0.1 verhindert falsche Offline-/Veraltet-Anzeigen der EOS-Übersicht durch eine zu aggressive Speicherentlastung. Schnelles Heap-Wachstum bei niedriger Auslastung bleibt nur Diagnosewert und löst keine Warnung oder SSE-Trennung mehr aus. Normale Speicherdruckbehandlung trennt nur wirklich blockierte oder stark gepufferte Clients und setzt keine globale Reconnect-Sperre; die kritische Sperre ist auf höchstens 10 Sekunden begrenzt. EMS-, NVP-, Lade-, Speicher-, Netzlimit-, §14a- und Hardware-Regelung bleiben unverändert.",
8
13
  "en": "Stable 1.0.1 prevents false Offline/Stale states in the EOS overview caused by overly aggressive memory relief. Rapid heap growth at low utilization remains diagnostic telemetry and no longer triggers warnings or SSE disconnects. Normal pressure handling closes only truly blocked or heavily buffered clients and sets no global reconnect lockout; the critical lockout is limited to 10 seconds. EMS, point-of-connection, charging, storage, grid-limit, §14a and hardware control remain unchanged.",
@@ -32,11 +37,6 @@
32
37
  "de": "RC82 macht Netzlimits zum dauerhaft aktiven, nicht abschaltbaren Kernschutz – unabhängig von alten AppCenter-, Legacy-, Backup- oder Lizenzzuständen. Netzanschlussleistung und signierter NVP stammen ausschließlich aus Zuordnung → Allgemein; Hard-Limit = 100 %, Soft-Limit = 90 % und Reserve = exakt 10 %. Die 0-Einspeisung bleibt separat optional. Der wiederkehrende Core-Limits-Shadow-Warnlog zu total.effectiveW ist bereinigt; die interne Diagnose bleibt ohne Log-Spam erhalten.",
33
38
  "en": "RC82 makes Grid Limits a permanently active core protection function that cannot be disabled by legacy App Center, configuration, backup or licence states. Grid connection power and signed point-of-connection measurement come exclusively from Assignment → General; hard limit is 100%, soft limit 90%, and reserve exactly 10%. Zero export remains separately optional. The recurring Core Limits shadow warning for total.effectiveW has been removed while internal diagnostics remain available without log spam.",
34
39
  "nl": "RC82 maakt Netlimieten tot een permanent actieve kernbeveiliging die niet kan worden uitgeschakeld door oude AppCenter-, configuratie-, backup- of licentiestatussen. Netaansluitvermogen en gesigneerde NVP komen uitsluitend uit Toewijzing → Algemeen; hardlimit = 100%, softlimit = 90% en reserve exact 10%. Nulteruglevering blijft afzonderlijk optioneel. De terugkerende Core-Limits-shadowwaarschuwing voor total.effectiveW is verwijderd; interne diagnose blijft zonder logspam beschikbaar."
35
- },
36
- "0.8.206": {
37
- "de": "RC81 macht Zuordnung → Allgemein zur einzigen statischen Quelle für Netzanschlussleistung und signierte NVP-Messung. Das Hard-Limit entspricht 100 % der dort eingetragenen Anschlussleistung, das Soft-Limit automatisch 90 % und die Reserve 10 %. Das AppCenter unter Netzlimits enthält kein zweites Hard-Limit und keinen zweiten NVP-Datenpunkt mehr. Alte importHardLimitW-/gridPowerId-Overrides sowie Peak-Shaving-Legacy-Fallbacks werden ignoriert; RLM darf die zentrale Grenze ausschließlich absenken.",
38
- "en": "RC81 makes Assignment → General the single static source for grid connection power and the signed point-of-connection measurement. The hard limit is 100% of the assigned connection power, the soft limit is automatically 90%, and the reserve is 10%. Grid Limits no longer exposes a second hard limit or point-of-connection datapoint. Legacy importHardLimitW/gridPowerId overrides and peak-shaving fallbacks are ignored; RLM may only reduce the central limit.",
39
- "nl": "RC81 maakt Toewijzing → Algemeen de enige statische bron voor het netaansluitvermogen en de gesigneerde NVP-meting. De hardlimit is 100% van het toegewezen aansluitvermogen, de softlimit automatisch 90% en de reserve 10%. Onder Netlimieten bestaat geen tweede hardlimit of NVP-datapunt meer. Oude importHardLimitW-/gridPowerId-overrides en peak-shaving-fallbacks worden genegeerd; RLM mag de centrale grens alleen verlagen."
40
40
  }
41
41
  },
42
42
  "title": "NexoWatt EOS",
package/main.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * AUTO-GENERATED RUNTIME FILE - NICHT MANUELL BEARBEITEN.
3
3
  *
4
4
  * Quelle: src-ts/runtime-executables/main.ts
5
- * Quell-Hash: sha256:8c40b483bb1e0112dfd2678210829177ff7b391fc86e3f9fb64b34c225c37d08
5
+ * Quell-Hash: sha256:5312b4a46ed165db44cff80876611e300c118455ac78dcd0f9ce4f62d7b2c9b6
6
6
  * Erzeugung: npm run sync:ts-runtime-executables
7
7
  *
8
8
  * Zweck:
@@ -712,10 +712,13 @@ class NexoWattVis extends utils.Adapter {
712
712
  if (this._nwShuttingDown || this._nwConnectionHeartbeatTimer) return;
713
713
  this._nwConnectionHeartbeatTimer = this._nwSetInterval(() => {
714
714
  const online = this._nwIsHttpServerListening();
715
- // Re-assert the state regularly. ioBroker/Admin updates or failed optional startup
716
- // blocks must not leave info.connection false while the HTTP/SSE service is alive.
715
+ // Re-assert the state every four seconds. EOS Admin uses a roughly
716
+ // 20-second stale window, so the former 30-second cadence inevitably
717
+ // oscillated between online and stale on otherwise healthy systems.
718
+ // A stopped process or HTTP server still stops/negates this heartbeat and
719
+ // is therefore reported as genuinely offline.
717
720
  this._nwSetInfoConnection(online, online ? 'heartbeat' : 'heartbeat-offline').catch(() => {});
718
- }, 30000);
721
+ }, 4000);
719
722
  }
720
723
  /** Code-Teil: _nwStopConnectionHeartbeat – bestehender Helfer; Aufrufer und State-/API-Verträge bei Änderungen mitprüfen. */
721
724
  _nwStopConnectionHeartbeat() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.nexowatt-ui",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
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-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-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",
@@ -479,7 +479,8 @@
479
479
  "test:rc91": "node scripts/verify-rc91-cross-app-catalog.js",
480
480
  "test:rc92": "node scripts/verify-rc92-history-mobile.cjs",
481
481
  "test:rc93": "node scripts/verify-rc93-certified-export-authority.cjs",
482
- "test:stable-release": "node scripts/verify-stable-release.cjs"
482
+ "test:stable-release": "node scripts/verify-stable-release.cjs",
483
+ "test:stable-1.0.2-health": "node scripts/verify-stable-1.0.2-health-heartbeat.cjs"
483
484
  },
484
485
  "dependencies": {
485
486
  "@iobroker/adapter-core": "^3.4.1",
@@ -565,6 +566,7 @@
565
566
  "docs/RC93_CERTIFIED_EXPORT_AUTHORITY_DE.md",
566
567
  "docs/STABLE_1_0_0_RELEASE_DE.md",
567
568
  "docs/STABLE_1_0_1_RELEASE_DE.md",
569
+ "docs/STABLE_1_0_2_RELEASE_DE.md",
568
570
  "ems/charging-budget-helpers.js",
569
571
  "ems/consumers/evcs.js",
570
572
  "ems/consumers/generic-load.js",
@@ -723,6 +725,7 @@
723
725
  "scripts/verify-rc92-history-mobile.cjs",
724
726
  "scripts/verify-rc93-certified-export-authority.cjs",
725
727
  "scripts/verify-stable-release.cjs",
728
+ "scripts/verify-stable-1.0.2-health-heartbeat.cjs",
726
729
  "www/admin-guard.js",
727
730
  "www/admin.png",
728
731
  "www/app.js",
@@ -201,7 +201,7 @@ async function main() {
201
201
  const sources = [runtimeSource];
202
202
  if (fs.existsSync(canonicalPath)) sources.push(fs.readFileSync(canonicalPath, 'utf8'));
203
203
  for (const source of sources) {
204
- assert(source.includes('lightweight publisher heartbeat'));
204
+ assert(source.includes('Independent liveness heartbeat') || source.includes('Independent compatibility heartbeat'));
205
205
  assert(source.includes('adapter online'));
206
206
  assert(source.includes('read-only overview forever'));
207
207
  assert(!source.includes('const emsOnline ='));
@@ -0,0 +1,260 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ /**
5
+ * Stable 1.0.2 regression contract
6
+ *
7
+ * Reproduces the field symptom where EOS Admin switched to "Offline / veraltet"
8
+ * after roughly 20 seconds although the adapter and EMS scheduler were alive.
9
+ * It verifies independent adapter, scheduler, regulation-tick and diagnostics
10
+ * heartbeats as well as a genuine offline state.
11
+ */
12
+ const assert = require('node:assert/strict');
13
+ const fs = require('node:fs');
14
+ const path = require('node:path');
15
+
16
+ const root = path.resolve(__dirname, '..');
17
+ const pkg = require(path.join(root, 'package.json'));
18
+ const {
19
+ AdminOverviewPublisher,
20
+ buildOverviewContract,
21
+ newestTimestamp,
22
+ } = require(path.join(root, 'ems/services/admin-overview-publisher.js'));
23
+ const { EmsEngine } = require(path.join(root, 'ems/engine.js'));
24
+
25
+ function cache(values, now = Date.now()) {
26
+ return Object.fromEntries(Object.entries(values).map(([key, value]) => [key, { value, ts: now }]));
27
+ }
28
+
29
+ function contractAdapter(values, extra = {}) {
30
+ return {
31
+ namespace: 'nexowatt-ui.0',
32
+ version: pkg.version,
33
+ packageVersion: pkg.version,
34
+ config: { port: 8188 },
35
+ stateCache: cache(values),
36
+ ...extra,
37
+ };
38
+ }
39
+
40
+ function baseValues(now) {
41
+ return {
42
+ 'info.connection': true,
43
+ 'ems.core.schedulerHeartbeatAt': now - 500,
44
+ 'ems.core.schedulerAlive': true,
45
+ 'ems.core.tickRunning': true,
46
+ 'ems.core.lastTickStart': now - 25_000,
47
+ 'ems.core.lastTickEnd': now - 28_000,
48
+ 'ems.core.lastTickDurationMs': 2_608,
49
+ 'ems.core.lastTickError': '',
50
+ 'ems.safety.valid': true,
51
+ 'ems.safety.emergencyStop': false,
52
+ 'ems.budget.active': true,
53
+ 'ems.budget.totalBudgetW': 29_980,
54
+ 'ems.budget.remainingTotalW': 29_980,
55
+ 'ems.budget.binding': 'none',
56
+ };
57
+ }
58
+
59
+ const now = Date.now();
60
+ const fieldCase = buildOverviewContract(contractAdapter(baseValues(now)), now);
61
+ assert.equal(fieldCase.adapter.online, true, 'field case adapter must remain online');
62
+ assert.equal(fieldCase.ems.schedulerFresh, true, 'independent scheduler heartbeat must be fresh');
63
+ assert.equal(fieldCase.ems.tickRunning, true, '25-second regulation cycle is still running');
64
+ assert.equal(fieldCase.ems.activeTickAgeMs, 25_000);
65
+ assert.equal(fieldCase.ems.tickStalled, false, '25 seconds is below the 30-second watchdog');
66
+ assert.equal(fieldCase.ems.tickFresh, true, 'running cycle remains healthy until watchdog threshold');
67
+ assert.equal(fieldCase.ems.health, 'ok');
68
+ assert.notEqual(fieldCase.status, 'error');
69
+ assert.doesNotMatch(fieldCase.headline, /offline|nicht aktuell|veraltet/i);
70
+
71
+ const stalledValues = baseValues(now);
72
+ stalledValues['ems.core.lastTickStart'] = now - 35_000;
73
+ stalledValues['ems.core.lastTickEnd'] = now - 38_000;
74
+ const stalled = buildOverviewContract(contractAdapter(stalledValues), now);
75
+ assert.equal(stalled.adapter.online, true);
76
+ assert.equal(stalled.ems.schedulerFresh, true);
77
+ assert.equal(stalled.ems.tickStalled, true);
78
+ assert.equal(stalled.ems.health, 'tick-stalled');
79
+ assert.equal(stalled.status, 'warning');
80
+ assert.match(stalled.headline, /Adapter online.*Regelzyklus.*Zeitlimit/i);
81
+ assert.doesNotMatch(stalled.headline, /offline/i);
82
+
83
+ const schedulerStaleValues = baseValues(now);
84
+ schedulerStaleValues['ems.core.schedulerHeartbeatAt'] = now - 20_000;
85
+ schedulerStaleValues['ems.core.tickRunning'] = false;
86
+ schedulerStaleValues['ems.core.lastTickEnd'] = now - 2_000;
87
+ const schedulerStale = buildOverviewContract(contractAdapter(schedulerStaleValues), now);
88
+ assert.equal(schedulerStale.adapter.online, true);
89
+ assert.equal(schedulerStale.ems.schedulerFresh, false);
90
+ assert.equal(schedulerStale.ems.health, 'scheduler-stale');
91
+ assert.equal(schedulerStale.status, 'warning');
92
+ assert.match(schedulerStale.headline, /Adapter online.*Scheduler/i);
93
+ assert.doesNotMatch(schedulerStale.headline, /offline/i);
94
+
95
+ const offlineValues = baseValues(now);
96
+ offlineValues['info.connection'] = false;
97
+ const offline = buildOverviewContract(contractAdapter(offlineValues), now);
98
+ assert.equal(offline.adapter.online, false, 'info.connection=false is authoritative');
99
+ assert.equal(offline.ems.online, false);
100
+ assert.equal(offline.status, 'error');
101
+ assert.match(offline.headline, /offline/i);
102
+
103
+ const timestampAdapter = contractAdapter({
104
+ older: now - 25_000,
105
+ newer: now - 500,
106
+ });
107
+ assert.equal(newestTimestamp(timestampAdapter, ['older', 'newer']), now - 500,
108
+ 'newest activity timestamp must win instead of first populated key');
109
+
110
+ function createPublisherMock() {
111
+ const stateCache = cache(baseValues(Date.now()));
112
+ const writes = [];
113
+ const intervals = [];
114
+ const cleared = [];
115
+ const adapter = {
116
+ namespace: 'nexowatt-ui.0',
117
+ version: pkg.version,
118
+ packageVersion: pkg.version,
119
+ config: { port: 8188 },
120
+ stateCache,
121
+ _nwShuttingDown: false,
122
+ log: { warn() {}, error() {}, debug() {} },
123
+ subscribeForeignStatesAsync: async () => undefined,
124
+ setObjectNotExistsAsync: async () => undefined,
125
+ getStateAsync: async (id) => ({ val: stateCache[id]?.value ?? null, ts: stateCache[id]?.ts ?? Date.now() }),
126
+ setStateAsync: async (id, payload) => {
127
+ writes.push([id, payload, Date.now()]);
128
+ stateCache[id] = { value: payload.val, ts: Date.now() };
129
+ },
130
+ updateValue: (id, value, ts) => { stateCache[id] = { value, ts }; },
131
+ _nwSetInterval: (callback, ms) => {
132
+ const timer = { callback, ms, id: intervals.length + 1 };
133
+ intervals.push(timer);
134
+ return timer;
135
+ },
136
+ _nwClearInterval: (timer) => { cleared.push(timer); },
137
+ };
138
+ return { adapter, stateCache, writes, intervals, cleared };
139
+ }
140
+
141
+ async function verifyPublisherHeartbeat() {
142
+ const mock = createPublisherMock();
143
+ const publisher = new AdminOverviewPublisher(mock.adapter, {
144
+ intervalMs: 5_000,
145
+ heartbeatIntervalMs: 4_000,
146
+ readTimeoutMs: 100,
147
+ writeTimeoutMs: 100,
148
+ objectTimeoutMs: 100,
149
+ tickFreshThresholdMs: 30_000,
150
+ schedulerFreshThresholdMs: 12_000,
151
+ });
152
+ await publisher.initialize();
153
+
154
+ assert(mock.intervals.some((timer) => timer.ms === 4_000), 'independent 4-second overview heartbeat timer missing');
155
+ assert(mock.intervals.some((timer) => timer.ms === 5_000), 'full 5-second overview refresh timer missing');
156
+
157
+ // Simulate the exact field window: the expensive full refresh is still active
158
+ // after 25 seconds, while the independent scheduler heartbeat remains current.
159
+ publisher.running = true;
160
+ publisher.runningSince = Date.now() - 25_000;
161
+ publisher.lastSummaryRefreshAt = Date.now() - 25_000;
162
+ const t = Date.now();
163
+ mock.stateCache['info.connection'] = { value: true, ts: t };
164
+ mock.stateCache['ems.core.schedulerHeartbeatAt'] = { value: t - 300, ts: t - 300 };
165
+ mock.stateCache['ems.core.tickRunning'] = { value: true, ts: t - 25_000 };
166
+ mock.stateCache['ems.core.lastTickStart'] = { value: t - 25_000, ts: t - 25_000 };
167
+ mock.stateCache['ems.core.lastTickEnd'] = { value: t - 28_000, ts: t - 28_000 };
168
+ await publisher.heartbeat('field-25s', true);
169
+
170
+ const updatedAt = mock.writes.filter(([id]) => id === 'info.adminOverview.updatedAt').at(-1);
171
+ assert(updatedAt, 'updatedAt heartbeat was not written while full cycle was running');
172
+ assert(Date.now() - Number(updatedAt[1].val) < 2_000, 'updatedAt heartbeat is not current');
173
+
174
+ const summaryWrite = mock.writes.filter(([id]) => id === 'info.adminOverview.summaryJson').at(-1);
175
+ assert(summaryWrite, 'compatibility summary heartbeat missing');
176
+ const summary = JSON.parse(summaryWrite[1].val);
177
+ assert.equal(summary.adapter.online, true);
178
+ assert.equal(summary.ems.schedulerFresh, true);
179
+ assert.equal(summary.ems.tickRunning, true);
180
+ assert.equal(summary.ems.tickStalled, false);
181
+ assert.doesNotMatch(summary.headline, /offline|nicht aktuell|veraltet/i);
182
+ assert(Date.now() - Number(summary.updatedAt) < 2_000, 'summary heartbeat timestamp is not current');
183
+
184
+ // Real loss of adapter connectivity must still be red/offline immediately.
185
+ mock.stateCache['info.connection'] = { value: false, ts: Date.now() };
186
+ await publisher.heartbeat('real-offline', true);
187
+ const offlineSummaryWrite = mock.writes.filter(([id]) => id === 'info.adminOverview.summaryJson').at(-1);
188
+ const offlineSummary = JSON.parse(offlineSummaryWrite[1].val);
189
+ assert.equal(offlineSummary.adapter.online, false);
190
+ assert.equal(offlineSummary.status, 'error');
191
+ assert.match(offlineSummary.headline, /offline/i);
192
+
193
+ publisher.running = false;
194
+ publisher.stop();
195
+ assert.equal(mock.cleared.length, 2, 'both heartbeat and full-refresh timers must be cleared on stop');
196
+ }
197
+
198
+ async function verifyEngineHeartbeat() {
199
+ const writes = [];
200
+ const intervals = [];
201
+ const cleared = [];
202
+ const adapter = {
203
+ _nwShuttingDown: false,
204
+ config: { diagnostics: { emsTickStaleAfterMs: 30_000 } },
205
+ setStateAsync: async (id, payload) => { writes.push([id, payload]); },
206
+ setInterval: (callback, ms) => {
207
+ const timer = { callback, ms, id: intervals.length + 1 };
208
+ intervals.push(timer);
209
+ return timer;
210
+ },
211
+ clearInterval: (timer) => { cleared.push(timer); },
212
+ };
213
+ const engine = new EmsEngine(adapter);
214
+ engine._tickRunning = true;
215
+ engine._lastTickStartMs = Date.now() - 25_000;
216
+ await engine._publishSchedulerHeartbeat('regression');
217
+ assert(adapter._nwEmsSchedulerHealth, 'local scheduler health object missing');
218
+ assert.equal(adapter._nwEmsSchedulerHealth.tickRunning, true);
219
+ assert.equal(adapter._nwEmsSchedulerHealth.tickStalled, false);
220
+ assert(writes.some(([id]) => id === 'ems.core.schedulerHeartbeatAt'));
221
+ assert(writes.some(([id]) => id === 'ems.core.schedulerAlive'));
222
+
223
+ engine._startSchedulerHeartbeat();
224
+ assert(intervals.some((timer) => timer.ms === 4_000), 'engine scheduler heartbeat timer must use four seconds');
225
+ engine.stop();
226
+ assert(cleared.some((timer) => timer.ms === 4_000), 'engine scheduler heartbeat timer must be cleared');
227
+ }
228
+
229
+ async function main() {
230
+ assert.equal(pkg.version, '1.0.2', 'regression contract must run for Stable 1.0.2');
231
+ await verifyPublisherHeartbeat();
232
+ await verifyEngineHeartbeat();
233
+
234
+ const canonicalOverview = fs.readFileSync(path.join(root, 'src-ts/runtime-executables/ems/services/admin-overview-publisher.ts'), 'utf8');
235
+ const runtimeOverview = fs.readFileSync(path.join(root, 'ems/services/admin-overview-publisher.js'), 'utf8');
236
+ const canonicalEngine = fs.readFileSync(path.join(root, 'src-ts/runtime-executables/ems/engine.ts'), 'utf8');
237
+ const canonicalMain = fs.readFileSync(path.join(root, 'src-ts/runtime-executables/main.ts'), 'utf8');
238
+ for (const source of [canonicalOverview, runtimeOverview]) {
239
+ assert(source.includes('Independent compatibility heartbeat for EOS Admin'));
240
+ assert(source.includes('summaryRefreshThresholdMs'));
241
+ assert(source.includes('newestTimestamp'));
242
+ assert(source.includes('emsSchedulerHeartbeatAt'));
243
+ }
244
+ assert(canonicalEngine.includes('_schedulerHeartbeatIntervalMs = 4000'));
245
+ assert(canonicalEngine.includes("_publishSchedulerHeartbeat('timer')"));
246
+ const heartbeatBlock = canonicalMain.slice(
247
+ canonicalMain.indexOf('_nwStartConnectionHeartbeat()'),
248
+ canonicalMain.indexOf('_nwStopConnectionHeartbeat()'),
249
+ );
250
+ assert(heartbeatBlock.includes('}, 4000);'), 'info.connection heartbeat must be four seconds');
251
+ assert(!heartbeatBlock.includes('}, 30000);'), '30-second info.connection heartbeat must be removed');
252
+
253
+ console.log('[Stable 1.0.2] OK: 25-s field cycle remains online; scheduler stall and genuine offline state stay distinguishable.');
254
+ console.log('[Stable 1.0.2] OK: independent 4-s adapter, scheduler and overview heartbeat lifecycle verified.');
255
+ }
256
+
257
+ main().catch((error) => {
258
+ console.error(error && error.stack ? error.stack : error);
259
+ process.exit(1);
260
+ });
@@ -42,7 +42,11 @@ if (newsVersions[0] !== version) fail(`Aktuelle Stable-Version ${version} ist ni
42
42
  if (newsVersions.length > 7) fail(`io-package.json enthält ${newsVersions.length} News-Einträge; maximal 7 sind zulässig.`);
43
43
 
44
44
  const files = Array.isArray(pkg.files) ? pkg.files : [];
45
- for (const required of [stableDocPath, 'scripts/verify-stable-release.cjs']) {
45
+ for (const required of [
46
+ stableDocPath,
47
+ 'scripts/verify-stable-release.cjs',
48
+ 'scripts/verify-stable-1.0.2-health-heartbeat.cjs',
49
+ ]) {
46
50
  if (!files.includes(required)) fail(`Stable-Paketdatei fehlt in package.json files: ${required}`);
47
51
  if (!fs.existsSync(path.join(root, required))) fail(`Stable-Paketdatei fehlt im Repository: ${required}`);
48
52
  if (!releaseManifest.files.some((entry) => entry.path === required)) fail(`Stable-Paketdatei fehlt im Release-Manifest: ${required}`);
@@ -50,6 +54,12 @@ for (const required of [stableDocPath, 'scripts/verify-stable-release.cjs']) {
50
54
  if (pkg.scripts?.['test:stable-release'] !== 'node scripts/verify-stable-release.cjs') {
51
55
  fail('test:stable-release ist nicht korrekt registriert.');
52
56
  }
57
+ if (pkg.scripts?.['test:stable-1.0.2-health'] !== 'node scripts/verify-stable-1.0.2-health-heartbeat.cjs') {
58
+ fail('test:stable-1.0.2-health ist nicht korrekt registriert.');
59
+ }
60
+ if (!String(pkg.scripts?.['test:all'] || '').includes('npm run test:stable-1.0.2-health')) {
61
+ fail('test:stable-1.0.2-health ist nicht Bestandteil von test:all.');
62
+ }
53
63
  if (!String(pkg.scripts?.['test:all'] || '').includes('npm run test:stable-release')) {
54
64
  fail('test:stable-release ist nicht Bestandteil von test:all.');
55
65
  }
@@ -121,6 +131,38 @@ if (!sseSource.includes('[sse-guard]')) {
121
131
  fail('Versionsneutrale SSE-Guard-Logkennzeichnung fehlt.');
122
132
  }
123
133
 
134
+ // Stable 1.0.2: adapter liveness, EMS scheduler, regulation tick and
135
+ // diagnostic publisher must be independent. This prevents the former 20/30-s
136
+ // oscillation without hiding a genuine adapter or HTTP-server outage.
137
+ const overviewSource = read('src-ts/runtime-executables/ems/services/admin-overview-publisher.ts');
138
+ const engineSource = read('src-ts/runtime-executables/ems/engine.ts');
139
+ const healthRegression = read('scripts/verify-stable-1.0.2-health-heartbeat.cjs');
140
+ if (!overviewSource.includes('DEFAULT_HEARTBEAT_INTERVAL_MS = 4_000')) {
141
+ fail('Unabhängiger Vier-Sekunden-Heartbeat des Diagnose-Publishers fehlt.');
142
+ }
143
+ for (const token of ['Independent compatibility heartbeat for EOS Admin', 'newestTimestamp', 'emsSchedulerHeartbeatAt', 'emsTickStalled', 'summaryRefreshThresholdMs']) {
144
+ if (!overviewSource.includes(token)) fail(`1.0.2-Übersichtsvertrag fehlt: ${token}`);
145
+ }
146
+ if (!engineSource.includes('this._schedulerHeartbeatIntervalMs = 4000')
147
+ || !engineSource.includes("_publishSchedulerHeartbeat('timer')")
148
+ || !engineSource.includes('ems.core.schedulerHeartbeatAt')) {
149
+ fail('Unabhängiger Vier-Sekunden-Heartbeat des EMS-Schedulers fehlt.');
150
+ }
151
+ const connectionHeartbeatStart = mainSource.indexOf('_nwStartConnectionHeartbeat()');
152
+ const connectionHeartbeatEnd = mainSource.indexOf('_nwStopConnectionHeartbeat()');
153
+ const connectionHeartbeatBlock = connectionHeartbeatStart >= 0 && connectionHeartbeatEnd > connectionHeartbeatStart
154
+ ? mainSource.slice(connectionHeartbeatStart, connectionHeartbeatEnd)
155
+ : '';
156
+ if (!connectionHeartbeatBlock.includes('}, 4000);')) {
157
+ fail('info.connection wird nicht im Vier-Sekunden-Takt bestätigt.');
158
+ }
159
+ if (connectionHeartbeatBlock.includes('}, 30000);')) {
160
+ fail('Alte 30-Sekunden-info.connection-Taktung ist noch aktiv.');
161
+ }
162
+ for (const token of ['25_000', '35_000', "offlineValues['info.connection'] = false", 'heartbeatIntervalMs: 4_000']) {
163
+ if (!healthRegression.includes(token)) fail(`1.0.2-Feldregression unvollständig: ${token}`);
164
+ }
165
+
124
166
  const rc66Verifier = read('scripts/verify-rc66-station-display-stable.js');
125
167
  if (!rc66Verifier.includes("isVersionAtLeast(pkg.version, '0.8.191')")) {
126
168
  fail('RC66-Prüfer besitzt keinen SemVer-festen Mindestversionsvergleich.');
@@ -130,4 +172,4 @@ if (/versionParts\[0\]\s*!==\s*0/.test(rc66Verifier)) {
130
172
  }
131
173
 
132
174
  console.log(`[stable-release] OK: ${pkg.name}@${version} ist konsistent als Official Stable versiegelt.`);
133
- console.log('[stable-release] OK: 1.0.1-Memory-/SSE-Patch, RC93-Regelungsbaseline und Release-Kennzeichnungen sind synchron.');
175
+ console.log('[stable-release] OK: 1.0.2-Liveness-/Tick-Patch, 1.0.1-Memory-/SSE-Härtung und RC93-Regelungsbaseline sind synchron.');
@@ -44,6 +44,6 @@
44
44
  "purpose": "maskable"
45
45
  }
46
46
  ],
47
- "version": "1.0.1",
48
- "appVersion": "1.0.1"
47
+ "version": "1.0.2",
48
+ "appVersion": "1.0.2"
49
49
  }