iobroker.eos-admin 9.0.34 → 9.0.36

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.
Files changed (234) hide show
  1. package/NEXOWATT_EOS_BUILD_INFO.json +10 -10
  2. package/README.md +16 -4
  3. package/adminWww/.vite/manifest.json +39 -39
  4. package/adminWww/NEXOWATT_EOS_FRONTEND_MANIFEST.json +107 -107
  5. package/adminWww/assets/{AdapterUpdateDialog-5L75o18m.js → AdapterUpdateDialog-D2nDWE_N.js} +1 -1
  6. package/adminWww/assets/{Adapters-FcghjF7E.js → Adapters-D0sVqNBU.js} +1 -1
  7. package/adminWww/assets/{ConfigManager-BnHarBfH.js → ConfigManager-Zm7UoaaN.js} +1 -1
  8. package/adminWww/assets/{Enums-BjLbLLQL.js → Enums-BGL7pR-O.js} +1 -1
  9. package/adminWww/assets/{Fields-DDE1hVOa.js → Fields-A8J3u1yq.js} +1 -1
  10. package/adminWww/assets/{Files-CDjnR4q6.js → Files-CQPjCvW6.js} +1 -1
  11. package/adminWww/assets/{Hosts-CJKQaNrD.js → Hosts-CxzkkNBj.js} +1 -1
  12. package/adminWww/assets/{Instances-DZNl369k.js → Instances-eEbEukDh.js} +1 -1
  13. package/adminWww/assets/{Intro-CjAmMGDB.js → Intro-I_Tknp0E.js} +1 -1
  14. package/adminWww/assets/{Logs-rUAV7SwM.js → Logs-C3GPz61Q.js} +1 -1
  15. package/adminWww/assets/{Objects-CqOH6rT_.js → Objects-DDnisxNB.js} +1 -1
  16. package/adminWww/assets/{Overview-BOtXqsMy.js → Overview-BpZFdEmp.js} +1 -1
  17. package/adminWww/assets/{State-C8ncThop.js → State-DY6Nw0SB.js} +1 -1
  18. package/adminWww/assets/{UsedResources-lUYJqy4F.js → UsedResources-CtUpdP2b.js} +1 -1
  19. package/adminWww/assets/{Users-CK1Cax82.js → Users-DcqlSfc5.js} +1 -1
  20. package/adminWww/assets/{bootstrap-CC0Qr-kr.js → bootstrap-Didkuj-F.js} +3 -3
  21. package/adminWww/assets/{hostInit-DqGL6nY8.js → hostInit-Chrs-wsg.js} +1 -1
  22. package/adminWww/assets/{icons-material-07rWS63O.js → icons-material-SqwOQW6y.js} +1 -1
  23. package/adminWww/assets/{index-BhhkToP2.js → index-CpDo61Mz.js} +2 -2
  24. package/adminWww/assets/{installSVGRenderer-B4-7lSQZ.js → installSVGRenderer-DZMZ3pJw.js} +1 -1
  25. package/adminWww/assets/{mf-entry-bootstrap-0-1afd2287.js → mf-entry-bootstrap-0-b0c4981a.js} +2 -2
  26. package/adminWww/index.html +23 -23
  27. package/adminWww/mf-manifest.json +1 -1
  28. package/adminWww/mf-stats.json +1 -1
  29. package/adminWww/{remoteEntry-eos-9.0.34.js → remoteEntry-eos-9.0.36.js} +1 -1
  30. package/adminWww/remoteEntry.js +1 -1
  31. package/build/lib/eosDashboardProcessStatus.js +199 -0
  32. package/build/lib/eosDashboardProcessStatus.js.map +1 -0
  33. package/build/lib/eosKiosk.js +1 -0
  34. package/build/lib/eosKiosk.js.map +1 -1
  35. package/build/lib/eosLegacyMigration.js +142 -49
  36. package/build/lib/eosLegacyMigration.js.map +1 -1
  37. package/build/lib/eosLicenseService.js +9 -0
  38. package/build/lib/eosLicenseService.js.map +1 -1
  39. package/build/lib/eosModuleConfigStore.js +21 -8
  40. package/build/lib/eosModuleConfigStore.js.map +1 -1
  41. package/build/lib/eosModuleHost.js +284 -106
  42. package/build/lib/eosModuleHost.js.map +1 -1
  43. package/build/lib/eosModuleHttp.js +41 -8
  44. package/build/lib/eosModuleHttp.js.map +1 -1
  45. package/build/lib/eosModuleProcess.js +34 -6
  46. package/build/lib/eosModuleProcess.js.map +1 -1
  47. package/build/lib/eosModuleProcessWorker.js +56 -2
  48. package/build/lib/eosModuleProcessWorker.js.map +1 -1
  49. package/build/lib/eosRuntimeControl.js +54 -14
  50. package/build/lib/eosRuntimeControl.js.map +1 -1
  51. package/build/lib/eosRuntimeHealth.js +84 -7
  52. package/build/lib/eosRuntimeHealth.js.map +1 -1
  53. package/build/lib/eosSupervisorNotifications.js +169 -0
  54. package/build/lib/eosSupervisorNotifications.js.map +1 -0
  55. package/build/lib/eosUiProcess.js +43 -4
  56. package/build/lib/eosUiProcess.js.map +1 -1
  57. package/build/lib/eosUiProcessWorker.js +21 -0
  58. package/build/lib/eosUiProcessWorker.js.map +1 -1
  59. package/build/lib/eosUnifiedOwnership.js +10 -8
  60. package/build/lib/eosUnifiedOwnership.js.map +1 -1
  61. package/build/lib/web.js +33 -24
  62. package/build/lib/web.js.map +1 -1
  63. package/build/main.js +35 -0
  64. package/build/main.js.map +1 -1
  65. package/docs/README.md +2 -0
  66. package/docs/reports/unified-9.0.35/PRUEFBERICHT.md +51 -0
  67. package/docs/reports/unified-9.0.35/PRUEFERGEBNISSE.json +112 -0
  68. package/docs/reports/unified-9.0.35/raw/INDEX.json +282 -0
  69. package/docs/reports/unified-9.0.35/raw/backend.log +5 -0
  70. package/docs/reports/unified-9.0.35/raw/browser-lp-detail.log +1 -0
  71. package/docs/reports/unified-9.0.35/raw/browser-lp-feedback.log +1 -0
  72. package/docs/reports/unified-9.0.35/raw/cold-ocpp-22.log +108 -0
  73. package/docs/reports/unified-9.0.35/raw/cold-ocpp-24.log +24 -0
  74. package/docs/reports/unified-9.0.35/raw/core-final-node22.log +1439 -0
  75. package/docs/reports/unified-9.0.35/raw/core-final-node24.log +1381 -0
  76. package/docs/reports/unified-9.0.35/raw/dashboard-de-en-nl.json +716 -0
  77. package/docs/reports/unified-9.0.35/raw/device-chain-closed-fixed.json +98 -0
  78. package/docs/reports/unified-9.0.35/raw/device-chain-rst-fixed.json +98 -0
  79. package/docs/reports/unified-9.0.35/raw/device-chain.json +93 -0
  80. package/docs/reports/unified-9.0.35/raw/ee-fusion-final.log +12 -0
  81. package/docs/reports/unified-9.0.35/raw/eebus-monitor-browser.json +1 -0
  82. package/docs/reports/unified-9.0.35/raw/eebus-monitor-node22.log +206 -0
  83. package/docs/reports/unified-9.0.35/raw/eebus-monitor-node24.log +39 -0
  84. package/docs/reports/unified-9.0.35/raw/fixtures-verification.log +44 -0
  85. package/docs/reports/unified-9.0.35/raw/frontend.log +152 -0
  86. package/docs/reports/unified-9.0.35/raw/installer.log +26 -0
  87. package/docs/reports/unified-9.0.35/raw/legacy-mail-setup-browser.log +1 -0
  88. package/docs/reports/unified-9.0.35/raw/lint.log +45 -0
  89. package/docs/reports/unified-9.0.35/raw/live-ems-loss.log +10 -0
  90. package/docs/reports/unified-9.0.35/raw/modules.log +5 -0
  91. package/docs/reports/unified-9.0.35/raw/node22-mira-reconnect-integrity.log +452 -0
  92. package/docs/reports/unified-9.0.35/raw/node22-mira.log +222 -0
  93. package/docs/reports/unified-9.0.35/raw/node22-system-status.log +213 -0
  94. package/docs/reports/unified-9.0.35/raw/node22-tests-final.log +18137 -0
  95. package/docs/reports/unified-9.0.35/raw/node22-version.log +1 -0
  96. package/docs/reports/unified-9.0.35/raw/node24-mira-reconnect-integrity.log +79 -0
  97. package/docs/reports/unified-9.0.35/raw/node24-mira.log +41 -0
  98. package/docs/reports/unified-9.0.35/raw/node24-system-status.log +40 -0
  99. package/docs/reports/unified-9.0.35/raw/node24-tests-final.log +3019 -0
  100. package/docs/reports/unified-9.0.35/raw/node24-version.log +1 -0
  101. package/docs/reports/unified-9.0.35/raw/notifications-legacy-node22.log +1 -0
  102. package/docs/reports/unified-9.0.35/raw/notifications-legacy-node24.log +1 -0
  103. package/docs/reports/unified-9.0.35/raw/notifications-node22.log +67 -0
  104. package/docs/reports/unified-9.0.35/raw/notifications-node24.log +17 -0
  105. package/docs/reports/unified-9.0.35/raw/npm-runtime-audit.json +77 -0
  106. package/docs/reports/unified-9.0.35/raw/ocpp-dashboard-stations-node22.log +110 -0
  107. package/docs/reports/unified-9.0.35/raw/ocpp-dashboard-stations-node24.log +106 -0
  108. package/docs/reports/unified-9.0.35/raw/ocpp-history-node22.log +561 -0
  109. package/docs/reports/unified-9.0.35/raw/ocpp-history-node24.log +98 -0
  110. package/docs/reports/unified-9.0.35/raw/poll-life-node22.log +38 -0
  111. package/docs/reports/unified-9.0.35/raw/poll-life-node24.log +12 -0
  112. package/docs/reports/unified-9.0.35/raw/qa-source-check.log +2 -0
  113. package/docs/reports/unified-9.0.35/raw/release-metadata.log +13 -0
  114. package/docs/reports/unified-9.0.35/raw/sbom.log +8 -0
  115. package/docs/reports/unified-9.0.35/raw/typecheck.log +5 -0
  116. package/docs/reports/unified-9.0.35/raw/ui-runtime.log +8 -0
  117. package/docs/reports/unified-9.0.35/raw/vergleich-9.0.33.json +29 -0
  118. package/docs/reports/unified-9.0.35/raw/vergleich-9.0.34.json +249 -0
  119. package/docs/reports/unified-9.0.35/raw/vorher-9.0.33-chromium.json +286 -0
  120. package/docs/reports/unified-9.0.35/raw/vorher-9.0.34-chromium.json +291 -0
  121. package/docs/reports/unified-9.0.36/MIGRATION.md +25 -0
  122. package/docs/reports/unified-9.0.36/PRUEFBERICHT.md +61 -0
  123. package/docs/reports/unified-9.0.36/PRUEFERGEBNISSE.json +112 -0
  124. package/docs/reports/unified-9.0.36/raw/INDEX.json +262 -0
  125. package/docs/reports/unified-9.0.36/raw/admin-934-legacy-ui-reproduction.json +66 -0
  126. package/docs/reports/unified-9.0.36/raw/admin-936-legacy-ui-reproduction.json +64 -0
  127. package/docs/reports/unified-9.0.36/raw/admin-health-browser22.json +49 -0
  128. package/docs/reports/unified-9.0.36/raw/admin-health-browser24.json +49 -0
  129. package/docs/reports/unified-9.0.36/raw/admin-runtime-migration-browser22.json +80 -0
  130. package/docs/reports/unified-9.0.36/raw/admin-runtime-migration-browser24.json +80 -0
  131. package/docs/reports/unified-9.0.36/raw/backend.log +6 -0
  132. package/docs/reports/unified-9.0.36/raw/core-final-node22.log +1439 -0
  133. package/docs/reports/unified-9.0.36/raw/core-final-node24.log +1381 -0
  134. package/docs/reports/unified-9.0.36/raw/customer-934-node22-final.log +78 -0
  135. package/docs/reports/unified-9.0.36/raw/customer-934-node22-repeat.log +78 -0
  136. package/docs/reports/unified-9.0.36/raw/customer-935-node24-final.log +74 -0
  137. package/docs/reports/unified-9.0.36/raw/customer-935-node24-repeat.log +74 -0
  138. package/docs/reports/unified-9.0.36/raw/customer-admin-six-controls24.log +24 -0
  139. package/docs/reports/unified-9.0.36/raw/customer-earlier-pid-stop.log +22 -0
  140. package/docs/reports/unified-9.0.36/raw/customer-six-process-restart-node22.log +28 -0
  141. package/docs/reports/unified-9.0.36/raw/customer-six-process-restart-node24.log +24 -0
  142. package/docs/reports/unified-9.0.36/raw/dashboard-de-en-nl.json +728 -0
  143. package/docs/reports/unified-9.0.36/raw/fixtures-verification.log +44 -0
  144. package/docs/reports/unified-9.0.36/raw/frontend.log +152 -0
  145. package/docs/reports/unified-9.0.36/raw/installer.log +26 -0
  146. package/docs/reports/unified-9.0.36/raw/legacy-migration-node22.log +630 -0
  147. package/docs/reports/unified-9.0.36/raw/legacy-migration-node24.log +109 -0
  148. package/docs/reports/unified-9.0.36/raw/lint.log +45 -0
  149. package/docs/reports/unified-9.0.36/raw/module-standby-drain22.log +446 -0
  150. package/docs/reports/unified-9.0.36/raw/module-standby-drain24.log +80 -0
  151. package/docs/reports/unified-9.0.36/raw/module-standby-linux-memory.log +6 -0
  152. package/docs/reports/unified-9.0.36/raw/modules.log +5 -0
  153. package/docs/reports/unified-9.0.36/raw/node22-migration.log +1329 -0
  154. package/docs/reports/unified-9.0.36/raw/node22-mira.log +222 -0
  155. package/docs/reports/unified-9.0.36/raw/node22-system-status.log +225 -0
  156. package/docs/reports/unified-9.0.36/raw/node22-tests-final.log +18358 -0
  157. package/docs/reports/unified-9.0.36/raw/node22-version.log +1 -0
  158. package/docs/reports/unified-9.0.36/raw/node24-migration.log +1301 -0
  159. package/docs/reports/unified-9.0.36/raw/node24-mira.log +41 -0
  160. package/docs/reports/unified-9.0.36/raw/node24-system-status.log +42 -0
  161. package/docs/reports/unified-9.0.36/raw/node24-tests-final.log +3058 -0
  162. package/docs/reports/unified-9.0.36/raw/node24-version.log +1 -0
  163. package/docs/reports/unified-9.0.36/raw/npm-runtime-audit.json +77 -0
  164. package/docs/reports/unified-9.0.36/raw/ocpp-owner-isolation22.log +109 -0
  165. package/docs/reports/unified-9.0.36/raw/ocpp-owner-isolation24.log +24 -0
  166. package/docs/reports/unified-9.0.36/raw/qa-source-check.log +2 -0
  167. package/docs/reports/unified-9.0.36/raw/release-metadata.log +13 -0
  168. package/docs/reports/unified-9.0.36/raw/sbom.log +9 -0
  169. package/docs/reports/unified-9.0.36/raw/standby-independent-drain.log +4 -0
  170. package/docs/reports/unified-9.0.36/raw/standby-independent-sockets.log +3 -0
  171. package/docs/reports/unified-9.0.36/raw/typecheck.log +5 -0
  172. package/docs/reports/unified-9.0.36/raw/ui-runtime.log +8 -0
  173. package/docs/start/START_HIER_9.0.35.md +27 -0
  174. package/docs/start/START_HIER_9.0.36.md +32 -0
  175. package/docs/unified/ARCHITECTURE.md +6 -0
  176. package/io-package.json +12 -12
  177. package/modules/devices/contracts.d.ts +1 -0
  178. package/modules/devices/index.js +20 -1
  179. package/modules/devices/lib/deviceRuntime.js +19 -0
  180. package/modules/devices/lib/drivers/modbus.js +11 -6
  181. package/modules/devices/lib/drivers/ovumMira.js +7 -3
  182. package/modules/devices/test/ovumMiraTransport.test.js +40 -1
  183. package/modules/eebus/README.md +8 -0
  184. package/modules/eebus/admin/index.js +29 -2
  185. package/modules/eebus/build/index.js +28 -3
  186. package/modules/eebus/build/lib/eebusRuntime.js +17 -2
  187. package/modules/eebus/build/lib/partnerMonitor.js +160 -0
  188. package/modules/eebus/build/lib/shipEndpoint.js +4 -0
  189. package/modules/eebus/build/lib/stateDefinitions.js +1 -0
  190. package/modules/eebus/src/index.ts +23 -3
  191. package/modules/eebus/src/lib/eebusRuntime.ts +20 -2
  192. package/modules/eebus/src/lib/partnerMonitor.ts +127 -0
  193. package/modules/eebus/src/lib/shipEndpoint.ts +5 -0
  194. package/modules/eebus/src/lib/stateDefinitions.ts +1 -0
  195. package/modules/eebus/test/partner-monitor.test.js +82 -0
  196. package/modules/eebus/test/security.test.js +17 -0
  197. package/modules/ocpp/README.md +9 -1
  198. package/modules/ocpp/build/index.js +137 -10
  199. package/modules/ocpp/build/stationHistory.js +113 -0
  200. package/modules/ocpp/ocpp/freshness.d.ts +3 -0
  201. package/modules/ocpp/ocpp/freshness.js +6 -0
  202. package/modules/ocpp/provenance.json +3 -2
  203. package/modules/ocpp/runtime.d.ts +1 -0
  204. package/modules/ocpp/runtime.js +23 -1
  205. package/modules/ocpp/src/index.ts +163 -12
  206. package/modules/ocpp/src/stationHistory.ts +119 -0
  207. package/modules/ocpp/test/hosted.test.cjs +161 -0
  208. package/package.json +9 -5
  209. package/public/eos-migration/index.html +1 -1
  210. package/public/eos-migration/index.js +23 -7
  211. package/public/eos-runtime/index.js +82 -15
  212. package/release-manifests/unified/build-environment.cdx.json +6 -6
  213. package/release-manifests/unified/files.json +318 -181
  214. package/release-manifests/unified/frontend.cdx.json +6 -6
  215. package/release-manifests/unified/installer.cdx.json +6 -6
  216. package/release-manifests/unified/obsolete-admin-assets.json +166 -0
  217. package/release-manifests/unified/runtime.cdx.json +30 -30
  218. package/release-manifests/unified/validation.json +15 -15
  219. package/tools/eos-release-manifest.cjs +1 -1
  220. package/ui/io-package.json +9 -1
  221. package/ui/lib/hosted-startup-status.js +2 -2
  222. package/ui/lib/notification-mail.js +235 -40
  223. package/ui/lib/notification-policy.js +41 -14
  224. package/ui/package.json +2 -1
  225. package/ui/www/app.js +91 -11
  226. package/ui/www/dashboard-lp-status.js +4 -11
  227. package/ui/www/dashboard-process-status.js +205 -0
  228. package/ui/www/i18n/en.json +24 -0
  229. package/ui/www/i18n/nl.json +21 -0
  230. package/ui/www/index.html +10 -5
  231. package/ui/www/live-display.js +106 -9
  232. package/ui/www/manifest.webmanifest +2 -2
  233. package/ui/www/settings.html +2 -2
  234. package/ui/www/styles.css +4 -0
@@ -1,12 +1,13 @@
1
1
  'use strict';
2
2
  // Actual 0.4.3 station runtime; explicit base injection.
3
3
  function createOcppRuntime(AdapterBase) {
4
- const { randomUUID } = require('node:crypto');
4
+ const { randomUUID, createHash } = require('node:crypto');
5
5
  const { OcppRpcServer } = require('./ocpp/server');
6
6
  const { StationTelemetry, normalizeEosLimit, shouldSendLimit } = require('./ocpp/eos-contract');
7
7
  const {
8
8
  sanitizeStationIdentity,
9
9
  deriveConnectionHealth,
10
+ hasConfirmedSessionActivity,
10
11
  commandTimeoutMs,
11
12
  isTriggerAccepted,
12
13
  isTriggerUnsupported,
@@ -161,6 +162,8 @@ class NexoWattOcppAdapter extends AdapterBase {
161
162
  for (const key of [...this._phaseMetricCache.keys()]) if (key.startsWith(`${identity}|`)) this._phaseMetricCache.delete(key);
162
163
  this.runtimeIndex.set(identity, {
163
164
  sessionId: randomUUID(),
165
+ // Keep the identity known across socket replacements, while requiring fresh evidence for each session.
166
+ dashboardPreviouslyConfirmed: old?.dashboardPreviouslyConfirmed === true || hasConfirmedSessionActivity(old),
164
167
  proto,
165
168
  client,
166
169
  rawIdentity: rawIdentity || identity,
@@ -349,6 +352,19 @@ class NexoWattOcppAdapter extends AdapterBase {
349
352
  entry.lastAction = String(action || '');
350
353
  }
351
354
 
355
+ _rememberDashboardStation(identity, entry) {
356
+ if (entry.dashboardMarkerPending || entry.dashboardMarkerSaved) return;
357
+ entry.dashboardMarkerPending = true;
358
+ // This observation outlives a socket. Never restore a present-session online flag from it.
359
+ void this.ensureStructure(identity).then(async () => {
360
+ if (this.runtimeIndex.get(identity)?.rawIdentity !== entry.rawIdentity) return;
361
+ const key = createHash('sha256').update(entry.rawIdentity).digest('hex');
362
+ await this._setStateFreshAsync(`${identity}.health.dashboardConfirmedKey`, key, true, 'static');
363
+ entry.dashboardMarkerSaved = true;
364
+ }).catch(() => { /* Retry on the next confirmed packet. */ })
365
+ .finally(() => { entry.dashboardMarkerPending = false; });
366
+ }
367
+
352
368
  _noteBoot(identity, intervalSec) {
353
369
  const entry = this.runtimeIndex.get(identity);
354
370
  if (!entry) return;
@@ -359,6 +375,7 @@ class NexoWattOcppAdapter extends AdapterBase {
359
375
  entry.lastMessageAt = Math.max(entry.lastMessageAt || 0, now);
360
376
  entry.nextRefreshAt = now + Math.max(30, Number(this.config.activeRefreshIntervalSec) || 60) * 1000;
361
377
  entry.lastBootAt = now;
378
+ this._rememberDashboardStation(identity, entry);
362
379
  entry.configurationRebootRequired = false;
363
380
  entry.configurationAutoRefreshDone = false;
364
381
  entry.configurationAutoRefreshAt = now + Math.max(5, Number(this.config.configurationRefreshDelaySec) || 15) * 1000;
@@ -377,6 +394,7 @@ class NexoWattOcppAdapter extends AdapterBase {
377
394
  // retained only for display and must not make an old connection appear new.
378
395
  const now = Date.now();
379
396
  entry.lastHeartbeatAt = now;
397
+ this._rememberDashboardStation(identity, entry);
380
398
  entry.lastMessageAt = Math.max(entry.lastMessageAt || 0, now);
381
399
  entry.lastHeartbeatSourceTimestamp = timestamp || '';
382
400
  }
@@ -453,6 +471,7 @@ class NexoWattOcppAdapter extends AdapterBase {
453
471
  telemetry.meter(evseId, connectorId, values, at, sourceAt);
454
472
  if (evseId > 0 && connectorId > 0) entry.connectors.add(`${evseId}:${connectorId}`);
455
473
  entry.lastMeterAt = at;
474
+ this._rememberDashboardStation(identity, entry);
456
475
  await this._setStateFreshAsync(`${identity}.health.lastMeterValue`, new Date(at).toISOString(), true, 'health');
457
476
  await this._publishStationTelemetry(identity, entry);
458
477
  }
@@ -474,6 +493,7 @@ class NexoWattOcppAdapter extends AdapterBase {
474
493
  const entry = this.runtimeIndex.get(identity);
475
494
  if (!entry || !entry.client || !entry.socketConnected) return;
476
495
  entry.lastStatusAt = Date.now();
496
+ this._rememberDashboardStation(identity, entry);
477
497
  if (evseId > 0 && connectorId > 0) entry.connectors.add(`${evseId}:${connectorId}`);
478
498
  entry.statuses.set(`${evseId}:${connectorId}`, String(status || ''));
479
499
  this._getStationTelemetry(identity, entry).status(evseId, connectorId, status);
@@ -487,6 +507,7 @@ class NexoWattOcppAdapter extends AdapterBase {
487
507
  // in the future or far in the past and must not falsify EOS data quality.
488
508
  const now = Date.now();
489
509
  entry.lastMeterAt = Math.max(entry.lastMeterAt || 0, now);
510
+ this._rememberDashboardStation(identity, entry);
490
511
  if (flags.hasPower) entry.lastPowerAt = Math.max(entry.lastPowerAt || 0, now);
491
512
  if (flags.hasExportPower) entry.lastExportPowerAt = Math.max(entry.lastExportPowerAt || 0, now);
492
513
  if (flags.hasCurrent) entry.lastCurrentAt = Math.max(entry.lastCurrentAt || 0, now);
@@ -2538,6 +2559,7 @@ class NexoWattOcppAdapter extends AdapterBase {
2538
2559
  staleReason: ['string', 'text', ''],
2539
2560
  powerSource: ['string', 'text', 'unknown-or-incomplete'],
2540
2561
  heartbeat: ['string', 'value.time', ''],
2562
+ dashboardConfirmedKey: ['string', 'text', ''],
2541
2563
  lastHeartbeatMs: ['number', 'value.time', 0],
2542
2564
  lastSeen: ['string', 'value.time', ''],
2543
2565
  lastSeenMs: ['number', 'value.time', 0],
@@ -1,10 +1,16 @@
1
1
  /** NexoWatt EOS OCPP hosting boundary. MIT; original station runtime remains attributed in provenance.json. */
2
+ import { readStationHistory, stationKey, type KnownStation } from './stationHistory';
2
3
  import { AsyncLocalStorage } from 'node:async_hooks';
3
4
  import { EventEmitter } from 'node:events';
4
5
  import { createRequire } from 'node:module';
5
- import type { OcppRuntime } from '../runtime';
6
+ import type { OcppRuntime, RuntimeEntry } from '../runtime';
6
7
  import { createOcppRuntime } from '../runtime';
7
- import { deriveConnectionHealth, dataFreshForEos } from '../ocpp/freshness';
8
+ import {
9
+ deriveConnectionHealth,
10
+ activityTimeoutMs,
11
+ dataFreshForEos,
12
+ hasConfirmedSessionActivity,
13
+ } from '../ocpp/freshness';
8
14
 
9
15
  export type RecordValue = Record<string, unknown>;
10
16
  interface Adapter extends RecordValue {
@@ -192,7 +198,16 @@ export interface HostedStatus {
192
198
  leaseState: string;
193
199
  }>;
194
200
  }
201
+ type StationHealthState = 'online' | 'offline' | 'unknown';
202
+ interface DashboardDeviceHealth {
203
+ complete: boolean;
204
+ state: 'ok' | 'unknown' | 'fault';
205
+ offline: { name: string }[];
206
+ totalOffline: number;
207
+ tracked: { key: string; name: string; state: StationHealthState }[];
208
+ }
195
209
  export interface HostedModule {
210
+ getDashboardDeviceHealth(): DashboardDeviceHealth;
196
211
  start(): Promise<void>;
197
212
  stop(): Promise<void>;
198
213
  getStatus(): HostedStatus;
@@ -311,6 +326,28 @@ export function createHostedModule(options: HostedOptions): HostedModule {
311
326
  })();
312
327
  return stopping;
313
328
  };
329
+ const dashboardKeys = new WeakMap<RuntimeEntry, string>();
330
+ const configuredIdentities = new Set(Array.isArray(settings.identityAllowlist) ? settings.identityAllowlist : []);
331
+ const allowedKeys = new Set([...configuredIdentities].map(id => stationKey(String(id))));
332
+ let knownStations = new Map<string, KnownStation>();
333
+ let historyComplete = false;
334
+ let observationStarted = 0;
335
+ let retryHistoryAfter = 0;
336
+ const restoreHistory = async (): Promise<void> => {
337
+ retryHistoryAfter = 0;
338
+ const token = generation;
339
+ const loaded = await readStationHistory(
340
+ adapter.namespace,
341
+ pattern => call('getStatesAsync', [pattern]),
342
+ allowedKeys,
343
+ );
344
+ if (!allowed() || token !== generation) {
345
+ return;
346
+ }
347
+ knownStations = loaded.complete ? loaded.known : new Map([...knownStations, ...loaded.known]);
348
+ historyComplete = loaded.complete;
349
+ retryHistoryAfter = loaded.readFailed ? Date.now() + 30000 : 0;
350
+ };
314
351
  const start = (): Promise<void> => {
315
352
  if (starting) {
316
353
  return starting;
@@ -360,7 +397,10 @@ export function createHostedModule(options: HostedOptions): HostedModule {
360
397
  ]);
361
398
  }
362
399
  await call('setStateAsync', ['info.eosHostedRuntime', { val: true, ack: true }]);
400
+ // Inventory hydration cannot delay the WebSocket listener or physical control.
401
+ void restoreHistory();
363
402
  await runtime.onReady();
403
+ observationStarted = Date.now();
364
404
  assert();
365
405
  started = true;
366
406
  state = 'running';
@@ -370,6 +410,9 @@ export function createHostedModule(options: HostedOptions): HostedModule {
370
410
  if (publishing || !allowed() || !runtime?.server) {
371
411
  return;
372
412
  }
413
+ if (retryHistoryAfter && Date.now() >= retryHistoryAfter) {
414
+ void restoreHistory();
415
+ }
373
416
  publishing = true;
374
417
  void publishAlive(true)
375
418
  .catch(() => {
@@ -389,6 +432,122 @@ export function createHostedModule(options: HostedOptions): HostedModule {
389
432
  });
390
433
  return starting;
391
434
  };
435
+ const connectionHealth = (entry: RuntimeEntry, now: number): ReturnType<typeof deriveConnectionHealth> =>
436
+ deriveConnectionHealth({
437
+ now,
438
+ socketConnected: entry.socketConnected,
439
+ connectedAt: entry.connectedAt,
440
+ lastMessageAt: entry.lastMessageAt,
441
+ lastHeartbeatAt: entry.lastHeartbeatAt,
442
+ heartbeatIntervalSec: entry.heartbeatIntervalSec,
443
+ heartbeatTimeoutFactor: settings.heartbeatTimeoutFactor,
444
+ activityTimeoutSec: settings.activityTimeoutSec,
445
+ });
446
+ const getDashboardDeviceHealth = (): DashboardDeviceHealth => {
447
+ const result: DashboardDeviceHealth = {
448
+ state: 'ok',
449
+ offline: [],
450
+ totalOffline: 0,
451
+ tracked: [],
452
+ complete: false,
453
+ };
454
+ if (!settings.enabled) {
455
+ result.complete = true;
456
+ return result;
457
+ }
458
+ if (
459
+ !started ||
460
+ !runtime ||
461
+ revoked ||
462
+ state !== 'running' ||
463
+ !options.canOperate() ||
464
+ (options.getAuthorityGeneration?.() ?? 0) !== authorityGeneration
465
+ ) {
466
+ result.state = 'unknown';
467
+ return result;
468
+ }
469
+ const now = Date.now();
470
+ if (!historyComplete) {
471
+ result.state = 'unknown';
472
+ }
473
+ const seen = new Set<string>();
474
+ let ordinal = 0,
475
+ eligible = 0,
476
+ confirmedConfigured = 0;
477
+ for (const entry of runtime.runtimeIndex.values()) {
478
+ ordinal++;
479
+ let key = dashboardKeys.get(entry);
480
+ if (!key) {
481
+ key = stationKey(entry.rawIdentity);
482
+ dashboardKeys.set(entry, key);
483
+ }
484
+ const historical = knownStations.get(key);
485
+ const confirmed = hasConfirmedSessionActivity(entry);
486
+ if (!confirmed && !entry.dashboardPreviouslyConfirmed && !historical && !entry.socketConnected) {
487
+ continue;
488
+ }
489
+ seen.add(key);
490
+ eligible++;
491
+ if ((confirmed || entry.dashboardPreviouslyConfirmed) && configuredIdentities.has(entry.rawIdentity)) {
492
+ confirmedConfigured++;
493
+ }
494
+ let current: StationHealthState = 'unknown';
495
+ if (confirmed) {
496
+ current = connectionHealth(entry, now).online ? 'online' : 'offline';
497
+ } else if ((entry.dashboardPreviouslyConfirmed || historical) && !entry.socketConnected) {
498
+ current = 'offline';
499
+ }
500
+ // The native station object has an OCPP identity and no separate public display name.
501
+ const name = `Ladestation ${ordinal}`;
502
+ if (current === 'offline') {
503
+ result.state = 'fault';
504
+ result.totalOffline++;
505
+ if (result.offline.length < 12) {
506
+ result.offline.push({ name });
507
+ }
508
+ } else if (current === 'unknown' && result.state !== 'fault') {
509
+ result.state = 'unknown';
510
+ }
511
+ if (result.tracked.length < 256) {
512
+ result.tracked.push({ key, name, state: current });
513
+ }
514
+ }
515
+ const windowMs = activityTimeoutMs(
516
+ settings.heartbeatIntervalSec,
517
+ settings.heartbeatTimeoutFactor,
518
+ settings.activityTimeoutSec,
519
+ );
520
+ for (const old of knownStations.values()) {
521
+ if (seen.has(old.key)) {
522
+ continue;
523
+ }
524
+ const name = `Ladestation ${++ordinal}`;
525
+ const absent = old.offline || now - observationStarted > windowMs;
526
+ if (absent) {
527
+ result.state = 'fault';
528
+ result.totalOffline++;
529
+ if (result.offline.length < 12) {
530
+ result.offline.push({ name });
531
+ }
532
+ } else if (result.state !== 'fault') {
533
+ result.state = 'unknown';
534
+ }
535
+ eligible++;
536
+ if (allowedKeys.has(old.key)) {
537
+ confirmedConfigured++;
538
+ }
539
+ if (result.tracked.length < 256) {
540
+ result.tracked.push({ key: old.key, name, state: absent ? 'offline' : 'unknown' });
541
+ }
542
+ }
543
+ // With open admission, earlier sessions may be missing after a worker restart.
544
+ result.complete =
545
+ historyComplete &&
546
+ configuredIdentities.size > 0 &&
547
+ confirmedConfigured === configuredIdentities.size &&
548
+ eligible === result.tracked.length;
549
+ return result;
550
+ };
392
551
  const getStatus = (): HostedStatus => ({
393
552
  started: started && allowed(),
394
553
  state,
@@ -410,16 +569,7 @@ export function createHostedModule(options: HostedOptions): HostedModule {
410
569
  status: entry.chargingState || '',
411
570
  lastSeenMs: entry.lastMessageAt || 0,
412
571
  dataFresh: dataFreshForEos(
413
- deriveConnectionHealth({
414
- now: Date.now(),
415
- socketConnected: entry.socketConnected,
416
- connectedAt: entry.connectedAt,
417
- lastMessageAt: entry.lastMessageAt,
418
- lastHeartbeatAt: entry.lastHeartbeatAt,
419
- heartbeatIntervalSec: entry.heartbeatIntervalSec,
420
- heartbeatTimeoutFactor: settings.heartbeatTimeoutFactor,
421
- activityTimeoutSec: settings.activityTimeoutSec,
422
- }).online,
572
+ connectionHealth(entry, Date.now()).online,
423
573
  entry.lastPowerAt > 0 && Date.now() - entry.lastPowerAt <= Number(settings.telemetryMaxAgeSec) * 1000,
424
574
  entry.socketConnected && entry.safeZeroAt > 0,
425
575
  ),
@@ -451,6 +601,7 @@ export function createHostedModule(options: HostedOptions): HostedModule {
451
601
  start,
452
602
  stop,
453
603
  getStatus,
604
+ getDashboardDeviceHealth,
454
605
  onStateChange,
455
606
  command: (name: unknown): Promise<HostedStatus> => {
456
607
  assert();
@@ -0,0 +1,119 @@
1
+ import { createHash } from 'node:crypto';
2
+
3
+ type States = Record<string, unknown>;
4
+ export type KnownStation = { key: string; offline: boolean };
5
+ const record = (value: unknown): value is States => !!value && typeof value === 'object' && !Array.isArray(value);
6
+ export const stationKey = (identity: string): string => createHash('sha256').update(identity).digest('hex');
7
+ const fields = [
8
+ 'health.staleReason',
9
+ 'health.online',
10
+ 'health.dashboardConfirmedKey',
11
+ 'info.identity',
12
+ 'info.heartbeatInterval',
13
+ 'health.lastBoot',
14
+ 'info.lastHeartbeat',
15
+ 'health.lastMeterValue',
16
+ ] as const;
17
+
18
+ /**
19
+ * Only exact evidence suffixes in the module's own (possibly migrated) namespace.
20
+ * Object defaults, socket creation and a configuration allowlist do not prove a station exists.
21
+ */
22
+ export async function readStationHistory(
23
+ namespace: string,
24
+ read: (pattern: string) => Promise<unknown>,
25
+ allow: Set<string>,
26
+ ): Promise<{ known: Map<string, KnownStation>; complete: boolean; readFailed: boolean }> {
27
+ const rows = new Map<string, States>();
28
+ let complete = true;
29
+ let readFailed = false;
30
+ const collect = async (field: (typeof fields)[number]): Promise<void> => {
31
+ try {
32
+ const values = await read(`*.${field}`);
33
+ if (!record(values)) {
34
+ throw new Error('invalid controller response');
35
+ }
36
+ for (const [id, state] of Object.entries(values)) {
37
+ const rel = id.startsWith(`${namespace}.`) ? id.slice(namespace.length + 1) : id;
38
+ if (!rel.endsWith(`.${field}`)) {
39
+ continue;
40
+ }
41
+ const root = rel.slice(0, -(field.length + 1));
42
+ if (!/^[A-Za-z0-9_-]{1,256}$/.test(root) || !record(state)) {
43
+ continue;
44
+ }
45
+ if (state.ack !== true || (state.q !== undefined && state.q !== 0)) {
46
+ // An unreadable positive marker is not proof of an empty station inventory.
47
+ if (field === 'health.dashboardConfirmedKey' && state.val) {
48
+ complete = false;
49
+ }
50
+ continue;
51
+ }
52
+ let row = rows.get(root);
53
+ if (!row) {
54
+ if (rows.size >= 1024) {
55
+ complete = false;
56
+ continue;
57
+ }
58
+ row = {};
59
+ rows.set(root, row);
60
+ }
61
+ row[field] = state.val;
62
+ }
63
+ } catch {
64
+ complete = false;
65
+ readFailed = true;
66
+ }
67
+ };
68
+ // Start with outage evidence before the normal runtime resets old session flags.
69
+ // At most two bounded controller requests in flight, independent of station count.
70
+ for (let i = 0; i < fields.length; i += 2) {
71
+ await Promise.all(fields.slice(i, i + 2).map(collect));
72
+ }
73
+ const known = new Map<string, KnownStation>();
74
+ const now = Date.now();
75
+ for (const row of rows.values()) {
76
+ const raw = row['info.identity'],
77
+ marker = row['health.dashboardConfirmedKey'];
78
+ const timestamp = (value: unknown): boolean =>
79
+ typeof value === 'string' &&
80
+ Number.isFinite(Date.parse(value)) &&
81
+ Date.parse(value) > 0 &&
82
+ Date.parse(value) <= now;
83
+ const interval = row['info.heartbeatInterval']; // The native runtime writes this only after BootNotification.
84
+ const legacy =
85
+ (typeof interval === 'number' && Number.isInteger(interval) && interval >= 10 && interval <= 86400) ||
86
+ timestamp(row['health.lastBoot']) ||
87
+ timestamp(row['info.lastHeartbeat']) ||
88
+ timestamp(row['health.lastMeterValue']);
89
+ const marked = typeof marker === 'string' && /^[a-f0-9]{64}$/.test(marker);
90
+ if (!marked && !legacy) {
91
+ if (marker) {
92
+ complete = false;
93
+ }
94
+ continue;
95
+ }
96
+ const rawKey = typeof raw === 'string' && raw.length > 0 && raw.length <= 256 ? stationKey(raw) : '';
97
+ if (marked && rawKey && rawKey !== marker) {
98
+ complete = false;
99
+ continue;
100
+ }
101
+ const key = marked ? marker : rawKey;
102
+ if (!key) {
103
+ complete = false;
104
+ continue;
105
+ }
106
+ if (allow.size && !allow.has(key)) {
107
+ continue;
108
+ }
109
+ if (known.has(key)) {
110
+ complete = false;
111
+ continue;
112
+ }
113
+ const reason = row['health.staleReason'];
114
+ const offline =
115
+ row['health.online'] === false && (reason === 'socket-disconnected' || reason === 'no-ocpp-activity');
116
+ known.set(key, { key, offline });
117
+ }
118
+ return { known, complete, readFailed };
119
+ }
@@ -163,3 +163,164 @@ test('hosted status never labels an inactive open idle station as fresh', async
163
163
  assert.equal(station.dataFresh, false);
164
164
  } finally { Date.now = originalNow; }
165
165
  });
166
+
167
+ test('dashboard health follows proven OCPP sessions, preserves identity privately and clears after a confirmed reconnect', async t => {
168
+ const f = fixture(), listenerPort = await port();
169
+ const hosted = createHostedModule({...f, config:{enabled:true,port:listenerPort,activeRefresh:false}});
170
+ const disabled = createHostedModule({...f, config:{enabled:false}});
171
+ const empty = {state:'ok',offline:[],totalOffline:0,tracked:[],complete:false};
172
+ assert.deepEqual(disabled.getDashboardDeviceHealth(),{...empty,complete:true});
173
+ assert.deepEqual(hosted.getDashboardDeviceHealth(),{...empty,state:'unknown'});
174
+ const identity = 'secret-serial-888264902', clients = [];
175
+ const connect = async () => {
176
+ const client = new RPCClient({endpoint:'ws://127.0.0.1:'+listenerPort,identity,protocols:['ocpp1.6'],reconnect:false});
177
+ clients.push(client);
178
+ await client.connect();
179
+ return client;
180
+ };
181
+ t.after(async () => {
182
+ await Promise.all(clients.map(c => c.close({force:true}).catch(()=>{})));
183
+ await hosted.stop();
184
+ });
185
+ await hosted.start();
186
+ assert.deepEqual(hosted.getDashboardDeviceHealth(),empty);
187
+ const measure = () => hosted.getDashboardDeviceHealth();
188
+ const waitState = state => until(measure,result => result.tracked[0]?.state === state);
189
+ const first = await connect();
190
+ const pending = await waitState('unknown');
191
+ assert.equal(pending.state,'unknown');
192
+ assert.equal(pending.totalOffline,0);
193
+ await first.close({force:true});
194
+ await until(measure,result => !result.tracked.length);
195
+ assert.deepEqual(measure(),empty);
196
+
197
+ const station = await connect();
198
+ const boot = await station.call('BootNotification',{chargePointVendor:'Test',chargePointModel:'Local station'});
199
+ assert.equal(boot.status,'Accepted');
200
+ await station.call('StatusNotification',{connectorId:1,status:'Available',errorCode:'NoError'});
201
+ const online = await waitState('online');
202
+ const key = require('node:crypto').createHash('sha256').update(identity).digest('hex');
203
+ assert.deepEqual(online,{...empty,tracked:[{key,name:'Ladestation 1',state:'online'}]});
204
+ const systemNow = Date.now;
205
+ try {
206
+ const later = systemNow() + 751000;
207
+ Date.now = () => later;
208
+ assert.equal(measure().state,'fault','the native activity window also covers a silent open socket');
209
+ } finally { Date.now = systemNow; }
210
+ await station.close({force:true});
211
+ const offline = await waitState('offline');
212
+ assert.deepEqual(offline,{state:'fault',complete:false,offline:[{name:'Ladestation 1'}],totalOffline:1,tracked:[{key,name:'Ladestation 1',state:'offline'}]});
213
+ assert.doesNotMatch(JSON.stringify(offline),/secret-serial|888264902|127\.0\.0\.1/);
214
+ const reconnecting = await connect();
215
+ await waitState('unknown');
216
+ await reconnecting.close({force:true});
217
+ await waitState('offline');
218
+ const final = await connect();
219
+ await final.call('Heartbeat',{});
220
+ assert.deepEqual(await waitState('online'),online,'an accepted heartbeat confirms an existing station after reconnection');
221
+ f.revoke();
222
+ assert.deepEqual(measure(),{...empty,state:'unknown'});
223
+ });
224
+
225
+ test('dashboard reports the offline count and at most twelve synthetic station names',async t => {
226
+ const f = fixture(),listenerPort = await port();
227
+ const identityAllowlist = Array.from({length:13},(_,i) => 'private-address-'+i);
228
+ const hosted = createHostedModule({...f,config:{enabled:true,port:listenerPort,activeRefresh:false,identityAllowlist}});
229
+ t.after(()=>hosted.stop());
230
+ await hosted.start();
231
+ assert.equal(hosted.getDashboardDeviceHealth().complete,false);
232
+ for(let i=0;i<13;i++){
233
+ const client = new RPCClient({endpoint:'ws://127.0.0.1:'+listenerPort,identity:'private-address-'+i,protocols:['ocpp1.6'],reconnect:false});
234
+ try {
235
+ await client.connect();
236
+ await client.call('Heartbeat',{});
237
+ } finally { await client.close({force:true}); }
238
+ }
239
+ const summary=await until(()=>hosted.getDashboardDeviceHealth(),v=>v.totalOffline===13);
240
+ assert.equal(summary.state,'fault');
241
+ assert.equal(summary.complete,true,'every identity on the closed admission list has been confirmed');
242
+ assert.equal(summary.offline.length,12);
243
+ assert.equal(summary.tracked.length,13);
244
+ assert.deepEqual(summary.offline[11],{name:'Ladestation 12'});
245
+ assert.equal(new Set(summary.tracked.map(x=>x.key)).size,13);
246
+ assert.doesNotMatch(JSON.stringify(summary),/private-address/);
247
+ });
248
+
249
+ test('known stations survive worker replacement with the same native states; inactive admission entries and a bare socket are never promoted', async t => {
250
+ const f = fixture(), identity='Garage West', listenerPort=await port();
251
+ const config={enabled:true,port:listenerPort,activeRefresh:false,identityAllowlist:[identity,'Future Spare'],heartbeatIntervalSec:10,activityTimeoutSec:90};
252
+ const boot = async () => {
253
+ const hosted=createHostedModule({...f,config});
254
+ t.after(()=>hosted.stop()); await hosted.start(); return hosted;
255
+ };
256
+ const socket=async () => {
257
+ const client=new RPCClient({endpoint:'ws://127.0.0.1:'+listenerPort,identity,protocols:['ocpp1.6'],reconnect:false});
258
+ t.after(()=>client.close({force:true}).catch(()=>{}));
259
+ await client.connect();return client;
260
+ };
261
+ const original=await boot();
262
+ await until(()=>original.getDashboardDeviceHealth(),r=>r.state==='ok'&&!r.tracked.length);
263
+ const client=await socket();
264
+ await client.call('Heartbeat',{});
265
+ await until(()=>original.getDashboardDeviceHealth(),r=>r.tracked[0]?.state==='online');
266
+ await until(()=>[...f.states.keys()],ids=>ids.some(k=>k.endsWith('.health.dashboardConfirmedKey')&&
267
+ /^[a-f0-9]{64}$/.test(String(f.states.get(k).val))));
268
+ await client.close({force:true});
269
+ const firstLost=await until(()=>original.getDashboardDeviceHealth(),r=>r.totalOffline===1);
270
+ await original.stop();
271
+ const reloaded=await boot();
272
+ const waiting=await until(()=>reloaded.getDashboardDeviceHealth(),r=>r.tracked[0]?.key===firstLost.tracked[0].key);
273
+ assert.notEqual(waiting.state,'ok');assert.equal(waiting.tracked.length,1);
274
+ const dt=Date.now;
275
+ try {const afterWindow=dt()+91000;Date.now=()=>afterWindow;
276
+ assert.deepEqual(reloaded.getDashboardDeviceHealth().offline,[{name:'Ladestation 1'}]);
277
+ } finally {Date.now=dt;}
278
+ const replacement=await socket();
279
+ assert.equal((await until(()=>reloaded.getDashboardDeviceHealth(),r=>r.tracked[0]?.state==='unknown')).state,'unknown');
280
+ await replacement.call('BootNotification',{chargePointModel:'Local',chargePointVendor:'Fixture'});
281
+ const online=await until(()=>reloaded.getDashboardDeviceHealth(),r=>r.tracked[0]?.state==='online');
282
+ assert.equal(online.totalOffline,0);assert.equal(online.tracked[0].key,firstLost.tracked[0].key);
283
+ });
284
+
285
+ test('legacy ocpp21 namespace restores acknowledged Boot evidence and prior physical disconnect, rejects defaults, bad quality and handshakes', async t=>{
286
+ const ns='ocpp21.3',f=fixture(ns),listenerPort=await port();
287
+ const add=(id,val,q=0)=>f.states.set(ns+'.'+id,{val,ack:true,q,ts:Date.now()});
288
+ add('Primary.info.identity','Raw With Space');
289
+ add('Primary.info.heartbeatInterval',300);add('Primary.health.staleReason','socket-disconnected');add('Primary.health.online',false);
290
+ add('Never.info.identity','Whitelist Only');add('Never.info.heartbeatInterval',0);add('Never.health.online',false);
291
+ add('Bad.info.identity','Bad device');add('Bad.health.lastBoot',new Date().toISOString(),32);
292
+ add('Opening.info.identity','Websocket only');add('Opening.health.lastSeenMs',Date.now());
293
+ const hosted=createHostedModule({...f,config:{enabled:true,port:listenerPort,activeRefresh:false}});
294
+ t.after(()=>hosted.stop());await hosted.start();
295
+ const health=await until(()=>hosted.getDashboardDeviceHealth(),r=>r.totalOffline===1);
296
+ assert.equal(health.tracked.length,1);assert.equal(health.tracked[0].key,require('node:crypto').createHash('sha256').update('Raw With Space').digest('hex'));
297
+ assert.doesNotMatch(JSON.stringify(health),/With Space|Primary|ocpp21/);
298
+ });
299
+
300
+ test('an unavailable historical inventory does not prevent the port from accepting stations and cannot declare all devices healthy',async t=>{
301
+ const f=fixture(),listenerPort=await port();
302
+ f.adapter.getStatesAsync=async()=>{throw Error('controller unavailable')};
303
+ const hosted=createHostedModule({...f,config:{enabled:true,port:listenerPort}});
304
+ t.after(()=>hosted.stop());await hosted.start();
305
+ assert.equal(hosted.getStatus().started,true);assert.equal(hosted.getDashboardDeviceHealth().state,'unknown');
306
+ assert.equal(hosted.getDashboardDeviceHealth().complete,false);
307
+ });
308
+
309
+ test('deferred history does not delay the WebSocket listener and is neutral until loaded',async t=>{
310
+ const f=fixture(), read=f.adapter.getStatesAsync,listenerPort=await port();
311
+ let resume,waiting=true;const blocked=new Promise(resolve=>{resume=resolve;});
312
+ f.adapter.getStatesAsync=async pattern=>{
313
+ if(pattern==='*.health.dashboardConfirmedKey' && waiting) await blocked;
314
+ return read(pattern);
315
+ };
316
+ const hosted=createHostedModule({...f,config:{enabled:true,port:listenerPort,activeRefresh:false}});
317
+ t.after(async()=>{waiting=false;resume();await hosted.stop();});
318
+ await hosted.start();assert.equal(hosted.getDashboardDeviceHealth().state,'unknown');
319
+ const client=new RPCClient({endpoint:'ws://127.0.0.1:'+listenerPort,identity:'Live',protocols:['ocpp1.6'],reconnect:false});
320
+ try {
321
+ await client.connect();
322
+ await client.call('Heartbeat',{});
323
+ await until(()=>hosted.getDashboardDeviceHealth(),r=>r.tracked[0]?.state==='online');
324
+ waiting=false;resume();await until(()=>hosted.getDashboardDeviceHealth(),r=>r.state==='ok');
325
+ } finally {await client.close({force:true});}
326
+ });