iobroker.eos-admin 9.0.31 → 9.0.34

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 (242) hide show
  1. package/NEXOWATT_EOS_BUILD_INFO.json +10 -11
  2. package/README.md +7 -7
  3. package/adminWww/.vite/manifest.json +233 -224
  4. package/adminWww/NEXOWATT_EOS_FRONTEND_MANIFEST.json +13897 -13887
  5. package/adminWww/assets/AccessTime-CuR73YC3.js +1 -0
  6. package/adminWww/assets/{AdapterUpdateDialog-UhaQHyF1.js → AdapterUpdateDialog-5L75o18m.js} +5 -5
  7. package/adminWww/assets/{Adapters-Di3sM_ky.js → Adapters-FcghjF7E.js} +5 -5
  8. package/adminWww/assets/ConfigManager-BnHarBfH.js +1 -0
  9. package/adminWww/assets/Enums-BjLbLLQL.js +92 -0
  10. package/adminWww/assets/Fields-DDE1hVOa.js +1 -0
  11. package/adminWww/assets/Files-CDjnR4q6.js +1 -0
  12. package/adminWww/assets/{Hosts-DXjTE0pX.js → Hosts-CJKQaNrD.js} +6 -6
  13. package/adminWww/assets/Instances-DZNl369k.js +4 -0
  14. package/adminWww/assets/Intro-CjAmMGDB.js +2 -0
  15. package/adminWww/assets/KeyboardArrowRight-ifvmV1ZL.js +1 -0
  16. package/adminWww/assets/{Logs-DTo6XJF_.js → Logs-rUAV7SwM.js} +2 -2
  17. package/adminWww/assets/MoreHoriz-CS7nODK8.js +1 -0
  18. package/adminWww/assets/{Objects-DyEBMDK6.js → Objects-CqOH6rT_.js} +4 -4
  19. package/adminWww/assets/Overview-BOtXqsMy.js +3 -0
  20. package/adminWww/assets/Pageview-wzrLQZ-j.js +1 -0
  21. package/adminWww/assets/PersonOff-YtHcY0sV.js +1 -0
  22. package/adminWww/assets/Star-D8VNXawT.js +1 -0
  23. package/adminWww/assets/State-C8ncThop.js +1 -0
  24. package/adminWww/assets/UsedResources-lUYJqy4F.js +2 -0
  25. package/adminWww/assets/Users-CK1Cax82.js +1 -0
  26. package/adminWww/assets/ViewCompact-D7bHgn99.js +1 -0
  27. package/adminWww/assets/ViewSidebar-CjClbCI5.js +1 -0
  28. package/adminWww/assets/WifiTethering-DJ9VO12W.js +1 -0
  29. package/adminWww/assets/{bootstrap-BQ4OzwbT.js → bootstrap-CC0Qr-kr.js} +25 -25
  30. package/adminWww/assets/date-fns-BtR4dG_j.js +1 -0
  31. package/adminWww/assets/en-US-BjjaEI6N.js +1 -0
  32. package/adminWww/assets/{hostInit-CGSSNegd.js → hostInit-DqGL6nY8.js} +1 -1
  33. package/adminWww/assets/icons-material-07rWS63O.js +1 -0
  34. package/adminWww/assets/{index-C4CShixx.js → index-BhhkToP2.js} +2 -2
  35. package/adminWww/assets/{installSVGRenderer-DeaOAT3W.js → installSVGRenderer-B4-7lSQZ.js} +1 -1
  36. package/adminWww/assets/isSameWeek-WMSJR5Qs.js +1 -0
  37. package/adminWww/assets/locale-DN6Bdkdt.js +1 -0
  38. package/adminWww/assets/{mf-entry-bootstrap-0-c5733c2d.js → mf-entry-bootstrap-0-1afd2287.js} +2 -2
  39. package/adminWww/assets/sentry-CPzCHrwe.js +1 -0
  40. package/adminWww/assets/setYear-DDSuW45e.js +1 -0
  41. package/adminWww/index.html +23 -23
  42. package/adminWww/mf-manifest.json +1 -1
  43. package/adminWww/mf-stats.json +1 -1
  44. package/adminWww/{remoteEntry-eos-9.0.31.js → remoteEntry-eos-9.0.34.js} +1 -1
  45. package/adminWww/remoteEntry.js +1 -1
  46. package/build/lib/eosDeviceEmsPlan.js +285 -9
  47. package/build/lib/eosDeviceEmsPlan.js.map +1 -1
  48. package/build/lib/eosDeviceEmsService.js +29 -2
  49. package/build/lib/eosDeviceEmsService.js.map +1 -1
  50. package/build/lib/eosUiProcess.js +31 -14
  51. package/build/lib/eosUiProcess.js.map +1 -1
  52. package/build/lib/eosUiProcessRpc.js +3 -1
  53. package/build/lib/eosUiProcessRpc.js.map +1 -1
  54. package/build/lib/eosUiProcessWorker.js +6 -4
  55. package/build/lib/eosUiProcessWorker.js.map +1 -1
  56. package/docs/README.md +3 -2
  57. package/docs/reports/unified-9.0.32/PRUEFBERICHT.md +34 -0
  58. package/docs/reports/unified-9.0.32/PRUEFERGEBNISSE.json +112 -0
  59. package/docs/reports/unified-9.0.32/raw/INDEX.json +102 -0
  60. package/docs/reports/unified-9.0.32/raw/backend.log +5 -0
  61. package/docs/reports/unified-9.0.32/raw/browser-cadence-headless.json +63 -0
  62. package/docs/reports/unified-9.0.32/raw/browser-flow-headless.json +328 -0
  63. package/docs/reports/unified-9.0.32/raw/focused.log +67 -0
  64. package/docs/reports/unified-9.0.32/raw/frontend.log +151 -0
  65. package/docs/reports/unified-9.0.32/raw/installer.log +26 -0
  66. package/docs/reports/unified-9.0.32/raw/lint.log +5 -0
  67. package/docs/reports/unified-9.0.32/raw/modules.log +5 -0
  68. package/docs/reports/unified-9.0.32/raw/node22-tests-final.log +17212 -0
  69. package/docs/reports/unified-9.0.32/raw/node22-version.log +1 -0
  70. package/docs/reports/unified-9.0.32/raw/node24-tests-final.log +2869 -0
  71. package/docs/reports/unified-9.0.32/raw/node24-version.log +1 -0
  72. package/docs/reports/unified-9.0.32/raw/sbom.log +2 -0
  73. package/docs/reports/unified-9.0.32/raw/typecheck.log +5 -0
  74. package/docs/reports/unified-9.0.32/raw/ui-runtime.log +8 -0
  75. package/docs/reports/unified-9.0.32/raw/version-parity-928-929.log +6 -0
  76. package/docs/reports/unified-9.0.33/PRUEFBERICHT.md +60 -0
  77. package/docs/reports/unified-9.0.33/PRUEFERGEBNISSE.json +112 -0
  78. package/docs/reports/unified-9.0.33/raw/INDEX.json +272 -0
  79. package/docs/reports/unified-9.0.33/raw/backend.log +5 -0
  80. package/docs/reports/unified-9.0.33/raw/browser/UI_REVIEW.json +147 -0
  81. package/docs/reports/unified-9.0.33/raw/browser/admin-bundle.log +136 -0
  82. package/docs/reports/unified-9.0.33/raw/browser/eos-backup-settings-browser.log +67 -0
  83. package/docs/reports/unified-9.0.33/raw/browser/eos-customer-tariff-startup-browser.log +43 -0
  84. package/docs/reports/unified-9.0.33/raw/browser/eos-energyflow-browser-smoke.log +438 -0
  85. package/docs/reports/unified-9.0.33/raw/browser/eos-energyflow-cadence-browser-10s.log +108 -0
  86. package/docs/reports/unified-9.0.33/raw/browser/eos-evcs-delete-browser.log +1 -0
  87. package/docs/reports/unified-9.0.33/raw/browser/eos-history-setup-browser-smoke.log +49 -0
  88. package/docs/reports/unified-9.0.33/raw/browser/eos-kiosk-browser.log +59 -0
  89. package/docs/reports/unified-9.0.33/raw/browser/eos-ocpp-admin-browser.log +71 -0
  90. package/docs/reports/unified-9.0.33/raw/browser/eos-ocpp-installer-discovery-browser.log +11 -0
  91. package/docs/reports/unified-9.0.33/raw/browser/eos-pwa-trust-browser.log +35 -0
  92. package/docs/reports/unified-9.0.33/raw/browser/eos-runtime-controls-browser.log +78 -0
  93. package/docs/reports/unified-9.0.33/raw/browser/eos-runtime-health-browser.log +49 -0
  94. package/docs/reports/unified-9.0.33/raw/browser/eos-runtime-login-browser.log +34 -0
  95. package/docs/reports/unified-9.0.33/raw/browser/smarthome.log +46 -0
  96. package/docs/reports/unified-9.0.33/raw/browser-ten-seconds.json +108 -0
  97. package/docs/reports/unified-9.0.33/raw/changed-test-coverage.json +116 -0
  98. package/docs/reports/unified-9.0.33/raw/connected-control-node22.jsonl +42 -0
  99. package/docs/reports/unified-9.0.33/raw/connected-control-summary-node22.json +103 -0
  100. package/docs/reports/unified-9.0.33/raw/connected-control-summary.json +103 -0
  101. package/docs/reports/unified-9.0.33/raw/connected-control.jsonl +42 -0
  102. package/docs/reports/unified-9.0.33/raw/display-ui-node22.log +162 -0
  103. package/docs/reports/unified-9.0.33/raw/display-ui.log +35 -0
  104. package/docs/reports/unified-9.0.33/raw/frontend.log +151 -0
  105. package/docs/reports/unified-9.0.33/raw/git-delivery-fix.log +10 -0
  106. package/docs/reports/unified-9.0.33/raw/installer.log +26 -0
  107. package/docs/reports/unified-9.0.33/raw/license-central-node24.log +173 -0
  108. package/docs/reports/unified-9.0.33/raw/lint-final.log +45 -0
  109. package/docs/reports/unified-9.0.33/raw/modules.log +5 -0
  110. package/docs/reports/unified-9.0.33/raw/node22-npm-version.log +1 -0
  111. package/docs/reports/unified-9.0.33/raw/node22-tests-final.log +17646 -0
  112. package/docs/reports/unified-9.0.33/raw/node22-version.log +1 -0
  113. package/docs/reports/unified-9.0.33/raw/node24-npm-version.log +1 -0
  114. package/docs/reports/unified-9.0.33/raw/node24-tests-final.log +2941 -0
  115. package/docs/reports/unified-9.0.33/raw/node24-version.log +1 -0
  116. package/docs/reports/unified-9.0.33/raw/process-final-node22.log +220 -0
  117. package/docs/reports/unified-9.0.33/raw/process-final-node24.log +110 -0
  118. package/docs/reports/unified-9.0.33/raw/ram-picker.jsonl +12 -0
  119. package/docs/reports/unified-9.0.33/raw/reg-combined-node22.log +622 -0
  120. package/docs/reports/unified-9.0.33/raw/reg-combined.log +108 -0
  121. package/docs/reports/unified-9.0.33/raw/sbom-final.log +8 -0
  122. package/docs/reports/unified-9.0.33/raw/tariff-update-all-final-node22.log +1185 -0
  123. package/docs/reports/unified-9.0.33/raw/typecheck-final.log +5 -0
  124. package/docs/reports/unified-9.0.33/raw/ui-functional-node24.log +430 -0
  125. package/docs/reports/unified-9.0.33/raw/ui-runtime-final-verification.log +1 -0
  126. package/docs/reports/unified-9.0.33/raw/update-controller-standard-7-2-5.log +4 -0
  127. package/docs/reports/unified-9.0.33/raw/worker-memory-eos933.log +12 -0
  128. package/docs/reports/unified-9.0.33/raw/worker-memory-flow932.log +12 -0
  129. package/docs/reports/unified-9.0.34/PRUEFBERICHT.md +40 -0
  130. package/docs/reports/unified-9.0.34/PRUEFERGEBNISSE.json +112 -0
  131. package/docs/reports/unified-9.0.34/raw/INDEX.json +137 -0
  132. package/docs/reports/unified-9.0.34/raw/backend.log +5 -0
  133. package/docs/reports/unified-9.0.34/raw/dashboard-interval.json +108 -0
  134. package/docs/reports/unified-9.0.34/raw/fixtures-verification.log +44 -0
  135. package/docs/reports/unified-9.0.34/raw/frontend.log +152 -0
  136. package/docs/reports/unified-9.0.34/raw/installer.log +26 -0
  137. package/docs/reports/unified-9.0.34/raw/lint.log +45 -0
  138. package/docs/reports/unified-9.0.34/raw/mira-dashboard-browser.json +1 -0
  139. package/docs/reports/unified-9.0.34/raw/mira-devices-browser.log +9 -0
  140. package/docs/reports/unified-9.0.34/raw/mira-memory-process.json +379 -0
  141. package/docs/reports/unified-9.0.34/raw/modules.log +5 -0
  142. package/docs/reports/unified-9.0.34/raw/node22-mira.log +216 -0
  143. package/docs/reports/unified-9.0.34/raw/node22-protocol-to-ems.log +8 -0
  144. package/docs/reports/unified-9.0.34/raw/node22-tests-final.log +17850 -0
  145. package/docs/reports/unified-9.0.34/raw/node22-version.log +1 -0
  146. package/docs/reports/unified-9.0.34/raw/node24-mira.log +40 -0
  147. package/docs/reports/unified-9.0.34/raw/node24-protocol-to-ems.log +6 -0
  148. package/docs/reports/unified-9.0.34/raw/node24-tests-final.log +2973 -0
  149. package/docs/reports/unified-9.0.34/raw/node24-version.log +1 -0
  150. package/docs/reports/unified-9.0.34/raw/protocol-to-ems.cjs +364 -0
  151. package/docs/reports/unified-9.0.34/raw/release-metadata.log +13 -0
  152. package/docs/reports/unified-9.0.34/raw/sbom.log +8 -0
  153. package/docs/reports/unified-9.0.34/raw/typecheck.log +5 -0
  154. package/docs/reports/unified-9.0.34/raw/ui-runtime.log +8 -0
  155. package/docs/start/START_HIER_9.0.32.md +16 -0
  156. package/docs/start/START_HIER_9.0.33.md +32 -0
  157. package/docs/start/START_HIER_9.0.34.md +25 -0
  158. package/io-package.json +16 -16
  159. package/modules/devices/admin/alias-contract-v1.json +22 -0
  160. package/modules/devices/admin/ems-assignment.js +6 -1
  161. package/modules/devices/admin/host-bridge.js +2 -0
  162. package/modules/devices/admin/index.html +16 -0
  163. package/modules/devices/admin/index_m.js +168 -9
  164. package/modules/devices/admin/templates.json +976 -0
  165. package/modules/devices/checks/emsAssignment.check.js +52 -2
  166. package/modules/devices/index.js +5 -1
  167. package/modules/devices/lib/alias-contract-v1.json +22 -0
  168. package/modules/devices/lib/deviceRuntime.js +17 -7
  169. package/modules/devices/lib/drivers/modbus.js +1 -1
  170. package/modules/devices/lib/drivers/modbusRtuBus.js +7 -1
  171. package/modules/devices/lib/drivers/ovumMira.js +148 -0
  172. package/modules/devices/lib/ovumMiraAliases.js +61 -0
  173. package/modules/devices/lib/ovumMiraConnection.js +32 -0
  174. package/modules/devices/lib/templates.json +976 -0
  175. package/modules/devices/test/aliasContractV1.test.js +4 -4
  176. package/modules/devices/test/deviceAliasSemantics.test.js +2 -2
  177. package/modules/devices/test/fixtures/approved-additive-templates.json +3 -1
  178. package/modules/devices/test/ovumMiraPairing.test.js +76 -0
  179. package/modules/devices/test/ovumMiraTemplates.test.js +110 -0
  180. package/modules/devices/test/ovumMiraTransport.test.js +162 -0
  181. package/package.json +10 -5
  182. package/release-manifests/unified/build-environment.cdx.json +7 -7
  183. package/release-manifests/unified/files.json +302 -180
  184. package/release-manifests/unified/frontend.cdx.json +7 -7
  185. package/release-manifests/unified/installer.cdx.json +7 -7
  186. package/release-manifests/unified/obsolete-admin-assets.json +281 -28
  187. package/release-manifests/unified/runtime.cdx.json +28 -28
  188. package/release-manifests/unified/validation.json +15 -15
  189. package/tools/eos-release-manifest.cjs +2 -2
  190. package/ui/ems/consumers/ovum-mira.js +164 -0
  191. package/ui/ems/consumers/sg-ready.js +26 -6
  192. package/ui/ems/datapoints.js +12 -4
  193. package/ui/ems/modules/charging-management.js +58 -67
  194. package/ui/ems/modules/core-limits.js +59 -36
  195. package/ui/ems/modules/para14a.js +3 -2
  196. package/ui/ems/modules/prime-mover-control.js +141 -29
  197. package/ui/ems/modules/stage-a-diagnostics.js +4 -2
  198. package/ui/ems/modules/storage-control.js +31 -38
  199. package/ui/ems/modules/storage-mapping.js +14 -13
  200. package/ui/ems/modules/tarif-vis.js +38 -56
  201. package/ui/ems/modules/thermal-control.js +91 -10
  202. package/ui/ems/services/measurement-freshness.js +58 -21
  203. package/ui/ems/services/safety-envelope.js +13 -6
  204. package/ui/io-package.json +13 -1
  205. package/ui/lib/datapoint-picker.js +27 -20
  206. package/ui/lib/installer-lifecycle.js +11 -2
  207. package/ui/lib/tariff-price.js +7 -1
  208. package/ui/lib/ts-mirrors/ems/core-limits/core-runtime.js +5 -1
  209. package/ui/main.js +313 -188
  210. package/ui/package.json +4 -3
  211. package/ui/www/app.js +238 -100
  212. package/ui/www/ems-apps.js +30 -10
  213. package/ui/www/index.html +1 -0
  214. package/ui/www/licenses/smarthome-markdown-components.json +156 -156
  215. package/ui/www/live-display.js +38 -4
  216. package/ui/www/manifest.webmanifest +2 -2
  217. package/ui/www/power-measurements.js +28 -3
  218. package/adminWww/assets/AddLink-0L0E-LsA.js +0 -1
  219. package/adminWww/assets/ColorLens-DA51K29x.js +0 -1
  220. package/adminWww/assets/ConfigManager-C2naRwDl.js +0 -1
  221. package/adminWww/assets/Enums-B9ucB-qg.js +0 -92
  222. package/adminWww/assets/Fields-DN41WFbp.js +0 -1
  223. package/adminWww/assets/FileCopy-B16lEuur.js +0 -1
  224. package/adminWww/assets/Files-C3PbbeNR.js +0 -1
  225. package/adminWww/assets/Instances-PKvEjDNQ.js +0 -4
  226. package/adminWww/assets/Intro-BnYMjDZr.js +0 -2
  227. package/adminWww/assets/Lens-9lkeoWGk.js +0 -1
  228. package/adminWww/assets/LinearScale-Be5h2beh.js +0 -1
  229. package/adminWww/assets/North-C2whbHM-.js +0 -1
  230. package/adminWww/assets/Overview-CWLYuqZx.js +0 -3
  231. package/adminWww/assets/PersonOff-DqBq0Fho.js +0 -1
  232. package/adminWww/assets/PlaylistAdd-O8k92YBd.js +0 -1
  233. package/adminWww/assets/State-Ca9_Ke_c.js +0 -1
  234. package/adminWww/assets/UsedResources-20bsoxmj.js +0 -2
  235. package/adminWww/assets/Users-yZyZX-18.js +0 -1
  236. package/adminWww/assets/date-fns-C1dqkno9.js +0 -1
  237. package/adminWww/assets/icons-material-C3PNaipj.js +0 -1
  238. package/adminWww/assets/isSameWeek-Crh37s7U.js +0 -1
  239. package/adminWww/assets/isWithinInterval-Bo1WiDfq.js +0 -1
  240. package/adminWww/assets/locale-hLcz_Xh2.js +0 -1
  241. package/adminWww/assets/sentry-DwQQLI7N.js +0 -1
  242. package/adminWww/assets/startOfWeek-DJph8SIW.js +0 -1
@@ -7,7 +7,7 @@
7
7
  * AUTO-GENERATED RUNTIME FILE - NICHT MANUELL BEARBEITEN.
8
8
  *
9
9
  * Quelle: src-ts/runtime-executables/ems/modules/tarif-vis.ts
10
- * Quell-Hash: sha256:0b23f5257106c1900c5a001c8b7697dc1db059138d3443a6f34566b0a61bf8fc
10
+ * Quell-Hash: sha256:1ef6a702f33390e7f72332ae2b9b20ed5b1d0f04bbb5b8e626592756d54563a5
11
11
  * Erzeugung: npm run sync:ts-runtime-executables
12
12
  *
13
13
  * Zweck:
@@ -74,7 +74,7 @@
74
74
  'use strict';
75
75
 
76
76
  const { BaseModule } = require('./base');
77
- const { tariffPriceUnit, normalizeTariffPrice } = require('../../lib/tariff-price');
77
+ const { tariffPriceUnit, normalizeTariffPrice, verifiedTariffAgeMs } = require('../../lib/tariff-price');
78
78
 
79
79
  /**
80
80
  * Speicher-Netzladen ist strikt an einen frischen, aktiven und als „günstig“
@@ -981,10 +981,6 @@ class TarifVisModule extends BaseModule {
981
981
  }
982
982
 
983
983
  async tick() {
984
- // VIS-Einstellungen sind Konfigurationswerte und müssen dauerhaft gültig bleiben.
985
- // Wenn diese nach kurzer Zeit als "stale" gelten, fällt die Logik auf Fallbacks zurück
986
- // (z.B. Manual-Preis = null) und die Tarifsteuerung wirkt "inaktiv".
987
- const staleTimeoutMs = 365 * 24 * 60 * 60 * 1000; // 1 Jahr
988
984
  // Aktueller Preis und Day-Ahead-Kurve haben unterschiedliche Lebenszeiten:
989
985
  // - der aktuelle Stundenpreis darf standardmäßig höchstens 90 Minuten alt sein;
990
986
  // - Durchschnitt und Day-Ahead-Kurve dürfen bis zu 36 Stunden alt sein.
@@ -1000,18 +996,16 @@ class TarifVisModule extends BaseModule {
1000
996
 
1001
997
  try {
1002
998
  // --- VIS Settings ---
1003
- const aktiv = this.dp ? this.dp.getBoolean('vis.settings.dynamicTariff', false) : false;
1004
- const aktivAge = this.dp ? this.dp.getAgeMs('vis.settings.dynamicTariff') : null;
1005
- const aktivFresh = (aktivAge === null || aktivAge === undefined) ? true : (aktivAge <= staleTimeoutMs);
1006
- const aktivEff = !!(aktivFresh && aktiv);
999
+ // Persisted operator settings remain in force until changed.
1000
+ const aktivEff = !!this.dp?.getBoolean('vis.settings.dynamicTariff', false);
1007
1001
 
1008
- const modusRaw = this.dp ? this.dp.getNumberFresh('vis.settings.tariffMode', staleTimeoutMs, null) : null;
1002
+ const modusRaw = this.dp ? this.dp.getNumber('vis.settings.tariffMode', null) : null;
1009
1003
  const modusInt = (typeof modusRaw === 'number' && Number.isFinite(modusRaw)) ? Math.round(modusRaw) : 1;
1010
1004
 
1011
- const preisGrenzeVisRaw = this.dp ? this.dp.getNumberFresh('vis.settings.price', staleTimeoutMs, null) : null;
1012
- const priorRaw = this.dp ? this.dp.getNumberFresh('vis.settings.priority', staleTimeoutMs, null) : null;
1013
- const storageW = this.dp ? this.dp.getNumberFresh('vis.settings.storagePower', staleTimeoutMs, null) : null;
1014
- const evcsMaxW = this.dp ? this.dp.getNumberFresh('vis.settings.evcsMaxPower', staleTimeoutMs, null) : null;
1005
+ const preisGrenzeVisRaw = this.dp ? this.dp.getNumber('vis.settings.price', null) : null;
1006
+ const priorRaw = this.dp ? this.dp.getNumber('vis.settings.priority', null) : null;
1007
+ const storageW = this.dp ? this.dp.getNumber('vis.settings.storagePower', null) : null;
1008
+ const evcsMaxW = this.dp ? this.dp.getNumber('vis.settings.evcsMaxPower', null) : null;
1015
1009
 
1016
1010
  const prioritaet = this._normPrioritaet(priorRaw);
1017
1011
  const storagePowerAbsW = Math.max(0, Math.abs(this._num(storageW, 0)));
@@ -1021,17 +1015,8 @@ class TarifVisModule extends BaseModule {
1021
1015
  // Unterstützt zwei Modelle:
1022
1016
  // 1) Einfach (HT/NT) – ganzjährig
1023
1017
  // 2) Quartale (NT/HT je Quartal, Rest = Standard)
1024
- const netFeeEnabledRaw = this.dp ? this.dp.getBoolean('vis.settings.netFeeEnabled', false) : false;
1025
- const netFeeAge = this.dp ? this.dp.getAgeMs('vis.settings.netFeeEnabled') : null;
1026
- const netFeeFresh = (netFeeAge === null || netFeeAge === undefined) ? true : (netFeeAge <= staleTimeoutMs);
1027
-
1028
- // IMPORTANT (Robustness/UX):
1029
- // Das Zeitfenster muss auch ohne dynamischen Stromtarif funktionieren.
1030
- // Ist der dynamische Tarif aktiv, muss sein Preis zusätzlich frisch sein;
1031
- // teuer, stale oder unbekannt sperrt trotz NT die wirtschaftliche Netzladung.
1032
- const netFeeEff = !!(netFeeFresh && netFeeEnabledRaw);
1033
-
1034
- const netFeeModelRaw = this.dp ? this.dp.getNumberFresh('vis.settings.netFeeModel', staleTimeoutMs, 1) : 1;
1018
+ const netFeeEff = !!this.dp?.getBoolean('vis.settings.netFeeEnabled', false);
1019
+ const netFeeModelRaw = this.dp ? this.dp.getNumber('vis.settings.netFeeModel', 1) : 1;
1035
1020
  const netFeeModel = (typeof netFeeModelRaw === 'number' && Number.isFinite(netFeeModelRaw)) ? Math.round(netFeeModelRaw) : 1;
1036
1021
  const netFeeModelEff = (netFeeModel === 2) ? 2 : 1;
1037
1022
 
@@ -1109,35 +1094,33 @@ class TarifVisModule extends BaseModule {
1109
1094
 
1110
1095
  let preisAktuell = null;
1111
1096
  let preisAktuellSource = 'missing';
1112
- const currentPriceAgeMs = (this.dp && typeof this.dp.getAgeMs === 'function')
1113
- ? this.dp.getAgeMs('tarif.preisAktuellEurProKwh')
1114
- : null;
1115
- const currentPriceDirectFresh = currentPriceAgeMs === null || currentPriceAgeMs === undefined || currentPriceAgeMs <= currentPriceMaxAgeMs;
1116
- if (this.dp && typeof this.dp.getEntry === 'function' && this.dp.getEntry('tarif.preisAktuellEurProKwh')) {
1117
- const raw = this.dp.getNumberFresh('tarif.preisAktuellEurProKwh', currentPriceMaxAgeMs, null);
1118
- preisAktuell = this._normalizePriceEurPerKwh(raw, null, this._priceInputUnit('tarif.preisAktuellEurProKwh', 'priceCurrent', 'currentPriceEurPerKwh'));
1119
- if (typeof preisAktuell === 'number' && Number.isFinite(preisAktuell)) preisAktuellSource = 'provider-current';
1120
- }
1121
-
1122
- let preisDurchschnitt = null;
1123
- const averagePriceAgeMs = (this.dp && typeof this.dp.getAgeMs === 'function')
1124
- ? this.dp.getAgeMs('tarif.preisDurchschnittEurProKwh')
1125
- : null;
1126
- if (this.dp && typeof this.dp.getEntry === 'function' && this.dp.getEntry('tarif.preisDurchschnittEurProKwh')) {
1127
- const raw = this.dp.getNumberFresh('tarif.preisDurchschnittEurProKwh', averagePriceMaxAgeMs, null);
1128
- preisDurchschnitt = this._normalizePriceEurPerKwh(raw, null, this._priceInputUnit('tarif.preisDurchschnittEurProKwh', 'priceAverage', 'averagePriceEurPerKwh'));
1129
- }
1097
+ // Use original, acknowledged samples for each price source. A heartbeat
1098
+ // or an old cached command cannot grant permission to buy electricity.
1099
+ const priceAge = key => verifiedTariffAgeMs(this.dp, key, nowMs);
1100
+ const currentPriceAgeMs = priceAge('tarif.preisAktuellEurProKwh');
1101
+ const currentPriceDirectFresh = currentPriceAgeMs <= currentPriceMaxAgeMs;
1102
+ if (currentPriceDirectFresh) {
1103
+ const raw = this.dp.getNumber('tarif.preisAktuellEurProKwh', null);
1104
+ preisAktuell = this._normalizePriceEurPerKwh(raw, null, this._priceInputUnit('tarif.preisAktuellEurProKwh', 'priceCurrent', 'currentPriceEurPerKwh'));
1105
+ if (Number.isFinite(preisAktuell)) preisAktuellSource = 'provider-current';
1106
+ }
1107
+
1108
+ let preisDurchschnitt = null;
1109
+ if (priceAge('tarif.preisDurchschnittEurProKwh') <= averagePriceMaxAgeMs) {
1110
+ const raw = this.dp.getNumber('tarif.preisDurchschnittEurProKwh', null);
1111
+ preisDurchschnitt = this._normalizePriceEurPerKwh(raw, null, this._priceInputUnit('tarif.preisDurchschnittEurProKwh', 'priceAverage', 'averagePriceEurPerKwh'));
1112
+ }
1130
1113
 
1131
1114
  const preisVisOk = (typeof preisGrenzeVis === 'number' && Number.isFinite(preisGrenzeVis));
1132
1115
  let preisAktuellOk = (typeof preisAktuell === 'number' && Number.isFinite(preisAktuell));
1133
1116
  const preisDurchschnittOk = (typeof preisDurchschnitt === 'number' && Number.isFinite(preisDurchschnitt));
1134
1117
 
1135
- const todayCurveAgeMs = (this.dp && typeof this.dp.getAgeMs === 'function') ? this.dp.getAgeMs('tarif.pricesTodayJson') : null;
1136
- const tomorrowCurveAgeMs = (this.dp && typeof this.dp.getAgeMs === 'function') ? this.dp.getAgeMs('tarif.pricesTomorrowJson') : null;
1137
- const todayCurveFresh = todayCurveAgeMs === null || todayCurveAgeMs === undefined || todayCurveAgeMs <= curveMaxAgeMs;
1138
- const tomorrowCurveFresh = tomorrowCurveAgeMs === null || tomorrowCurveAgeMs === undefined || tomorrowCurveAgeMs <= curveMaxAgeMs;
1139
- const curveAgeCandidates = [todayCurveAgeMs, tomorrowCurveAgeMs].filter(value => Number.isFinite(Number(value))).map(Number);
1140
- const curveAgeMs = curveAgeCandidates.length ? Math.min(...curveAgeCandidates) : null;
1118
+ const todayCurveAgeMs = priceAge('tarif.pricesTodayJson');
1119
+ const tomorrowCurveAgeMs = priceAge('tarif.pricesTomorrowJson');
1120
+ const todayCurveFresh = todayCurveAgeMs <= curveMaxAgeMs;
1121
+ const tomorrowCurveFresh = tomorrowCurveAgeMs <= curveMaxAgeMs;
1122
+ const curveAgeMs = Math.min(todayCurveAgeMs, tomorrowCurveAgeMs);
1123
+ let effectiveCurrentPriceAgeMs = currentPriceAgeMs;
1141
1124
  let curveFresh = false;
1142
1125
  let priceDataStatus = preisAktuellOk ? 'current-price-fresh' : (currentPriceDirectFresh ? 'current-price-missing' : 'current-price-stale');
1143
1126
 
@@ -1205,6 +1188,7 @@ class TarifVisModule extends BaseModule {
1205
1188
  preisAktuell = activeSegment.priceEurKwh;
1206
1189
  preisAktuellOk = true;
1207
1190
  preisAktuellSource = 'curve-current';
1191
+ effectiveCurrentPriceAgeMs = todayArr.includes(activeSegment) ? todayCurveAgeMs : tomorrowCurveAgeMs;
1208
1192
  priceDataStatus = 'current-from-fresh-curve';
1209
1193
  }
1210
1194
  }
@@ -1236,11 +1220,9 @@ class TarifVisModule extends BaseModule {
1236
1220
  if (negAll.length > 0) {
1237
1221
  negativeMinPrice = Math.min(...negAll.map(x => x.priceEurKwh));
1238
1222
  const activeSeg = negAll.find(x => x.startMs <= nowMs && x.endMs > nowMs);
1239
- if (activeSeg) {
1240
- negativeActive = true;
1241
- negativeWindowNow = true;
1242
- negativeCurrentPrice = activeSeg.priceEurKwh;
1243
- }
1223
+ // The forecast describes its window. Only the selected current
1224
+ // price (direct, or the curve as fallback) grants grid import.
1225
+ negativeWindowNow = !!activeSeg;
1244
1226
 
1245
1227
  const first = negAll[0];
1246
1228
  let winStart = first.startMs;
@@ -1641,7 +1623,6 @@ class TarifVisModule extends BaseModule {
1641
1623
  await this._setIfChanged('tarif.speicherLeistungW', this._num(storageW, 0));
1642
1624
  await this._setIfChanged('tarif.ladeparkMaxW', this._num(evcsMaxW, 0));
1643
1625
 
1644
- const effectiveCurrentPriceAgeMs = preisAktuellSource === 'curve-current' ? curveAgeMs : currentPriceAgeMs;
1645
1626
  await this._setIfChanged('tarif.currentPriceFresh', !!preisAktuellOk);
1646
1627
  await this._setIfChanged('tarif.currentPriceAgeMs', Number.isFinite(Number(effectiveCurrentPriceAgeMs)) ? Math.round(Number(effectiveCurrentPriceAgeMs)) : null);
1647
1628
  await this._setIfChanged('tarif.currentPriceMaxAgeMs', Math.round(currentPriceMaxAgeMs));
@@ -1796,6 +1777,7 @@ await this._setIfChanged('tarif.speicherIntentGrund', storageIntentReason);
1796
1777
  currentPriceFresh: !!preisAktuellOk,
1797
1778
  currentPriceAgeMs: Number.isFinite(Number(effectiveCurrentPriceAgeMs)) ? Math.round(Number(effectiveCurrentPriceAgeMs)) : null,
1798
1779
  currentPriceSource: preisAktuellSource,
1780
+ curveMaxAgeMs,
1799
1781
  curveFresh: !!curveFresh,
1800
1782
  curveAgeMs: Number.isFinite(Number(curveAgeMs)) ? Math.round(Number(curveAgeMs)) : null,
1801
1783
  priceDataStatus,
@@ -7,7 +7,7 @@
7
7
  * AUTO-GENERATED RUNTIME FILE - NICHT MANUELL BEARBEITEN.
8
8
  *
9
9
  * Quelle: src-ts/runtime-executables/ems/modules/thermal-control.ts
10
- * Quell-Hash: sha256:899d9d925a26038d8d956627ab100ebb4fc3b358992c1b4ccdb38ad00a37472a
10
+ * Quell-Hash: sha256:22a3be98230f58eece31013022c5f131d8e066abec396596b0ee8b2eaf687ff2
11
11
  * Erzeugung: npm run sync:ts-runtime-executables
12
12
  *
13
13
  * Zweck:
@@ -76,6 +76,7 @@
76
76
  const { BaseModule } = require('./base');
77
77
  const { resolveThermalStrategyOverlay } = require('../services/operating-strategy-runtime');
78
78
  const { applySetpoint } = require('../consumers');
79
+ const { miraBinding, registerMiraDevice, regulateMira, miraSample } = require('../consumers/ovum-mira');
79
80
  const { withActuatorShadowContext, priorityForOwner } = require('../services/actuator-shadow-arbiter');
80
81
  const { ActuatorCommandContract } = require('../services/actuator-command-contract');
81
82
  const { recordAcceptedPowerTarget } = require('../services/accepted-power-effects');
@@ -291,10 +292,13 @@ class ThermalControlModule extends BaseModule {
291
292
  const modeRaw = String(r.mode || 'pvAuto').trim().toLowerCase();
292
293
  const mode = (modeRaw === 'manual' || modeRaw === 'off') ? modeRaw : 'pvAuto';
293
294
 
294
- const type = normalizeType(r.type || r.deviceType || r.kind);
295
+ const ovumMira = r.ovumMira === true;
296
+ const type = ovumMira ? 'power' : normalizeType(r.type || r.deviceType || r.kind);
295
297
  const profile = normalizeProfile(r.profile, type);
296
298
 
297
- const maxPowerW = clamp(num(r.maxPowerW, 2500), 0, 1e12);
299
+ const maxPowerW = ovumMira
300
+ ? (Number.isSafeInteger(r.maxPowerW) && r.maxPowerW > 0 && r.maxPowerW <= 2147483647 ? r.maxPowerW : 0)
301
+ : clamp(num(r.maxPowerW, 2500), 0, 1e12);
298
302
  const startSurplusW = clamp(num(r.startSurplusW, 800), 0, 1e12);
299
303
  const stopSurplusW = clamp(num(r.stopSurplusW, 300), 0, 1e12);
300
304
  const minOnSec = clamp(num(r.minOnSec, 300), 0, 86400);
@@ -306,7 +310,7 @@ class ThermalControlModule extends BaseModule {
306
310
  if (slotTypeRaw === 'heatingrod' || slotTypeRaw === 'heating_rod' || slotTypeRaw === 'heating-rod' || slotTypeRaw === 'heizstab' || slotTypeRaw === 'rod' || slotTypeRaw === 'immersion') {
307
311
  continue;
308
312
  }
309
- const ctrl = (slotCfg.ctrl && typeof slotCfg.ctrl === 'object') ? slotCfg.ctrl : {};
313
+ const ctrl = (!ovumMira && slotCfg.ctrl && typeof slotCfg.ctrl === 'object') ? slotCfg.ctrl : {};
310
314
 
311
315
  const name = String(r.name || slotCfg.name || '').trim() || `Thermal ${slot}`;
312
316
 
@@ -379,6 +383,9 @@ class ThermalControlModule extends BaseModule {
379
383
  maxRetries,
380
384
  faultLockSec,
381
385
 
386
+ ovumMira,
387
+ miraSourcesConfirmed: ovumMira && maxPowerW > 0 && r.miraSourcesConfirmed === true,
388
+ miraBinding: ovumMira ? miraBinding(r, powerId, this.adapter.config.eosDeviceEms?.bindings, slot) : null,
382
389
  powerId,
383
390
  switchWriteId,
384
391
  setpointWriteId,
@@ -412,6 +419,14 @@ class ThermalControlModule extends BaseModule {
412
419
  return String(a.name || '').localeCompare(String(b.name || ''));
413
420
  });
414
421
 
422
+ // A hydraulic module represents one system. Ambiguous control assignments cannot write.
423
+ const miraOwners = new Map();
424
+ for (const d of out) {
425
+ if (!d.enabled || !d.miraSourcesConfirmed || !d.miraBinding) continue;
426
+ const previous = miraOwners.get(d.miraBinding.base);
427
+ if (previous) previous.miraConflict = d.miraConflict = true;
428
+ else miraOwners.set(d.miraBinding.base, d);
429
+ }
415
430
  this._devices = out;
416
431
  }
417
432
 
@@ -624,6 +639,8 @@ const mk = async (id, name, type, role, unit = undefined) => {
624
639
  d.pWKey = k;
625
640
  }
626
641
 
642
+ if (d.ovumMira) await registerMiraDevice(this.dp, d);
643
+
627
644
  // DP mapping (actuation)
628
645
  if (this.dp && d.switchWriteId) {
629
646
  const k = `th.${d.id}.en`;
@@ -667,9 +684,28 @@ const mk = async (id, name, type, role, unit = undefined) => {
667
684
  if (!Array.isArray(this._devices) || !this._devices.length) this._buildDevicesFromConfig();
668
685
  const failures = [];
669
686
  let attempted = 0;
687
+ let miraReleases = 0;
688
+ let miraMeasuredW = 0;
670
689
 
671
690
  for (const d of this._devices || []) {
672
691
  try {
692
+ if (d.ovumMira) {
693
+ await registerMiraDevice(this.dp, d);
694
+ if (!d.miraKeys) continue;
695
+ const mode = String(this.dp.getRaw(d.userModeKey, '') || '').toLowerCase();
696
+ const manual = ['manual', 'manuell'].includes(mode) || ((!mode || mode === 'inherit') && d.mode === 'manual')
697
+ || this.dp.getBoolean(d.userEnabledKey, true) === false || this._readOverrideForDevice(d, Date.now()).manualActive;
698
+ if (manual && !d.miraBoostIssued) continue;
699
+ attempted++;
700
+ miraReleases++;
701
+ const release = await regulateMira(this, d, { requestedW: 0 });
702
+ miraMeasuredW += release.usedW;
703
+ if (!release.applied) failures.push(d.id + ':' + release.status);
704
+ await this._setStateIfChanged(`thermal.devices.${d.id}.applied`, release.applied);
705
+ await this._setStateIfChanged(`thermal.devices.${d.id}.targetW`, 0);
706
+ await this._setStateIfChanged(`thermal.devices.${d.id}.status`, release.status);
707
+ continue;
708
+ }
673
709
  if (this.dp && typeof this.dp.upsert === 'function') {
674
710
  if (d.switchWriteId && !d.enableKey) {
675
711
  d.enableKey = `th.${d.id}.en`;
@@ -731,12 +767,15 @@ const mk = async (id, name, type, role, unit = undefined) => {
731
767
  }
732
768
  }
733
769
  try {
734
- await this._setStateIfChanged('thermal.summary.appliedTotalW', 0);
770
+ await this._setStateIfChanged('thermal.summary.appliedTotalW', Math.round(miraMeasuredW));
735
771
  await this._setStateIfChanged('thermal.summary.budgetUsedW', 0);
736
- await this._setStateIfChanged('thermal.summary.status', attempted ? 'module-disabled-safe-stop' : 'module-disabled-no-actuators');
772
+ const status = miraReleases ? (failures.length ? 'module-disabled-release-pending' : 'module-disabled-mira-local-control')
773
+ : (attempted ? 'module-disabled-safe-stop' : 'module-disabled-no-actuators');
774
+ await this._setStateIfChanged('thermal.summary.status', status);
737
775
  } catch (_diagnosticError) {}
738
776
  if (failures.length) throw new Error(`thermal-safe-stop-failed:${failures.join(',')}`);
739
- return { ok: true, attempted, stopped: attempted };
777
+ return miraReleases ? { ok: true, attempted, stopped: attempted - miraReleases, miraNeutral: miraReleases }
778
+ : { ok: true, attempted, stopped: attempted };
740
779
  }
741
780
 
742
781
  /**
@@ -1495,6 +1534,7 @@ const mk = async (id, name, type, role, unit = undefined) => {
1495
1534
 
1496
1535
  let appliedTotalW = 0;
1497
1536
  let budgetUsedW = 0;
1537
+ let miraPvReserveW = 0;
1498
1538
  const ctx = { dp: this.dp, adapter: this.adapter };
1499
1539
  // Der Core darf nur aktuelle PV-Automatiklast in sein PV-Budget
1500
1540
  // zurückrechnen. Dieser Modusnachweis ist getrennt von der direkten
@@ -1579,7 +1619,11 @@ const mk = async (id, name, type, role, unit = undefined) => {
1579
1619
  // Read measured power if mapped
1580
1620
  let measuredW = null;
1581
1621
  if (this.dp && d.pWKey && this.dp.getEntry && this.dp.getEntry(d.pWKey)) {
1582
- measuredW = this.dp.getNumber(d.pWKey, null);
1622
+ measuredW = d.ovumMira ? (miraSample(this.dp, d.pWKey, now)?.value ?? null) : this.dp.getNumber(d.pWKey, null);
1623
+ if (d.ovumMira && (measuredW === null || measuredW < 0)) {
1624
+ measuredW = null;
1625
+ await this._setStateIfChanged(`thermal.devices.${d.id}.measuredW`, null);
1626
+ }
1583
1627
  if (typeof measuredW === 'number' && Number.isFinite(measuredW)) {
1584
1628
  await this._setStateIfChanged(`thermal.devices.${d.id}.measuredW`, Math.round(measuredW));
1585
1629
  }
@@ -1590,13 +1634,50 @@ const mk = async (id, name, type, role, unit = undefined) => {
1590
1634
  // Manuell, Aus und Boost bleiben Hauslast. Der Core prüft zusätzlich
1591
1635
  // die Frische dieses Nachweises und des gemappten Leistungszählers.
1592
1636
  this.adapter._zeroExportPvOwnedThermal[d.id] = {
1593
- owned: effectiveEnabled && effectiveMode === 'pvAuto' && !ov.boostActive && !ov.manualActive,
1637
+ owned: !d.ovumMira && effectiveEnabled && effectiveMode === 'pvAuto' && !ov.boostActive && !ov.manualActive,
1594
1638
  ts: now,
1595
1639
  };
1596
1640
  await this._setStateIfChanged(`thermal.devices.${d.id}.boostActive`, !!ov.boostActive);
1597
1641
  await this._setStateIfChanged(`thermal.devices.${d.id}.boostUntil`, ov.boostUntil ? Math.round(ov.boostUntil) : 0);
1598
1642
  await this._setStateIfChanged(`thermal.devices.${d.id}.manualUntil`, ov.manualUntil ? Math.round(ov.manualUntil) : 0);
1599
1643
 
1644
+ if (d.ovumMira) {
1645
+ const boost = effectiveEnabled && ov.boostActive && d.boostEnabled;
1646
+ const manual = !effectiveEnabled || (!boost && (ov.manualActive || effectiveMode === 'manual'));
1647
+ let requestedW = 0;
1648
+ if (effectiveEnabled && !manual && !para14aActive) {
1649
+ if (boost) {
1650
+ requestedW = Math.min(d.boostPowerW, d.maxPowerW);
1651
+ } else if (effectiveMode === 'pvAuto') {
1652
+ let availableW = availableForAutomationW();
1653
+ if (pv.source === 'ems.budget.tariffNegative') {
1654
+ // A cheap-import grant alone is not a MIRA surplus request.
1655
+ const pvGrant = this.adapter._emsBudget?.getPvGrant?.({key: 'thermal', requestedW: availableW});
1656
+ availableW = Math.min(availableW, Math.max(0, num(pvGrant?.grantW, 0) - miraPvReserveW));
1657
+ }
1658
+ const band = this._computeBandDesiredOn(d.id, availableW, d.startSurplusW, d.stopSurplusW);
1659
+ const action = String(strategyOverlay.action || 'standard').toLowerCase();
1660
+ const pause = strategyOverlay.fallbackPause === true || (strategyOverlay.active && ['pause', 'off', 'disable', 'block'].includes(action));
1661
+ const on = this._hysteresisOnOff(d.id, !pause && band, d.minOnSec, d.minOffSec);
1662
+ requestedW = !pause && on ? Math.min(availableW, d.maxPowerW) : 0;
1663
+ if (strategyOverlay.active && typeof strategyOverlay.requestedPowerW === 'number') {
1664
+ requestedW = Math.min(requestedW, Math.max(0, strategyOverlay.requestedPowerW));
1665
+ }
1666
+ }
1667
+ }
1668
+ const mira = await regulateMira(this, d, { requestedW, manual, boost });
1669
+ this.adapter._zeroExportPvOwnedThermal[d.id].owned = mira.owned;
1670
+ const usedW = consumeControlledW(mira.usedW);
1671
+ appliedTotalW += measuredW === null ? 0 : Math.max(0, Math.round(measuredW));
1672
+ budgetUsedW += usedW;
1673
+ if (!boost && !manual && mira.targetW > 0) miraPvReserveW += usedW;
1674
+ await this._setStateIfChanged(`thermal.devices.${d.id}.targetW`, mira.targetW);
1675
+ await this._setStateIfChanged(`thermal.devices.${d.id}.applied`, mira.applied);
1676
+ await this._setStateIfChanged(`thermal.devices.${d.id}.status`, mira.status);
1677
+ await this._setStateIfChanged(`thermal.devices.${d.id}.override`, manual ? 'manual' : (boost ? 'boost' : ''));
1678
+ continue;
1679
+ }
1680
+
1600
1681
  const heldManualContext = !effectiveEnabled
1601
1682
  || (ov.manualActive && !ov.boostActive)
1602
1683
  || effectiveMode === 'manual';
@@ -2021,7 +2102,7 @@ const mk = async (id, name, type, role, unit = undefined) => {
2021
2102
  priority: 200,
2022
2103
  requestedW: used,
2023
2104
  reserveW: used,
2024
- pvReserveW: tariffImportPreferred ? 0 : used,
2105
+ pvReserveW: tariffImportPreferred ? Math.min(used, miraPvReserveW) : used,
2025
2106
  pvOnly: !tariffImportPreferred,
2026
2107
  mode: tariffImportPreferred ? 'tariffNegative' : 'pvAuto',
2027
2108
  });
@@ -7,7 +7,7 @@
7
7
  * AUTO-GENERATED RUNTIME FILE - NICHT MANUELL BEARBEITEN.
8
8
  *
9
9
  * Quelle: src-ts/runtime-executables/ems/services/measurement-freshness.ts
10
- * Quell-Hash: sha256:590430928acf161b2d47c16ed03f191400c392c9761775c3ddb835e714afb0d7
10
+ * Quell-Hash: sha256:e125e1d4d44561ea53e210281d0123c0abf217168ca0082e744434062d706920
11
11
  * Erzeugung: npm run sync:ts-runtime-executables
12
12
  *
13
13
  * Zweck:
@@ -110,6 +110,8 @@ function buildNvpSnapshotFromRegistry(input) {
110
110
  const invertGrid = input.invertGrid === true;
111
111
  const age = (key) => normalizedAge(typeof registry.getMeasurementAgeMs === 'function' ? registry.getMeasurementAgeMs(key) : registry.getAgeMs(key));
112
112
  const timestamp = (key) => {
113
+ if (typeof registry.getVerifiedMeasurementTimestampMs === 'function')
114
+ return registry.getVerifiedMeasurementTimestampMs(key, now);
113
115
  if (typeof registry.getMeasurementTimestampMs === 'function')
114
116
  return finiteOrNull(registry.getMeasurementTimestampMs(key));
115
117
  const valueAge = age(key);
@@ -136,8 +138,8 @@ function buildNvpSnapshotFromRegistry(input) {
136
138
  const watchdogId = String(watchdogEntry.srcObjectId || watchdogEntry.objectId || '');
137
139
  if (/lastSeenMs$/i.test(watchdogId)) {
138
140
  const lastSeenMs = registry.getNumber(watchdogKey, null);
139
- if (finiteOrNull(lastSeenMs) !== null && Number(lastSeenMs) > 0)
140
- heartbeatAgeMs = Math.max(0, now - Number(lastSeenMs));
141
+ if (finiteOrNull(lastSeenMs) !== null && Number(lastSeenMs) > 0 && Number(lastSeenMs) <= now)
142
+ heartbeatAgeMs = now - Number(lastSeenMs);
141
143
  }
142
144
  else {
143
145
  const candidates = [age(watchdogKey), aliveAge(watchdogKey)].filter((value) => value !== null);
@@ -155,14 +157,16 @@ function buildNvpSnapshotFromRegistry(input) {
155
157
  }
156
158
  const sample = (key, value) => {
157
159
  const mapped = !!registry.getEntry(key);
160
+ const sampleTs = mapped ? timestamp(key) : null;
161
+ const measurementAgeMs = sampleTs !== null && sampleTs > 0 && sampleTs <= now ? now - sampleTs : null;
158
162
  return {
159
163
  mapped,
160
164
  value,
161
- sampleTs: mapped ? timestamp(key) : null,
165
+ sampleTs,
162
166
  freshness: evaluateMeasurementFreshness({
163
167
  mapped,
164
168
  present: mapped && finiteOrNull(value) !== null,
165
- measurementAgeMs: mapped ? age(key) : null,
169
+ measurementAgeMs,
166
170
  heartbeatAgeMs,
167
171
  connected,
168
172
  }, { staleMs, heartbeatStaleMs: staleMs, maxHeartbeatHoldMs }),
@@ -176,12 +180,28 @@ function buildNvpSnapshotFromRegistry(input) {
176
180
  const exportKey = invertGrid ? buyKey : sellKey;
177
181
  const importValue = finiteOrNull(invertGrid ? rawSell : rawBuy);
178
182
  const exportValue = finiteOrNull(invertGrid ? rawBuy : rawSell);
183
+ const importSample = sample(importKey, importValue);
184
+ const exportSample = sample(exportKey, exportValue);
179
185
  const resolution = resolveNvpMeasurement({
180
186
  signed: sample(signedKey, signedValue),
181
- import: sample(importKey, importValue),
182
- export: sample(exportKey, exportValue),
187
+ import: importSample,
188
+ export: exportSample,
183
189
  maxSkewMs,
184
190
  });
191
+ // Bei fehlerhafter Telemetrie eines konfigurierten Richtungskanals darf
192
+ // der Gegenkanal allein keinen vollständigen NVP für Stellbefehle vortäuschen.
193
+ if (resolution.mode === 'split' && resolution.usable &&
194
+ ((importSample.mapped && (importSample.value === null || importSample.freshness?.measurementAgeMs == null)) ||
195
+ (exportSample.mapped && (exportSample.value === null || exportSample.freshness?.measurementAgeMs == null)))) {
196
+ resolution.usable = false;
197
+ resolution.coherent = false;
198
+ resolution.status = 'stale';
199
+ resolution.reason = 'split-measurement-invalid';
200
+ resolution.netW = null;
201
+ resolution.importW = 0;
202
+ resolution.exportW = 0;
203
+ resolution.measurementAgeMs = null;
204
+ }
185
205
  return {
186
206
  ...resolution,
187
207
  ts: now,
@@ -211,20 +231,23 @@ function resolveNvpDisplay(input) {
211
231
  gridSellW: Math.max(0, -canonicalNetW),
212
232
  hasGrid: true,
213
233
  src: String(input.canonicalSource || 'ems-canonical'),
234
+ sampleSource: 'canonical',
214
235
  ...mapped,
215
236
  };
216
237
  }
217
238
  if (input.canonicalKnown && input.canonicalFresh === false) {
218
- return { gridBuyRaw: null, gridSellRaw: null, gridNetRaw: null, gridBuyW: 0, gridSellW: 0, hasGrid: false, src: `ems-${String(input.canonicalStatus || 'stale')}`, ...mapped };
239
+ return { gridBuyRaw: null, gridSellRaw: null, gridNetRaw: null, gridBuyW: 0, gridSellW: 0, hasGrid: false, src: `ems-${String(input.canonicalStatus || 'stale')}`, sampleSource: 'missing', ...mapped };
219
240
  }
220
241
  const gridNetRaw = finiteOrNull(input.gridNetRaw);
221
242
  let gridBuyRaw = finiteOrNull(input.gridBuyRaw);
222
243
  let gridSellRaw = finiteOrNull(input.gridSellRaw);
223
244
  let src = 'missing';
245
+ let sampleSource = 'missing';
224
246
  if (gridNetRaw !== null) {
225
247
  gridBuyRaw = Math.max(0, gridNetRaw);
226
248
  gridSellRaw = Math.max(0, -gridNetRaw);
227
249
  src = 'net-fresh';
250
+ sampleSource = 'signed';
228
251
  }
229
252
  else if (gridBuyRaw !== null || gridSellRaw !== null) {
230
253
  const buyTs = finiteOrNull(input.gridBuyTs);
@@ -234,21 +257,27 @@ function resolveNvpDisplay(input) {
234
257
  if (buyTs >= sellTs) {
235
258
  gridSellRaw = 0;
236
259
  src = 'split-newer-import';
260
+ sampleSource = 'import';
237
261
  }
238
262
  else {
239
263
  gridBuyRaw = 0;
240
264
  src = 'split-newer-export';
265
+ sampleSource = 'export';
241
266
  }
242
267
  }
243
- else if (gridBuyRaw !== null && gridSellRaw !== null)
268
+ else if (gridBuyRaw !== null && gridSellRaw !== null) {
244
269
  src = 'split-coherent';
270
+ sampleSource = 'split';
271
+ }
245
272
  else if (gridBuyRaw !== null) {
246
273
  gridSellRaw = 0;
247
274
  src = 'split-import-only';
275
+ sampleSource = 'import';
248
276
  }
249
277
  else {
250
278
  gridBuyRaw = 0;
251
279
  src = 'split-export-only';
280
+ sampleSource = 'export';
252
281
  }
253
282
  }
254
283
  const rawBuyW = Math.max(0, Math.abs(gridBuyRaw ?? 0));
@@ -267,6 +296,7 @@ function resolveNvpDisplay(input) {
267
296
  gridSellW,
268
297
  hasGrid,
269
298
  src,
299
+ sampleSource,
270
300
  ...mapped,
271
301
  };
272
302
  }
@@ -276,20 +306,27 @@ function resolveCurrentNvpSnapshot(snapshot, now, maxAgeMs) {
276
306
  if (!value)
277
307
  return { known: false, current: false, usable: false, ageMs: null, measurementAgeMs: null, heartbeatAgeMs: null, netW: null, status: 'missing', source: '', reason: '', connected: null };
278
308
  const ts = finiteOrNull(value.ts);
279
- const ageMs = ts === null ? null : Math.max(0, now - ts);
280
- const current = ageMs !== null && ageMs <= Math.max(1000, maxAgeMs);
309
+ const ageMs = ts !== null && ts > 0 && ts <= now ? now - ts : null;
310
+ const limitMs = Math.max(1000, maxAgeMs);
311
+ const current = ageMs !== null && ageMs <= limitMs;
312
+ // Ältere Einzelmessungs-Snapshots tragen nur ts. Die Engine führt das Messalter
313
+ // ausdrücklich mit, da ein neuer Rechenzyklus kein neues Zählersample ist.
314
+ const atCreation = 'measurementAgeMs' in value ? finiteOrNull(value.measurementAgeMs) : 0;
315
+ const measurementAgeMs = ageMs !== null && atCreation !== null && atCreation >= 0 ? atCreation + ageMs : null;
316
+ const physicalFresh = measurementAgeMs !== null && measurementAgeMs <= limitMs;
317
+ const expiredMeasurement = current && value.usable === true && !physicalFresh;
281
318
  const netW = finiteOrNull(value.netW);
282
319
  return {
283
320
  known: true,
284
321
  current,
285
- usable: current && value.usable === true && netW !== null && value.connected !== false,
322
+ usable: current && physicalFresh && value.usable === true && netW !== null && value.connected !== false,
286
323
  ageMs,
287
- measurementAgeMs: normalizedAge(value.measurementAgeMs),
324
+ measurementAgeMs,
288
325
  heartbeatAgeMs: normalizedAge(value.heartbeatAgeMs),
289
326
  netW,
290
- status: String(value.status || (current ? 'stale' : 'snapshot-stale')),
327
+ status: expiredMeasurement ? 'stale' : String(value.status || (current ? 'stale' : 'snapshot-stale')),
291
328
  source: String(value.source || 'ems-canonical'),
292
- reason: String(value.reason || ''),
329
+ reason: expiredMeasurement ? 'measurement-stale' : String(value.reason || ''),
293
330
  connected: typeof value.connected === 'boolean' ? value.connected : null,
294
331
  };
295
332
  }
@@ -346,8 +383,8 @@ function resolveNvpMeasurement(input) {
346
383
  const importTs = channelTs(imp);
347
384
  const exportTs = channelTs(exp);
348
385
  const skewMs = importTs !== null && exportTs !== null ? Math.abs(importTs - exportTs) : null;
349
- const ages = [channelAge(imp), channelAge(exp)].filter((age) => age !== null);
350
- const measurementAgeMs = ages.length ? Math.min(...ages) : null;
386
+ const importAge = channelAge(imp);
387
+ const exportAge = channelAge(exp);
351
388
  if (importFresh && exportFresh) {
352
389
  if (skewMs === null || skewMs <= maxSkewMs) {
353
390
  return {
@@ -361,11 +398,11 @@ function resolveNvpMeasurement(input) {
361
398
  importW,
362
399
  exportW,
363
400
  skewMs,
364
- measurementAgeMs,
401
+ measurementAgeMs: importAge !== null && exportAge !== null ? Math.max(importAge, exportAge) : null,
365
402
  reason: 'split-coherent',
366
403
  };
367
404
  }
368
- const useImport = importTs !== null && exportTs !== null ? importTs >= exportTs : (channelAge(imp) ?? Infinity) <= (channelAge(exp) ?? Infinity);
405
+ const useImport = importTs !== null && exportTs !== null ? importTs >= exportTs : (importAge ?? Infinity) <= (exportAge ?? Infinity);
369
406
  return {
370
407
  usable: true,
371
408
  coherent: false,
@@ -377,7 +414,7 @@ function resolveNvpMeasurement(input) {
377
414
  importW: useImport ? importW : 0,
378
415
  exportW: useImport ? 0 : exportW,
379
416
  skewMs,
380
- measurementAgeMs,
417
+ measurementAgeMs: useImport ? importAge : exportAge,
381
418
  reason: `split-skew>${Math.round(maxSkewMs)}ms`,
382
419
  };
383
420
  }
@@ -424,7 +461,7 @@ function resolveNvpMeasurement(input) {
424
461
  importW: 0,
425
462
  exportW: 0,
426
463
  skewMs,
427
- measurementAgeMs,
464
+ measurementAgeMs: importAge !== null && exportAge !== null ? Math.min(importAge, exportAge) : importAge ?? exportAge,
428
465
  reason: [imp?.freshness?.reason, exp?.freshness?.reason].filter(Boolean).join('+') || 'split-stale',
429
466
  };
430
467
  }