iobroker.eos-admin 9.0.19 → 9.0.20

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 (460) hide show
  1. package/NEXOWATT_EOS_BUILD_INFO.json +4 -4
  2. package/README.md +5 -3
  3. package/START_HIER_9.0.20.md +65 -0
  4. package/adminWww/.vite/manifest.json +39 -39
  5. package/adminWww/NEXOWATT_EOS_FRONTEND_MANIFEST.json +110 -109
  6. package/adminWww/assets/{AdapterUpdateDialog-JOf2z4Vg.js → AdapterUpdateDialog-CRD3XVom.js} +1 -1
  7. package/adminWww/assets/{Adapters-C9fcSdWm.js → Adapters-Cuf0X0CU.js} +1 -1
  8. package/adminWww/assets/{ConfigManager-BeeLlT6D.js → ConfigManager-B8ycQt1C.js} +1 -1
  9. package/adminWww/assets/{Enums-FqnXWl8U.js → Enums-CctVCgZX.js} +1 -1
  10. package/adminWww/assets/{Fields-DMgrt5Pi.js → Fields-onm4DfoO.js} +1 -1
  11. package/adminWww/assets/{Files-CIHtt12g.js → Files-OLP3Rwc7.js} +1 -1
  12. package/adminWww/assets/{Hosts-fPLBzvTy.js → Hosts-C31oqMcW.js} +1 -1
  13. package/adminWww/assets/{Instances-4XaVQlrT.js → Instances-DFdvJ9pa.js} +1 -1
  14. package/adminWww/assets/{Intro-5TKriiLO.js → Intro-DvsFJxU0.js} +1 -1
  15. package/adminWww/assets/{Logs-33zcIds-.js → Logs-Zqg2Bqv6.js} +1 -1
  16. package/adminWww/assets/{Objects-CNQPVbNG.js → Objects-CpWZp6yp.js} +1 -1
  17. package/adminWww/assets/{Overview-BskXGOc8.js → Overview-BsKUo298.js} +1 -1
  18. package/adminWww/assets/{State-C8SJ_Iqo.js → State-D_xwlhhb.js} +1 -1
  19. package/adminWww/assets/{UsedResources-CgqRa9ei.js → UsedResources-C79N6yZx.js} +1 -1
  20. package/adminWww/assets/{Users-0JVYWR9u.js → Users-WgC0O8P0.js} +1 -1
  21. package/adminWww/assets/{bootstrap-D16lu6rd.js → bootstrap-BcfBoIoa.js} +3 -3
  22. package/adminWww/assets/{hostInit-C8YZJuzi.js → hostInit-B7bBV7cH.js} +1 -1
  23. package/adminWww/assets/icons/nexowatt-180.png +0 -0
  24. package/adminWww/assets/{icons-material-CiNJ_6Ur.js → icons-material-D1JYmRTj.js} +1 -1
  25. package/adminWww/assets/{index-DA9Sphgh.js → index-DbiuoDjo.js} +2 -2
  26. package/adminWww/assets/{installSVGRenderer-DPdkRa_d.js → installSVGRenderer-BAY-Pzp-.js} +1 -1
  27. package/adminWww/assets/{mf-entry-bootstrap-0-a7ab91de.js → mf-entry-bootstrap-0-33384c20.js} +2 -2
  28. package/adminWww/index.html +24 -24
  29. package/adminWww/mf-manifest.json +1 -1
  30. package/adminWww/mf-stats.json +1 -1
  31. package/adminWww/remoteEntry-eos-9.0.20.js +12 -0
  32. package/adminWww/remoteEntry.js +1 -1
  33. package/build/lib/eosDeviceEmsPlan.js +18 -5
  34. package/build/lib/eosDeviceEmsPlan.js.map +1 -1
  35. package/build/lib/eosDeviceEmsService.js +52 -2
  36. package/build/lib/eosDeviceEmsService.js.map +1 -1
  37. package/build/lib/eosLegacyMigration.js +26 -1
  38. package/build/lib/eosLegacyMigration.js.map +1 -1
  39. package/build/lib/eosModuleHost.js +40 -0
  40. package/build/lib/eosModuleHost.js.map +1 -1
  41. package/build/lib/eosStateSubscriptions.js +59 -2
  42. package/build/lib/eosStateSubscriptions.js.map +1 -1
  43. package/build/lib/web.js +3 -0
  44. package/build/lib/web.js.map +1 -1
  45. package/docs/reports/unified-9.0.20/ANFORDERUNGEN_UND_INBETRIEBNAHME.md +159 -0
  46. package/docs/reports/unified-9.0.20/DEVICE_COMMAND_DELIVERY_REVIEW.md +82 -0
  47. package/docs/reports/unified-9.0.20/DEVICE_LIFECYCLE_REVIEW.md +46 -0
  48. package/docs/reports/unified-9.0.20/DEVICE_PLAN_REVIEW.md +33 -0
  49. package/docs/reports/unified-9.0.20/DEVICE_POWER_CAPABILITY_REVIEW.md +25 -0
  50. package/docs/reports/unified-9.0.20/FARM_CONTROLLER_REVIEW.md +27 -0
  51. package/docs/reports/unified-9.0.20/FARM_DIAGNOSE_UI.md +81 -0
  52. package/docs/reports/unified-9.0.20/FARM_DISPATCH_REVIEW.md +47 -0
  53. package/docs/reports/unified-9.0.20/HISTORY_REVIEW.md +68 -0
  54. package/docs/reports/unified-9.0.20/INFLUXDB2_INSTALLER_UI.md +39 -0
  55. package/docs/reports/unified-9.0.20/INFLUX_CREDENTIAL_NETWORK_REVIEW.md +38 -0
  56. package/docs/reports/unified-9.0.20/INFLUX_DIRECT_UNABHAENGIGE_PRUEFUNG.md +64 -0
  57. package/docs/reports/unified-9.0.20/INFLUX_RUNTIME_INTEGRATION_REVIEW.md +53 -0
  58. package/docs/reports/unified-9.0.20/INFLUX_RUNTIME_UNABHAENGIGE_PRUEFUNG.md +34 -0
  59. package/docs/reports/unified-9.0.20/INFLUX_TRANSPORT_ABSCHLUSSPRUEFUNG.md +55 -0
  60. package/docs/reports/unified-9.0.20/LOGIN_WEBAPP_LOGO.md +29 -0
  61. package/docs/reports/unified-9.0.20/MIGRATION_REVIEW.md +35 -0
  62. package/docs/reports/unified-9.0.20/PRUEFBERICHT.md +54 -0
  63. package/docs/reports/unified-9.0.20/PWA_ANONYMOUS_HTTPS_REVIEW.md +28 -0
  64. package/docs/reports/unified-9.0.20/PWA_ICON_UNABHAENGIGE_PRUEFUNG.md +60 -0
  65. package/docs/reports/unified-9.0.20/SERIAL_LIFECYCLE_REVIEW.md +37 -0
  66. package/docs/reports/unified-9.0.20/SOLAX_READBACK_REVIEW.md +43 -0
  67. package/docs/reports/unified-9.0.20/SOLAX_READBACK_UNABHAENGIGE_PRUEFUNG.md +34 -0
  68. package/docs/reports/unified-9.0.20/STATIC_REVIEW_DE.md +175 -0
  69. package/docs/reports/unified-9.0.20/STORAGE_COMMAND_ACK_REVIEW.md +36 -0
  70. package/docs/reports/unified-9.0.20/TARIFF_REPORT_REVIEW.md +29 -0
  71. package/docs/reports/unified-9.0.20/VISUALISIERUNG.md +64 -0
  72. package/docs/reports/unified-9.0.20/history-setup-navigation-proxy.txt +26 -0
  73. package/docs/reports/unified-9.0.20/history-setup-navigation-ssr.txt +7 -0
  74. package/docs/reports/unified-9.0.20/history-setup-ui-lint.txt +0 -0
  75. package/docs/reports/unified-9.0.20/history-setup-ui-node22.txt +102 -0
  76. package/docs/reports/unified-9.0.20/history-setup-ui-node24.txt +23 -0
  77. package/docs/reports/unified-9.0.20/history-setup-ui-security.txt +0 -0
  78. package/docs/reports/unified-9.0.20/history-setup-ui-typecheck.txt +0 -0
  79. package/docs/reports/unified-9.0.20/login-pwa-branding-hashes.txt +9 -0
  80. package/docs/reports/unified-9.0.20/login-pwa-branding-node22.txt +42 -0
  81. package/docs/reports/unified-9.0.20/login-pwa-branding-node24.txt +13 -0
  82. package/docs/reports/unified-9.0.20/raw/INDEX.json +1913 -0
  83. package/docs/reports/unified-9.0.20/raw/additional-audit/device/baseline-node22.log +16 -0
  84. package/docs/reports/unified-9.0.20/raw/additional-audit/device/baseline-node24.log +14 -0
  85. package/docs/reports/unified-9.0.20/raw/additional-audit/device/lint-after.json +1 -0
  86. package/docs/reports/unified-9.0.20/raw/additional-audit/device/lint-before.json +1 -0
  87. package/docs/reports/unified-9.0.20/raw/additional-audit/device/modbus-stop-backoff.cjs +22 -0
  88. package/docs/reports/unified-9.0.20/raw/additional-audit/device/node22-control-review.log +29 -0
  89. package/docs/reports/unified-9.0.20/raw/additional-audit/device/node22-modbus-final.json +18 -0
  90. package/docs/reports/unified-9.0.20/raw/additional-audit/device/node22-modbus-final.log +325 -0
  91. package/docs/reports/unified-9.0.20/raw/additional-audit/device/node22-modbus-review.log +278 -0
  92. package/docs/reports/unified-9.0.20/raw/additional-audit/device/node24-modbus-final.json +18 -0
  93. package/docs/reports/unified-9.0.20/raw/additional-audit/device/node24-modbus-final.log +58 -0
  94. package/docs/reports/unified-9.0.20/raw/additional-audit/device/node24-modbus-review.log +51 -0
  95. package/docs/reports/unified-9.0.20/raw/additional-audit/history/api-gaps-before.log +64 -0
  96. package/docs/reports/unified-9.0.20/raw/additional-audit/history/api-negative-before.log +46 -0
  97. package/docs/reports/unified-9.0.20/raw/additional-audit/history/chart-gaps-before.log +127 -0
  98. package/docs/reports/unified-9.0.20/raw/additional-audit/history/device-command-subscriptions-after.log +67 -0
  99. package/docs/reports/unified-9.0.20/raw/additional-audit/history/device-command-subscriptions-before.log +61 -0
  100. package/docs/reports/unified-9.0.20/raw/additional-audit/history/device-command-subscriptions-eslint-js.log +0 -0
  101. package/docs/reports/unified-9.0.20/raw/additional-audit/history/device-command-subscriptions-eslint-ts.log +0 -0
  102. package/docs/reports/unified-9.0.20/raw/additional-audit/history/device-command-subscriptions-node22.log +442 -0
  103. package/docs/reports/unified-9.0.20/raw/additional-audit/history/device-command-subscriptions-node24.log +78 -0
  104. package/docs/reports/unified-9.0.20/raw/additional-audit/history/fix.py +73 -0
  105. package/docs/reports/unified-9.0.20/raw/additional-audit/history/history-eslint-final.json +7 -0
  106. package/docs/reports/unified-9.0.20/raw/additional-audit/history/history-final-node22.log +279 -0
  107. package/docs/reports/unified-9.0.20/raw/additional-audit/history/history-final-node24.log +52 -0
  108. package/docs/reports/unified-9.0.20/raw/additional-audit/history/history-followup-node22.log +223 -0
  109. package/docs/reports/unified-9.0.20/raw/additional-audit/history/history-followup-node24.log +43 -0
  110. package/docs/reports/unified-9.0.20/raw/additional-audit/history/history-own-cache.log +17 -0
  111. package/docs/reports/unified-9.0.20/raw/additional-audit/history/negative-pricing-before.log +96 -0
  112. package/docs/reports/unified-9.0.20/raw/additional-audit/history/node22-after.log +66 -0
  113. package/docs/reports/unified-9.0.20/raw/additional-audit/history/node22-repro.log +8 -0
  114. package/docs/reports/unified-9.0.20/raw/additional-audit/history/node24-after.log +17 -0
  115. package/docs/reports/unified-9.0.20/raw/additional-audit/history/node24-repro.log +8 -0
  116. package/docs/reports/unified-9.0.20/raw/additional-audit/history/repro.cjs +39 -0
  117. package/docs/reports/unified-9.0.20/raw/additional-audit/visuals/chromium-probe.log +3 -0
  118. package/docs/reports/unified-9.0.20/raw/additional-audit/visuals/patch-live.py +101 -0
  119. package/docs/reports/unified-9.0.20/raw/additional-audit/visuals/repro-live-display.cjs +26 -0
  120. package/docs/reports/unified-9.0.20/raw/additional-audit/visuals/repro-live-display.log +36 -0
  121. package/docs/reports/unified-9.0.20/raw/audit-full.log +345 -0
  122. package/docs/reports/unified-9.0.20/raw/audit-full.result.json +14 -0
  123. package/docs/reports/unified-9.0.20/raw/audit-runtime.log +23 -0
  124. package/docs/reports/unified-9.0.20/raw/audit-runtime.result.json +15 -0
  125. package/docs/reports/unified-9.0.20/raw/backend-final.log +5 -0
  126. package/docs/reports/unified-9.0.20/raw/backend-final.result.json +14 -0
  127. package/docs/reports/unified-9.0.20/raw/baseline-919-coverage-tests-node22.result.json +20 -0
  128. package/docs/reports/unified-9.0.20/raw/baseline-919-coverage-tests-node22.tap +721 -0
  129. package/docs/reports/unified-9.0.20/raw/baseline-919-coverage-tests-node24.result.json +20 -0
  130. package/docs/reports/unified-9.0.20/raw/baseline-919-coverage-tests-node24.tap +127 -0
  131. package/docs/reports/unified-9.0.20/raw/commissioning-evidence.json +69 -0
  132. package/docs/reports/unified-9.0.20/raw/commissioning-failed-init-drain-919-before.log +14 -0
  133. package/docs/reports/unified-9.0.20/raw/commissioning-final-node22.log +882 -0
  134. package/docs/reports/unified-9.0.20/raw/commissioning-final-node24.log +149 -0
  135. package/docs/reports/unified-9.0.20/raw/commissioning-lint.log +0 -0
  136. package/docs/reports/unified-9.0.20/raw/commissioning-planner-919-before.log +70 -0
  137. package/docs/reports/unified-9.0.20/raw/commissioning-retained-readiness-before.log +34 -0
  138. package/docs/reports/unified-9.0.20/raw/commissioning-runtime-retry-919-before.log +46 -0
  139. package/docs/reports/unified-9.0.20/raw/commissioning-types-node24.log +0 -0
  140. package/docs/reports/unified-9.0.20/raw/device-farm-protocol/DEVICE_FARM_READONLY_REVIEW.md +66 -0
  141. package/docs/reports/unified-9.0.20/raw/device-farm-protocol/run-readback-tests.cjs +13 -0
  142. package/docs/reports/unified-9.0.20/raw/device-farm-protocol/solax-control-chain.test.cjs +58 -0
  143. package/docs/reports/unified-9.0.20/raw/device-lifecycle-baseline-node22.log +16 -0
  144. package/docs/reports/unified-9.0.20/raw/device-lifecycle-baseline-node24.log +14 -0
  145. package/docs/reports/unified-9.0.20/raw/device-lifecycle-evidence.json +55 -0
  146. package/docs/reports/unified-9.0.20/raw/device-lifecycle-lint-after.json +1 -0
  147. package/docs/reports/unified-9.0.20/raw/device-lifecycle-lint-before.json +1 -0
  148. package/docs/reports/unified-9.0.20/raw/device-lifecycle-modbus-stop-backoff.cjs +22 -0
  149. package/docs/reports/unified-9.0.20/raw/device-lifecycle-node22-control-review.log +29 -0
  150. package/docs/reports/unified-9.0.20/raw/device-lifecycle-node22-modbus-final.json +18 -0
  151. package/docs/reports/unified-9.0.20/raw/device-lifecycle-node22-modbus-final.log +325 -0
  152. package/docs/reports/unified-9.0.20/raw/device-lifecycle-node22-modbus-review.log +278 -0
  153. package/docs/reports/unified-9.0.20/raw/device-lifecycle-node24-modbus-final.json +18 -0
  154. package/docs/reports/unified-9.0.20/raw/device-lifecycle-node24-modbus-final.log +58 -0
  155. package/docs/reports/unified-9.0.20/raw/device-lifecycle-node24-modbus-review.log +51 -0
  156. package/docs/reports/unified-9.0.20/raw/devices-hosted-typecheck-node22.log +0 -0
  157. package/docs/reports/unified-9.0.20/raw/devices-hosted-typecheck-node22.result.json +15 -0
  158. package/docs/reports/unified-9.0.20/raw/devices-hosted-typecheck-node24.log +0 -0
  159. package/docs/reports/unified-9.0.20/raw/devices-hosted-typecheck-node24.result.json +15 -0
  160. package/docs/reports/unified-9.0.20/raw/farm-controller/controller-node22.log +110 -0
  161. package/docs/reports/unified-9.0.20/raw/farm-controller/controller-node24.log +24 -0
  162. package/docs/reports/unified-9.0.20/raw/farm-controller/evidence.json +33 -0
  163. package/docs/reports/unified-9.0.20/raw/farm-diagnostics-ui-lint.txt +0 -0
  164. package/docs/reports/unified-9.0.20/raw/farm-diagnostics-ui-node22.txt +113 -0
  165. package/docs/reports/unified-9.0.20/raw/farm-diagnostics-ui-node24.txt +26 -0
  166. package/docs/reports/unified-9.0.20/raw/farm-diagnostics-ui-security.txt +0 -0
  167. package/docs/reports/unified-9.0.20/raw/farm-diagnostics-ui-typecheck.txt +0 -0
  168. package/docs/reports/unified-9.0.20/raw/farm-dispatch/allocator-baseline.jsonl +6 -0
  169. package/docs/reports/unified-9.0.20/raw/farm-dispatch/diagnostics-before.log +138 -0
  170. package/docs/reports/unified-9.0.20/raw/farm-dispatch/diagnostics-main-delta.patch +77 -0
  171. package/docs/reports/unified-9.0.20/raw/farm-dispatch/diagnostics-main-lint.json +7 -0
  172. package/docs/reports/unified-9.0.20/raw/farm-dispatch/diagnostics-node22.log +64 -0
  173. package/docs/reports/unified-9.0.20/raw/farm-dispatch/diagnostics-node22.result.json +14 -0
  174. package/docs/reports/unified-9.0.20/raw/farm-dispatch/diagnostics-node24.log +18 -0
  175. package/docs/reports/unified-9.0.20/raw/farm-dispatch/diagnostics-node24.result.json +14 -0
  176. package/docs/reports/unified-9.0.20/raw/final-ui-independent-review.json +194 -0
  177. package/docs/reports/unified-9.0.20/raw/frontend-build.log +152 -0
  178. package/docs/reports/unified-9.0.20/raw/frontend-build.result.json +14 -0
  179. package/docs/reports/unified-9.0.20/raw/independent-influx/parser-after-node22.json +35 -0
  180. package/docs/reports/unified-9.0.20/raw/independent-influx/parser-after-node22.result.json +17 -0
  181. package/docs/reports/unified-9.0.20/raw/independent-influx/parser-after-node24.json +31 -0
  182. package/docs/reports/unified-9.0.20/raw/independent-influx/parser-after-node24.result.json +17 -0
  183. package/docs/reports/unified-9.0.20/raw/independent-influx/parser-before.json +31 -0
  184. package/docs/reports/unified-9.0.20/raw/independent-influx/parser-reproducer.cjs +9 -0
  185. package/docs/reports/unified-9.0.20/raw/independent-influx/transport-extra-node22.result.json +18 -0
  186. package/docs/reports/unified-9.0.20/raw/independent-influx/transport-extra-node22.tap +34 -0
  187. package/docs/reports/unified-9.0.20/raw/independent-influx/transport-extra-node24.result.json +18 -0
  188. package/docs/reports/unified-9.0.20/raw/independent-influx/transport-extra-node24.tap +11 -0
  189. package/docs/reports/unified-9.0.20/raw/independent-influx/transport-extra.test.cjs +9 -0
  190. package/docs/reports/unified-9.0.20/raw/independent-solax/node22-focused.log +165 -0
  191. package/docs/reports/unified-9.0.20/raw/independent-solax/node24-focused.log +35 -0
  192. package/docs/reports/unified-9.0.20/raw/independent-solax/review-receipt.json +57 -0
  193. package/docs/reports/unified-9.0.20/raw/independent-solax/split-response-after.log +1 -0
  194. package/docs/reports/unified-9.0.20/raw/independent-solax/split-response-before.log +1 -0
  195. package/docs/reports/unified-9.0.20/raw/independent-solax/split-response.cjs +16 -0
  196. package/docs/reports/unified-9.0.20/raw/independent-solax/stop-race-generation-guard.log +1 -0
  197. package/docs/reports/unified-9.0.20/raw/independent-solax/stop-race.cjs +13 -0
  198. package/docs/reports/unified-9.0.20/raw/influx-direct/eslint.log +0 -0
  199. package/docs/reports/unified-9.0.20/raw/influx-direct/node22.log +112 -0
  200. package/docs/reports/unified-9.0.20/raw/influx-direct/node24.log +24 -0
  201. package/docs/reports/unified-9.0.20/raw/influx-direct/typecheck.log +0 -0
  202. package/docs/reports/unified-9.0.20/raw/influx-direct-review/hosted-module-history.test.cjs +85 -0
  203. package/docs/reports/unified-9.0.20/raw/influx-direct-review/independent-node22.json +12 -0
  204. package/docs/reports/unified-9.0.20/raw/influx-direct-review/independent-node22.log +100 -0
  205. package/docs/reports/unified-9.0.20/raw/influx-direct-review/independent-node24.json +12 -0
  206. package/docs/reports/unified-9.0.20/raw/influx-direct-review/independent-node24.log +21 -0
  207. package/docs/reports/unified-9.0.20/raw/influx-direct-review/runtime-after.test.cjs +15 -0
  208. package/docs/reports/unified-9.0.20/raw/influx-direct-review/runtime-loss-before.test.cjs +9 -0
  209. package/docs/reports/unified-9.0.20/raw/influx-direct-review/security-scan.cjs +15 -0
  210. package/docs/reports/unified-9.0.20/raw/influx-direct-review/transport-extra.test.cjs +9 -0
  211. package/docs/reports/unified-9.0.20/raw/influx-independent/legacy-history-node22.log +227 -0
  212. package/docs/reports/unified-9.0.20/raw/influx-independent/legacy-history-node22.result.json +11 -0
  213. package/docs/reports/unified-9.0.20/raw/influx-independent/legacy-history-node24.log +44 -0
  214. package/docs/reports/unified-9.0.20/raw/influx-independent/legacy-history-node24.result.json +11 -0
  215. package/docs/reports/unified-9.0.20/raw/influx-independent/node22.log +112 -0
  216. package/docs/reports/unified-9.0.20/raw/influx-independent/node22.result.json +12 -0
  217. package/docs/reports/unified-9.0.20/raw/influx-independent/node24.log +23 -0
  218. package/docs/reports/unified-9.0.20/raw/influx-independent/node24.result.json +12 -0
  219. package/docs/reports/unified-9.0.20/raw/influx-independent/runtime-after.test.cjs +15 -0
  220. package/docs/reports/unified-9.0.20/raw/influx-independent/transport-extra.test.cjs +9 -0
  221. package/docs/reports/unified-9.0.20/raw/influx-runtime/evidence.json +24 -0
  222. package/docs/reports/unified-9.0.20/raw/influx-runtime/final-node22.log +326 -0
  223. package/docs/reports/unified-9.0.20/raw/influx-runtime/final-node24.log +59 -0
  224. package/docs/reports/unified-9.0.20/raw/influx-runtime/runtime-node22.log +62 -0
  225. package/docs/reports/unified-9.0.20/raw/influx-runtime/runtime-node24.log +16 -0
  226. package/docs/reports/unified-9.0.20/raw/influx-security/security-influx-lint.log +0 -0
  227. package/docs/reports/unified-9.0.20/raw/influx-security/security-influx-lint.result.json +17 -0
  228. package/docs/reports/unified-9.0.20/raw/influx-security/security-influx-node22.log +112 -0
  229. package/docs/reports/unified-9.0.20/raw/influx-security/security-influx-node22.result.json +15 -0
  230. package/docs/reports/unified-9.0.20/raw/influx-security/security-influx-node24.log +106 -0
  231. package/docs/reports/unified-9.0.20/raw/influx-security/security-influx-node24.result.json +15 -0
  232. package/docs/reports/unified-9.0.20/raw/influx-security/security-influx-typecheck.log +0 -0
  233. package/docs/reports/unified-9.0.20/raw/influx-security/security-influx-typecheck.result.json +15 -0
  234. package/docs/reports/unified-9.0.20/raw/influx-security/source-sha256.json +5 -0
  235. package/docs/reports/unified-9.0.20/raw/influx-transport-final/influx-transport-lint-final.log +0 -0
  236. package/docs/reports/unified-9.0.20/raw/influx-transport-final/influx-transport-lint-final.result.json +16 -0
  237. package/docs/reports/unified-9.0.20/raw/influx-transport-final/influx-transport-node22-final.log +124 -0
  238. package/docs/reports/unified-9.0.20/raw/influx-transport-final/influx-transport-node22-final.result.json +14 -0
  239. package/docs/reports/unified-9.0.20/raw/influx-transport-final/influx-transport-node24-final.log +26 -0
  240. package/docs/reports/unified-9.0.20/raw/influx-transport-final/influx-transport-node24-final.result.json +14 -0
  241. package/docs/reports/unified-9.0.20/raw/influx-transport-final/influx-transport-type-node22-final.log +0 -0
  242. package/docs/reports/unified-9.0.20/raw/influx-transport-final/influx-transport-type-node22-final.result.json +15 -0
  243. package/docs/reports/unified-9.0.20/raw/influx-transport-final/influx-transport-type-node24-final.log +0 -0
  244. package/docs/reports/unified-9.0.20/raw/influx-transport-final/influx-transport-type-node24-final.result.json +15 -0
  245. package/docs/reports/unified-9.0.20/raw/influx-ui-independent-review-final.json +285 -0
  246. package/docs/reports/unified-9.0.20/raw/influx-ui-independent-review-intermediate.json +285 -0
  247. package/docs/reports/unified-9.0.20/raw/installer-build.log +26 -0
  248. package/docs/reports/unified-9.0.20/raw/installer-build.result.json +14 -0
  249. package/docs/reports/unified-9.0.20/raw/isolation/INDEX.json +332 -0
  250. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-family-final.log +3 -0
  251. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-family-final.result.json +13 -0
  252. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-family-hosted.log +6 -0
  253. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-family-hosted.result.json +13 -0
  254. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-family-verified.log +1 -0
  255. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-family-verified.result.json +13 -0
  256. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-family.log +11 -0
  257. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-family.result.json +13 -0
  258. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-fenecon-hybrid-final.log +3 -0
  259. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-fenecon-hybrid-final.result.json +13 -0
  260. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-fenecon-hybrid-hosted.log +3 -0
  261. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-fenecon-hybrid-hosted.result.json +13 -0
  262. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-fenecon-hybrid-verified.log +1 -0
  263. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-fenecon-hybrid-verified.result.json +13 -0
  264. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-fenecon-hybrid.log +11 -0
  265. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-fenecon-hybrid.result.json +13 -0
  266. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-final-node22.log +296 -0
  267. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-final-node22.result.json +16 -0
  268. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-final-node24.log +56 -0
  269. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-final-node24.result.json +16 -0
  270. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-node24.log +54 -0
  271. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-node24.result.json +16 -0
  272. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-output-modes.log +1 -0
  273. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-output-modes.result.json +13 -0
  274. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-release-final-node22.log +332 -0
  275. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-release-final-node22.result.json +16 -0
  276. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-release-final-node24.log +62 -0
  277. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-release-final-node24.result.json +16 -0
  278. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-release-node22.log +342 -0
  279. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-release-node22.result.json +16 -0
  280. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-release-node24.log +72 -0
  281. package/docs/reports/unified-9.0.20/raw/isolation/command-ack-release-node24.result.json +16 -0
  282. package/docs/reports/unified-9.0.20/raw/isolation/isolation-node22.log +482 -0
  283. package/docs/reports/unified-9.0.20/raw/isolation/isolation-node22.result.json +19 -0
  284. package/docs/reports/unified-9.0.20/raw/isolation/isolation-node24.log +87 -0
  285. package/docs/reports/unified-9.0.20/raw/isolation/migration-lint.log +0 -0
  286. package/docs/reports/unified-9.0.20/raw/isolation/migration-lint.result.json +16 -0
  287. package/docs/reports/unified-9.0.20/raw/isolation/migration-node22.log +330 -0
  288. package/docs/reports/unified-9.0.20/raw/isolation/migration-node22.result.json +16 -0
  289. package/docs/reports/unified-9.0.20/raw/isolation/migration-node24-before.log +72 -0
  290. package/docs/reports/unified-9.0.20/raw/isolation/migration-node24-before.result.json +16 -0
  291. package/docs/reports/unified-9.0.20/raw/isolation/migration-node24.log +60 -0
  292. package/docs/reports/unified-9.0.20/raw/isolation/migration-node24.result.json +16 -0
  293. package/docs/reports/unified-9.0.20/raw/isolation/repro-migration-start-budget.cjs +49 -0
  294. package/docs/reports/unified-9.0.20/raw/isolation/repro-serial-release.cjs +21 -0
  295. package/docs/reports/unified-9.0.20/raw/isolation/repro-sunspec-discovery.cjs +11 -0
  296. package/docs/reports/unified-9.0.20/raw/isolation/serial-before-repro.log +1 -0
  297. package/docs/reports/unified-9.0.20/raw/isolation/serial-before-repro.result.json +13 -0
  298. package/docs/reports/unified-9.0.20/raw/isolation/serial-gates-node22.log +32 -0
  299. package/docs/reports/unified-9.0.20/raw/isolation/serial-gates-node22.result.json +14 -0
  300. package/docs/reports/unified-9.0.20/raw/isolation/serial-gates-node24.log +11 -0
  301. package/docs/reports/unified-9.0.20/raw/isolation/serial-gates-node24.result.json +14 -0
  302. package/docs/reports/unified-9.0.20/raw/isolation/serial-helper-typecheck-final.log +0 -0
  303. package/docs/reports/unified-9.0.20/raw/isolation/serial-helper-typecheck-final.result.json +28 -0
  304. package/docs/reports/unified-9.0.20/raw/isolation/serial-helper-typecheck.log +2 -0
  305. package/docs/reports/unified-9.0.20/raw/isolation/serial-helper-typecheck.result.json +26 -0
  306. package/docs/reports/unified-9.0.20/raw/isolation/serial-lint.log +0 -0
  307. package/docs/reports/unified-9.0.20/raw/isolation/serial-lint.result.json +18 -0
  308. package/docs/reports/unified-9.0.20/raw/isolation/serial-node22.log +344 -0
  309. package/docs/reports/unified-9.0.20/raw/isolation/serial-node22.result.json +17 -0
  310. package/docs/reports/unified-9.0.20/raw/isolation/serial-node24.log +62 -0
  311. package/docs/reports/unified-9.0.20/raw/isolation/serial-node24.result.json +17 -0
  312. package/docs/reports/unified-9.0.20/raw/isolation/sunspec-review-after.log +3 -0
  313. package/docs/reports/unified-9.0.20/raw/isolation/sunspec-review-after.result.json +13 -0
  314. package/docs/reports/unified-9.0.20/raw/isolation/sunspec-review-before.log +3 -0
  315. package/docs/reports/unified-9.0.20/raw/isolation/sunspec-review-before.result.json +15 -0
  316. package/docs/reports/unified-9.0.20/raw/keygen-source.json +6 -0
  317. package/docs/reports/unified-9.0.20/raw/legacy-mirror-debt/check-919.log +70 -0
  318. package/docs/reports/unified-9.0.20/raw/legacy-mirror-debt/check-920.log +71 -0
  319. package/docs/reports/unified-9.0.20/raw/legacy-mirror-debt/diff.json +82 -0
  320. package/docs/reports/unified-9.0.20/raw/legacy-mirror-debt/receipt.json +48 -0
  321. package/docs/reports/unified-9.0.20/raw/lint-final.log +16 -0
  322. package/docs/reports/unified-9.0.20/raw/lint-final.result.json +14 -0
  323. package/docs/reports/unified-9.0.20/raw/main-individual-review-before-cache-boundary-fix.json +112 -0
  324. package/docs/reports/unified-9.0.20/raw/main-individual-review-before-capability-ack.json +103 -0
  325. package/docs/reports/unified-9.0.20/raw/main-individual-review-before-farm-diagnostics.json +102 -0
  326. package/docs/reports/unified-9.0.20/raw/main-individual-review-final.json +103 -0
  327. package/docs/reports/unified-9.0.20/raw/main-individual-review.json +93 -0
  328. package/docs/reports/unified-9.0.20/raw/modules-build.log +5 -0
  329. package/docs/reports/unified-9.0.20/raw/modules-build.result.json +14 -0
  330. package/docs/reports/unified-9.0.20/raw/node22-tests-final.log +12471 -0
  331. package/docs/reports/unified-9.0.20/raw/node22-tests-final.result.json +13 -0
  332. package/docs/reports/unified-9.0.20/raw/node22-typecheck-final.log +7 -0
  333. package/docs/reports/unified-9.0.20/raw/node22-typecheck-final.result.json +14 -0
  334. package/docs/reports/unified-9.0.20/raw/node22-version.log +1 -0
  335. package/docs/reports/unified-9.0.20/raw/node24-tests-final.log +2093 -0
  336. package/docs/reports/unified-9.0.20/raw/node24-tests-final.result.json +13 -0
  337. package/docs/reports/unified-9.0.20/raw/node24-typecheck-final.log +5 -0
  338. package/docs/reports/unified-9.0.20/raw/node24-typecheck-final.result.json +14 -0
  339. package/docs/reports/unified-9.0.20/raw/node24-version.log +1 -0
  340. package/docs/reports/unified-9.0.20/raw/power-capability/evidence.json +69 -0
  341. package/docs/reports/unified-9.0.20/raw/power-capability/power-capability-existing-regressions-node24.log +94 -0
  342. package/docs/reports/unified-9.0.20/raw/power-capability/power-capability-lint.log +0 -0
  343. package/docs/reports/unified-9.0.20/raw/power-capability/power-capability-node22.log +304 -0
  344. package/docs/reports/unified-9.0.20/raw/power-capability/power-capability-node24.log +56 -0
  345. package/docs/reports/unified-9.0.20/raw/power-capability/power-capability-typecheck.log +0 -0
  346. package/docs/reports/unified-9.0.20/raw/pwa-https/evidence.json +45 -0
  347. package/docs/reports/unified-9.0.20/raw/pwa-https/node22-build.log +21 -0
  348. package/docs/reports/unified-9.0.20/raw/pwa-https/node22-source.log +23 -0
  349. package/docs/reports/unified-9.0.20/raw/pwa-https/node24-build.log +11 -0
  350. package/docs/reports/unified-9.0.20/raw/pwa-https/node24-source.log +11 -0
  351. package/docs/reports/unified-9.0.20/raw/pwa-independent/policy-boundaries.test.cjs +45 -0
  352. package/docs/reports/unified-9.0.20/raw/pwa-independent/policy-receipt.json +71 -0
  353. package/docs/reports/unified-9.0.20/raw/pwa-independent/policy-v22.23.4.tap +34 -0
  354. package/docs/reports/unified-9.0.20/raw/pwa-independent/policy-v24.22.3.tap +11 -0
  355. package/docs/reports/unified-9.0.20/raw/pwa-ui-independent-review-final.json +348 -0
  356. package/docs/reports/unified-9.0.20/raw/repro-failed-init-drain-before.cjs +15 -0
  357. package/docs/reports/unified-9.0.20/raw/repro-profile-replacement-after-unmapped.cjs +15 -0
  358. package/docs/reports/unified-9.0.20/raw/repro-runtime-retry-before.cjs +18 -0
  359. package/docs/reports/unified-9.0.20/raw/sbom-runtime.log +7 -0
  360. package/docs/reports/unified-9.0.20/raw/sbom-runtime.result.json +14 -0
  361. package/docs/reports/unified-9.0.20/raw/sbom-vendor-check.log +1 -0
  362. package/docs/reports/unified-9.0.20/raw/sbom-vendor-check.result.json +14 -0
  363. package/docs/reports/unified-9.0.20/raw/solax-readback-node22.json +30 -0
  364. package/docs/reports/unified-9.0.20/raw/solax-readback-node22.log +542 -0
  365. package/docs/reports/unified-9.0.20/raw/solax-readback-node24.json +30 -0
  366. package/docs/reports/unified-9.0.20/raw/solax-readback-node24.log +97 -0
  367. package/docs/reports/unified-9.0.20/raw/tariff-report-before.log +147 -0
  368. package/docs/reports/unified-9.0.20/raw/tariff-report-evidence.json +48 -0
  369. package/docs/reports/unified-9.0.20/raw/tariff-report-final-node22.log +151 -0
  370. package/docs/reports/unified-9.0.20/raw/tariff-report-final-node24.log +32 -0
  371. package/docs/reports/unified-9.0.20/raw/ui-docs-check.log +6 -0
  372. package/docs/reports/unified-9.0.20/raw/ui-docs-check.result.json +14 -0
  373. package/docs/reports/unified-9.0.20/raw/ui-runtime-final.log +7 -0
  374. package/docs/reports/unified-9.0.20/raw/ui-runtime-final.result.json +14 -0
  375. package/docs/reports/unified-9.0.20/raw/ui-runtime-sync.log +6 -0
  376. package/docs/reports/unified-9.0.20/raw/ui-runtime-sync.result.json +14 -0
  377. package/docs/reports/unified-9.0.20/raw/ui-sbom-check.log +6 -0
  378. package/docs/reports/unified-9.0.20/raw/ui-sbom-check.result.json +14 -0
  379. package/docs/reports/unified-9.0.20/raw/ui-sbom-final.log +6 -0
  380. package/docs/reports/unified-9.0.20/raw/ui-sbom-final.result.json +14 -0
  381. package/docs/reports/unified-9.0.20/raw/ui-secret-final.log +6 -0
  382. package/docs/reports/unified-9.0.20/raw/ui-secret-final.result.json +14 -0
  383. package/docs/reports/unified-9.0.20/raw/ui-security-final.log +8 -0
  384. package/docs/reports/unified-9.0.20/raw/ui-security-final.result.json +14 -0
  385. package/docs/reports/unified-9.0.20/raw/visuals-baseline-919.txt +36 -0
  386. package/docs/reports/unified-9.0.20/raw/visuals-browser-limit.txt +3 -0
  387. package/docs/reports/unified-9.0.20/raw/visuals-lint.txt +0 -0
  388. package/docs/reports/unified-9.0.20/raw/visuals-node22.txt +258 -0
  389. package/docs/reports/unified-9.0.20/raw/visuals-node24.txt +51 -0
  390. package/docs/reports/unified-9.0.20/raw/visuals-security.txt +0 -0
  391. package/docs/reports/unified-9.0.20/raw/visuals-typecheck.txt +0 -0
  392. package/docs/reports/unified-9.0.20/raw/wallet-freshness-after.log +19 -0
  393. package/docs/reports/unified-9.0.20/raw/wallet-freshness-after.result.json +16 -0
  394. package/docs/reports/unified-9.0.20/raw/wallet-freshness-before.log +31 -0
  395. package/docs/reports/unified-9.0.20/raw/wallet-freshness-before.result.json +14 -0
  396. package/docs/reports/unified-9.0.20/raw/wallet-freshness-independent.result.json +13 -0
  397. package/docs/reports/unified-9.0.20/raw/wallet-freshness-independent.tap +10 -0
  398. package/io-package.json +8 -8
  399. package/modules/devices/lib/device-alias-semantics-v1.json +22 -1
  400. package/modules/devices/lib/deviceAliasFreshness.js +1 -0
  401. package/modules/devices/lib/deviceAliasSemantics.js +13 -3
  402. package/modules/devices/lib/deviceRuntime.js +79 -8
  403. package/modules/devices/lib/drivers/modbus.js +90 -21
  404. package/modules/devices/lib/drivers/modbusAsciiBus.js +47 -31
  405. package/modules/devices/lib/drivers/modbusRtuBus.js +33 -9
  406. package/modules/devices/lib/drivers/modbusSerialLease.js +29 -0
  407. package/modules/devices/lib/modbusReadEvidence.js +29 -0
  408. package/modules/devices/test/deviceAliasFreshness.test.js +7 -2
  409. package/modules/devices/test/modbusConnectLifecycle.test.js +148 -0
  410. package/modules/devices/test/modbusSerialLifecycle.test.js +91 -0
  411. package/modules/devices/test/serialOperationGate.test.js +3 -3
  412. package/modules/devices/test/solaxReadbackContext.test.js +472 -0
  413. package/modules/devices/tsconfig.alias-semantics.json +1 -1
  414. package/modules/devices/tsconfig.serial-lifecycle.json +18 -0
  415. package/package.json +9 -7
  416. package/release-manifests/unified/build-environment.cdx.json +6 -6
  417. package/release-manifests/unified/files.json +551 -140
  418. package/release-manifests/unified/obsolete-admin-assets.json +88 -6
  419. package/release-manifests/unified/runtime.cdx.json +23 -23
  420. package/release-manifests/unified/validation.json +15 -15
  421. package/tools/eos-release-check.cjs +2 -2
  422. package/tools/eos-release-manifest.cjs +3 -3
  423. package/ui/admin/react/assets/index-BJO3q7oe.js +13 -0
  424. package/ui/admin/react/assets/{index-CuquHlsY.css → index-ofLP_Y7y.css} +1 -1
  425. package/ui/admin/react/index.html +2 -2
  426. package/ui/docs/security/eslint-reviewed-findings.json +26 -26
  427. package/ui/ems/modules/energy-wallet.js +9 -3
  428. package/ui/ems/modules/storage-control.js +60 -19
  429. package/ui/io-package.json +1 -1
  430. package/ui/lib/influx-config.js +204 -0
  431. package/ui/lib/influx-direct.js +527 -0
  432. package/ui/lib/influx-history-runtime.js +326 -0
  433. package/ui/lib/influx-network-policy.js +112 -0
  434. package/ui/lib/ui-access-policy.js +2 -2
  435. package/ui/main.js +550 -222
  436. package/ui/package.json +12 -6
  437. package/ui/www/app.js +150 -202
  438. package/ui/www/ems-apps.html +2 -1
  439. package/ui/www/ems-apps.js +8 -1
  440. package/ui/www/energy-ledger.html +1 -1
  441. package/ui/www/evcs.html +1 -1
  442. package/ui/www/history.html +1 -1
  443. package/ui/www/history.js +114 -74
  444. package/ui/www/index.html +2 -1
  445. package/ui/www/live-display.js +115 -0
  446. package/ui/www/logic.html +1 -1
  447. package/ui/www/login.css +1 -0
  448. package/ui/www/login.html +2 -1
  449. package/ui/www/manifest.webmanifest +2 -2
  450. package/ui/www/settings.html +2 -1
  451. package/ui/www/simulation.html +1 -1
  452. package/ui/www/smarthome-config.html +1 -1
  453. package/ui/www/smarthome.html +1 -1
  454. package/ui/www/storagefarm-dispatch.js +287 -0
  455. package/ui/www/storagefarm-summary.css +15 -0
  456. package/ui/www/storagefarm.html +15 -1
  457. package/ui/www/storagefarm.js +8 -26
  458. package/ui/www/tariff-report.js +43 -25
  459. package/adminWww/remoteEntry-eos-9.0.19.js +0 -12
  460. package/ui/admin/react/assets/index-Bq5IupDw.js +0 -13
package/ui/main.js CHANGED
@@ -7,7 +7,7 @@
7
7
  * AUTO-GENERATED RUNTIME FILE - NICHT MANUELL BEARBEITEN.
8
8
  *
9
9
  * Quelle: src-ts/runtime-executables/main.ts
10
- * Quell-Hash: sha256:29a6433294bddf757bdbe2e7ffba84bffe0fc70f2e3fbdbd63c6ea2e9dce4a16
10
+ * Quell-Hash: sha256:11f2616a2f7f2e5066c180db4316c7f0b219b066790e7c4563dab3e1104d3d96
11
11
  * Erzeugung: npm run sync:ts-runtime-executables
12
12
  *
13
13
  * Zweck:
@@ -54,10 +54,13 @@ const os = require('os');
54
54
  // JSON bleibt unkomprimiert: inflate:false verhindert Dekompressionsfehler auch mit älteren ioBroker-Abhängigkeitsbäumen.
55
55
  const bodyParser = express.json({ limit: '5mb', inflate: false });
56
56
  const crypto = require('crypto');
57
- const { installerRevision, assertInstallerRevision, provisionInstallerObjects, assertDeviceAppActivations, numericMeasurement, activeDeviceProfileReferences } = require('./lib/installer-lifecycle');
57
+ const { installerRevision, assertInstallerRevision, provisionInstallerObjects, assertDeviceAppActivations, numericMeasurement, activeDeviceProfileReferences, awaitEmsTransition } = require('./lib/installer-lifecycle');
58
58
  const { buildFarmOverview } = require('./lib/storage-farm-overview');
59
- const { tariffDisplayConfig } = require('./lib/tariff-price');
59
+ const { tariffDisplayConfig, tariffPriceNumber } = require('./lib/tariff-price');
60
60
  const { customerTariffView, prepareCustomerTariffChange } = require('./lib/customer-tariff');
61
+ const { InfluxDirectClient } = require('./lib/influx-direct');
62
+ const { InfluxHistoryRuntime } = require('./lib/influx-history-runtime');
63
+ const { prepareInfluxHistoryChange, protectInfluxHistoryConfig, restoreInfluxHistoryConfig, redactInfluxHistoryConfig } = require('./lib/influx-config');
61
64
  const https = require('https');
62
65
  const pkg = require('./package.json');
63
66
  const { defaultEnergyOriginConfig, registerEnergyOriginApi } = require('./lib/energy-origin-api');
@@ -391,6 +394,16 @@ class NexoWattVis extends HostedAdapter {
391
394
  // responsive and avoids unnecessary InfluxDB round-trips.
392
395
  this._nwHistoryApiCache = new EphemeralMap(5000, 4);
393
396
  this._nwHistoryApiInflight = new Map();
397
+ this._nwDirectHistory = new InfluxHistoryRuntime(this.namespace);
398
+ // Only fulfilled ioBroker writes may enter the historian. Capture the event's
399
+ // timestamp before awaiting persistence; never await network I/O in an EMS tick.
400
+ const writeHistoryState = this.setStateAsync.bind(this);
401
+ this.setStateAsync = async (...args) => {
402
+ const captured = this._nwDirectHistory.capture(args[0], args[1], args[2]);
403
+ const result = await writeHistoryState(...args);
404
+ if (!isActuatorAuthorityBlockedResult(result)) this._nwDirectHistory.commit(captured);
405
+ return result;
406
+ };
394
407
  this._nwShcfgDetectCache = new EphemeralMap(30000, 1);
395
408
  this._nwTypeDetectorObjectsCache = null;
396
409
 
@@ -3355,6 +3368,7 @@ class NexoWattVis extends HostedAdapter {
3355
3368
  'settingsConfig',
3356
3369
  'datapoints',
3357
3370
  'installerConfig',
3371
+ 'history',
3358
3372
  'eosDeviceEms', // Server-owned commissioning identities survive updates and app changes.
3359
3373
  'countryProfile',
3360
3374
  'emsApps',
@@ -4700,7 +4714,7 @@ class NexoWattVis extends HostedAdapter {
4700
4714
  this._partnerRuntime = new PartnerRuntime({
4701
4715
  getRoot: () => this.config || {},
4702
4716
  isAppActive: (appId) => this._nwPartnerAppActive(appId),
4703
- controlAvailable: () => !!this.emsEngine && this._nwPartnerAppActive('arbitrage'),
4717
+ controlAvailable: () => this._nwIsEmsReady() && this._nwPartnerAppActive('arbitrage'),
4704
4718
  isResourceAvailable: (resourceId) => {
4705
4719
  const availability = this._nwPartnerResourceAvailability?.[resourceId];
4706
4720
  const now = Date.now();
@@ -4774,6 +4788,7 @@ class NexoWattVis extends HostedAdapter {
4774
4788
 
4775
4789
  // Neue Laufzeitfelder werden ausschließlich im Speicher ergänzt. Ein normales
4776
4790
  // Update/Neustart schreibt keine normalisierte Fassung über vorhandene Kundendaten.
4791
+ patch = restoreInfluxHistoryConfig(patch, this._nwHistorySecretCodec());
4777
4792
  const norm = this.nwNormalizeInstallerPatch(patch, baseNative);
4778
4793
  patch = norm.patch;
4779
4794
 
@@ -4784,6 +4799,7 @@ class NexoWattVis extends HostedAdapter {
4784
4799
 
4785
4800
  // Apply patch as installer SoT (replace installer-managed sections)
4786
4801
  this.config = this.nwApplyInstallerPatchToRuntimeConfig(baseNative, patch);
4802
+ this._nwConfigureHistory();
4787
4803
  try { await this._nwValidateNvpTopology(); }
4788
4804
  catch (_nvpError) { this._nwNvpTopologyValidation = { configFingerprint: JSON.stringify(this.config.nvpTopology), validation: { valid: false, errors: [{ code: 'NVP_SOURCE_VALIDATION_FAILED', message: 'NVP-Quellenprüfung fehlgeschlagen.' }] } }; }
4789
4805
 
@@ -4869,6 +4885,7 @@ class NexoWattVis extends HostedAdapter {
4869
4885
  }
4870
4886
 
4871
4887
  async _nwApplyInstallerRuntime(restartEms, reason) {
4888
+ this._nwConfigureHistory();
4872
4889
  const currentTariffModule = this.emsEngine?.mm?.modules?.find(entry => entry.key === 'tariffProvider')?.instance;
4873
4890
  if (currentTariffModule && typeof currentTariffModule.invalidateConfiguration === 'function') await currentTariffModule.invalidateConfiguration();
4874
4891
  if (currentTariffModule && typeof currentTariffModule.applyTariffMappings === 'function') await currentTariffModule.applyTariffMappings();
@@ -5009,7 +5026,7 @@ class NexoWattVis extends HostedAdapter {
5009
5026
  if (dynamicTransition && dynamicGridAppState(nextRuntime).active) this._nwDynamicGridOwnershipPending = nextRuntime.dynamicGridConnection;
5010
5027
  try {
5011
5028
  const obj = (patchObj && typeof patchObj === 'object') ? patchObj : {};
5012
- const json = JSON.stringify(obj);
5029
+ const json = JSON.stringify(protectInfluxHistoryConfig(obj, this._nwHistorySecretCodec()));
5013
5030
  await this._nwProtectCredentialState('installer.configJson');
5014
5031
  await this.setStateAsync('installer.configJson', { val: json, ack: true });
5015
5032
  if (dynamicTransition) this._nwDynamicGridPendingCommit = dynamicTransition;
@@ -5166,7 +5183,7 @@ class NexoWattVis extends HostedAdapter {
5166
5183
  adapterVersion: (pkg && pkg.version) ? String(pkg.version) : '',
5167
5184
  instance: this.instance,
5168
5185
  reason: reason ? String(reason) : '',
5169
- configPatch: patch,
5186
+ configPatch: protectInfluxHistoryConfig(patch, this._nwHistorySecretCodec()),
5170
5187
  };
5171
5188
 
5172
5189
  await this._nwProtectCredentialState(`${base}.backupJson`, true);
@@ -5210,6 +5227,7 @@ class NexoWattVis extends HostedAdapter {
5210
5227
  parseInstallerConfigState({ val: JSON.stringify(parsed.configPatch) });
5211
5228
  }
5212
5229
  if (parsed && typeof parsed === 'object') {
5230
+ parsed.configPatch = restoreInfluxHistoryConfig(parsed.configPatch, this._nwHistorySecretCodec());
5213
5231
  // Automatische Erst-Recovery nimmt die aktuelle Sicherung; ein älterer
5214
5232
  // Stand mit mehr Geräten ist kein besserer Kundenstand.
5215
5233
  if (strict) return parsed;
@@ -5340,7 +5358,7 @@ class NexoWattVis extends HostedAdapter {
5340
5358
  const s = raw.trim();
5341
5359
  if (!s) return null;
5342
5360
  const patch = JSON.parse(s);
5343
- return (patch && typeof patch === 'object') ? patch : null;
5361
+ return (patch && typeof patch === 'object') ? restoreInfluxHistoryConfig(patch, this._nwHistorySecretCodec()) : null;
5344
5362
  } catch (_e) {
5345
5363
  return null;
5346
5364
  }
@@ -5612,7 +5630,7 @@ class NexoWattVis extends HostedAdapter {
5612
5630
 
5613
5631
  // Backup current App-Center patch so we can restore after simulation.
5614
5632
  const basePatch = (this._nwInstallerConfigPatch && typeof this._nwInstallerConfigPatch === 'object') ? this._nwInstallerConfigPatch : {};
5615
- const backupJson = JSON.stringify(basePatch);
5633
+ const backupJson = JSON.stringify(protectInfluxHistoryConfig(basePatch, this._nwHistorySecretCodec()));
5616
5634
  const backupWritten = await this.nwSimWriteStatus({
5617
5635
  active: false,
5618
5636
  instanceId: inst,
@@ -5885,6 +5903,8 @@ class NexoWattVis extends HostedAdapter {
5885
5903
  // Grenzen / optionale Signale
5886
5904
  maxChargeW: numberOrNull('maxChargeW', 'maxChargePowerW'),
5887
5905
  maxDischargeW: numberOrNull('maxDischargeW', 'maxDischargePowerW'),
5906
+ allowedChargePowerId: textFrom('allowedChargePowerId'),
5907
+ allowedDischargePowerId: textFrom('allowedDischargePowerId'),
5888
5908
  availableId: textFrom('availableId', 'availableObjectId', 'availableDp', 'availabilityId'),
5889
5909
  faultId: textFrom('faultId', 'faultObjectId', 'faultDp', 'errorId'),
5890
5910
  chargeAllowedId: textFrom('chargeAllowedId', 'chargeAllowedObjectId', 'chargeAllowedDp', 'chargeEnableId'),
@@ -6754,9 +6774,9 @@ class NexoWattVis extends HostedAdapter {
6754
6774
  }
6755
6775
  }
6756
6776
 
6757
- // Ab v0.6.258 sind die Leistungsgrenzen bewusst feste Eingaben in der Farm-Konfiguration.
6758
- // Dynamische Max-Leistungs-DPs werden in der harten Dispatch-Logik nicht mehr verwendet,
6759
- // damit die Speicherfarm auch mit einfachen Signed-DP-Systemen herstellerneutral läuft.
6777
+ // Fixed installer limits remain authoritative upper bounds. Separately
6778
+ // bound device capabilities may only reduce them. Optional unsupported
6779
+ // registers are never automatically bound just because an object exists.
6760
6780
  const availableId = String(row.availableId || '').trim();
6761
6781
  const faultId = String(row.faultId || '').trim();
6762
6782
  const chargeAllowedId = String(row.chargeAllowedId || '').trim();
@@ -6981,6 +7001,23 @@ class NexoWattVis extends HostedAdapter {
6981
7001
  return { limitW: staticLimit, configured: false, fresh: true, missing: false, invalid: false };
6982
7002
  };
6983
7003
 
7004
+ // A bound numeric device capability is a safety input, unlike optional
7005
+ // change-only boolean flags. Missing/stale/invalid observations block
7006
+ // this direction, never become an unlimited or fabricated zero value.
7007
+ const readCapabilityW = async (id, staticLimit) => {
7008
+ const sid = String(id || '').trim();
7009
+ if (!sid) return { configured: false, limitW: staticLimit, status: 'unconfigured', valueW: null };
7010
+ const st = await getState(sid);
7011
+ let reason = '';
7012
+ if (!st || st.val === undefined || st.val === null) reason = 'missing';
7013
+ else if (typeof st.val !== 'number' || !Number.isFinite(st.val) || st.val < 0 || st.val > 1000000000
7014
+ || st.ack !== true || (st.q !== undefined && st.q !== 0) || await getUnit(sid) !== 'W') reason = 'invalid';
7015
+ else if (typeof st.ts !== 'number' || !Number.isFinite(st.ts) || st.ts > now + 1000 || now - st.ts > Math.min(staleMs, 30000)) reason = 'stale';
7016
+ if (reason) return { configured: true, limitW: 0, status: reason, valueW: null };
7017
+ const valueW = Math.floor(st.val);
7018
+ return { configured: true, limitW: staticLimit === null ? valueW : Math.min(staticLimit, valueW), status: 'valid', valueW };
7019
+ };
7020
+
6984
7021
  const availState = await readBoolDp(availableId);
6985
7022
  const faultState = await readBoolDp(faultId);
6986
7023
  const chargeAllowedState = await readBoolDp(chargeAllowedId);
@@ -6988,8 +7025,10 @@ class NexoWattVis extends HostedAdapter {
6988
7025
  const chargeLimitState = await readLimitW(row.maxChargeW);
6989
7026
  const dischargeLimitState = await readLimitW(row.maxDischargeW);
6990
7027
 
6991
- const maxChargeW = chargeLimitState.limitW;
6992
- const maxDischargeW = dischargeLimitState.limitW;
7028
+ const chargeCapability = await readCapabilityW(row.allowedChargePowerId, chargeLimitState.limitW);
7029
+ const dischargeCapability = await readCapabilityW(row.allowedDischargePowerId, dischargeLimitState.limitW);
7030
+ const maxChargeW = chargeCapability.limitW;
7031
+ const maxDischargeW = dischargeCapability.limitW;
6993
7032
 
6994
7033
  const baseBlocked = [];
6995
7034
  if (status.licenseBlocked) baseBlocked.push('license_storage_limit');
@@ -7019,6 +7058,8 @@ class NexoWattVis extends HostedAdapter {
7019
7058
  else if (!chargeAllowedState.fresh) dispatchWarnings.push('charge_allowed_stale_using_last');
7020
7059
  }
7021
7060
  if (maxChargeW !== null && maxChargeW <= 0) chargeBlocked.push('charge_limit_zero');
7061
+ if (chargeCapability.configured && chargeCapability.status !== 'valid') chargeBlocked.push(`charge_capability_${chargeCapability.status}`);
7062
+ else if (chargeCapability.configured && chargeCapability.valueW === 0) chargeBlocked.push('charge_capability_zero');
7022
7063
 
7023
7064
  const dischargeBlocked = baseBlocked.slice();
7024
7065
  if (!hasDischargeSetpoint) dischargeBlocked.push('discharge_setpoint_missing');
@@ -7029,6 +7070,8 @@ class NexoWattVis extends HostedAdapter {
7029
7070
  else if (!dischargeAllowedState.fresh) dispatchWarnings.push('discharge_allowed_stale_using_last');
7030
7071
  }
7031
7072
  if (maxDischargeW !== null && maxDischargeW <= 0) dischargeBlocked.push('discharge_limit_zero');
7073
+ if (dischargeCapability.configured && dischargeCapability.status !== 'valid') dischargeBlocked.push(`discharge_capability_${dischargeCapability.status}`);
7074
+ else if (dischargeCapability.configured && dischargeCapability.valueW === 0) dischargeBlocked.push('discharge_capability_zero');
7032
7075
 
7033
7076
  const chargeDispatchAvailable = chargeBlocked.length === 0;
7034
7077
  const dischargeDispatchAvailable = dischargeBlocked.length === 0;
@@ -7046,6 +7089,10 @@ class NexoWattVis extends HostedAdapter {
7046
7089
  status.dischargeDispatchAvailable = !!dischargeDispatchAvailable;
7047
7090
  status.maxChargeW = (maxChargeW !== null) ? maxChargeW : null;
7048
7091
  status.maxDischargeW = (maxDischargeW !== null) ? maxDischargeW : null;
7092
+ status.configuredMaxChargeW = chargeLimitState.limitW;
7093
+ status.configuredMaxDischargeW = dischargeLimitState.limitW;
7094
+ status.chargeCapability = { objectId: row.allowedChargePowerId || '', ...chargeCapability };
7095
+ status.dischargeCapability = { objectId: row.allowedDischargePowerId || '', ...dischargeCapability };
7049
7096
  status.chargeBlockedReasons = chargeBlocked;
7050
7097
  status.dischargeBlockedReasons = dischargeBlocked;
7051
7098
  if (dispatchWarnings.length) status.dispatchWarnings = Array.from(new Set(dispatchWarnings));
@@ -7648,9 +7695,9 @@ class NexoWattVis extends HostedAdapter {
7648
7695
  });
7649
7696
  }
7650
7697
  /**
7651
- * Liest einen Farm-Kommandodatenpunkt nach dem Write zurueck. Das bestaetigt
7652
- * nicht die physische Batteriereaktion, aber sehr wohl, dass ioBroker und der
7653
- * nachgelagerte Adapter exakt den erwarteten Kommandowert halten.
7698
+ * Trennt den angeforderten Kommandowert (ack:false) von einer aktuellen
7699
+ * Adapter-/Treiberquittierung (ack:true). Auch letztere ist weder ein separat
7700
+ * gelesenes Geräteregister noch eine bestätigte physische Batteriereaktion.
7654
7701
  */
7655
7702
  async _sfReadbackNumber(objectId, expectedValue, options = {}) {
7656
7703
  const id = String(objectId || '').trim();
@@ -7660,28 +7707,40 @@ class NexoWattVis extends HostedAdapter {
7660
7707
  const attempts = Math.max(1, Math.min(3, Number(options.attempts) || 3));
7661
7708
  const delayMs = Math.max(0, Math.min(100, Number(options.delayMs) || 30));
7662
7709
  const expected = Number(expectedValue);
7710
+ const notBeforeTs = Math.max(0, Number(options.notBeforeTs) || 0);
7663
7711
  let last = null;
7664
7712
  for (let attempt = 1; attempt <= attempts; attempt++) {
7665
7713
  try {
7666
7714
  const state = await this.getForeignStateAsync(id);
7667
7715
  const raw = state && Object.prototype.hasOwnProperty.call(state, 'val') ? state.val : null;
7668
- const actual = typeof raw === 'number'
7669
- ? raw
7670
- : Number(String(raw === null || raw === undefined ? '' : raw).trim().replace(',', '.'));
7716
+ const actual = typeof raw === 'number' ? raw
7717
+ : (typeof raw === 'string' && raw.trim() ? Number(raw.trim().replace(',', '.')) : Number.NaN);
7671
7718
  const tolerance = Math.max(0.000001, Math.abs(expected) * 0.000001);
7672
- const ok = Number.isFinite(actual) && Number.isFinite(expected) && Math.abs(actual - expected) <= tolerance;
7719
+ const matches = Number.isFinite(actual) && Number.isFinite(expected) && Math.abs(actual - expected) <= tolerance;
7720
+ const ts = state && typeof state.ts === 'number' && Number.isFinite(state.ts) && state.ts > 0 ? state.ts : null;
7721
+ const qualityOk = !!state && (state.q === undefined || state.q === 0);
7722
+ const current = ts !== null && ts >= notBeforeTs && ts <= Date.now() + 1000;
7723
+ const ok = matches && qualityOk && state.ack === true && current;
7724
+ const pending = matches && qualityOk && !ok;
7673
7725
  last = {
7674
7726
  supported: true,
7675
7727
  ok,
7676
- status: ok ? 'confirmed' : (Number.isFinite(actual) ? 'mismatch' : 'value-missing'),
7728
+ pending,
7729
+ status: ok ? 'driver-acknowledged' : (pending ? 'pending-ack'
7730
+ : (!qualityOk && state ? 'quality-invalid' : (Number.isFinite(actual) ? 'mismatch' : 'value-missing'))),
7731
+ confirmationLevel: ok ? 'driver-acknowledged' : (pending ? 'requested' : 'none'),
7732
+ pendingReason: pending ? (state.ack !== true ? 'ack-not-received' : 'ack-not-current') : '',
7677
7733
  objectId: id,
7678
7734
  expected,
7679
7735
  actual: Number.isFinite(actual) ? actual : raw,
7680
- ts: state && Number.isFinite(Number(state.ts)) ? Number(state.ts) : null,
7736
+ ts,
7681
7737
  ack: state && typeof state.ack === 'boolean' ? state.ack : null,
7738
+ q: state && state.q !== undefined ? state.q : null,
7682
7739
  attempts: attempt,
7683
7740
  };
7684
- if (ok) return last;
7741
+ // A matching request is an asynchronous handoff, not a retryable
7742
+ // mismatch. Observe the later ack on the next tick without blocking it.
7743
+ if (ok || pending) return last;
7685
7744
  } catch (error) {
7686
7745
  last = {
7687
7746
  supported: true,
@@ -7736,13 +7795,16 @@ class NexoWattVis extends HostedAdapter {
7736
7795
  const age = now - lastTs;
7737
7796
 
7738
7797
  if (same && (!keepaliveEnabled || age < effectiveKeepaliveMs)) {
7739
- const current = await this._sfReadbackNumber(objectId, value, { attempts: 1, delayMs: 0 });
7740
- if (!current.supported || current.ok) {
7798
+ const current = await this._sfReadbackNumber(objectId, value, { attempts: 1, delayMs: 0, notBeforeTs: lastTs });
7799
+ if (!current.supported || current.ok || current.pending === true) {
7741
7800
  return {
7742
7801
  ok: true,
7743
7802
  skipped: true,
7744
7803
  changed: false,
7745
7804
  same: true,
7805
+ submitted: true,
7806
+ pending: current.pending === true,
7807
+ confirmationLevel: current.confirmationLevel || 'requested',
7746
7808
  readback: current,
7747
7809
  readbackSupported: current.supported === true,
7748
7810
  readbackOk: current.supported === true ? current.ok === true : null,
@@ -7765,8 +7827,8 @@ class NexoWattVis extends HostedAdapter {
7765
7827
  };
7766
7828
  }
7767
7829
 
7768
- const readback = await this._sfReadbackNumber(objectId, value, { attempts: 3, delayMs: 30 });
7769
- if (readback.supported && !readback.ok) {
7830
+ const readback = await this._sfReadbackNumber(objectId, value, { attempts: 3, delayMs: 30, notBeforeTs: now });
7831
+ if (readback.supported && !readback.ok && readback.pending !== true) {
7770
7832
  this._sfLastSetpoints.delete(objectId);
7771
7833
  this._sfLastSetpointsTs.delete(objectId);
7772
7834
  return {
@@ -7787,6 +7849,9 @@ class NexoWattVis extends HostedAdapter {
7787
7849
  skipped: false,
7788
7850
  changed: true,
7789
7851
  same,
7852
+ submitted: true,
7853
+ pending: readback.pending === true,
7854
+ confirmationLevel: readback.confirmationLevel || 'requested',
7790
7855
  keepalive: keepaliveEnabled && same && age >= effectiveKeepaliveMs,
7791
7856
  readback,
7792
7857
  readbackSupported: readback.supported === true,
@@ -7918,6 +7983,9 @@ class NexoWattVis extends HostedAdapter {
7918
7983
  return {
7919
7984
  ...s,
7920
7985
  soc,
7986
+ // Preserve the observed value for diagnostics; do not change the
7987
+ // established dispatch calculation's treatment of absent status fields.
7988
+ _sfReportedSoc: numericMeasurement(st.soc),
7921
7989
  online,
7922
7990
  displayOnline,
7923
7991
  offlineReason,
@@ -8070,6 +8138,16 @@ class NexoWattVis extends HostedAdapter {
8070
8138
  if (Number.isFinite(minPowerW)) effectiveBatteryTargetW = Math.max(Number(minPowerW), effectiveBatteryTargetW);
8071
8139
  if (Number.isFinite(maxPowerW)) effectiveBatteryTargetW = Math.min(Number(maxPowerW), effectiveBatteryTargetW);
8072
8140
  }
8141
+ // A bound device capability must also constrain the exclusive native
8142
+ // FEMS path before translating battery power into a grid target. Without
8143
+ // these new bindings, retain the established native controller behavior.
8144
+ if (w > 0 && String(storage.allowedDischargePowerId || '').trim()) {
8145
+ effectiveBatteryTargetW = storage.dischargeDispatchAvailable === true && Number.isFinite(storage.maxDischargeW)
8146
+ ? Math.min(Math.max(0, effectiveBatteryTargetW), storage.maxDischargeW) : 0;
8147
+ } else if (w < 0 && String(storage.allowedChargePowerId || '').trim()) {
8148
+ effectiveBatteryTargetW = storage.chargeDispatchAvailable === true && Number.isFinite(storage.maxChargeW)
8149
+ ? -Math.min(Math.max(0, -effectiveBatteryTargetW), storage.maxChargeW) : 0;
8150
+ }
8073
8151
  // A FEMS grid target is not an ESS target: calculate the NVP value for
8074
8152
  // zero battery power instead of writing a misleading literal 0 to the grid DP.
8075
8153
  if (storage.licenseBlocked) effectiveBatteryTargetW = 0;
@@ -8167,7 +8245,8 @@ class NexoWattVis extends HostedAdapter {
8167
8245
  const readbackOk = readbackSupported ? writeResult.readbackOk === true : writeOk;
8168
8246
  const commandStatus = !calculation.ok
8169
8247
  ? String(calculation.reason || 'fenecon-calculation-failed')
8170
- : (!releaseOk ? 'fenecon-direct-release-failed' : (writeOk ? 'confirmed' : 'fenecon-grid-write-failed'));
8248
+ : (!releaseOk ? 'fenecon-direct-release-failed' : (writeOk
8249
+ ? String(writeResult.readback && writeResult.readback.status || 'unavailable') : 'fenecon-grid-write-failed'));
8171
8250
  const acceptedW = writeOk ? effectiveBatteryTargetW : 0;
8172
8251
  const failedW = writeOk ? 0 : w;
8173
8252
  const nativeResult = {
@@ -8201,6 +8280,11 @@ class NexoWattVis extends HostedAdapter {
8201
8280
  acceptedDeliveredW: acceptedW,
8202
8281
  failedW,
8203
8282
  unservedW: writeOk ? (w - effectiveBatteryTargetW) : w,
8283
+ commandDpReadbackSupported: readbackSupported,
8284
+ commandDpReadbackOk: readbackOk,
8285
+ commandDpReadbackStatus: commandStatus,
8286
+ commandDpReadbackPending: !!(writeResult && writeResult.pending === true),
8287
+ commandConfirmationLevel: writeResult && writeResult.confirmationLevel || 'none',
8204
8288
  validation: feneconFarmValidation,
8205
8289
  results: [nativeResult],
8206
8290
  };
@@ -8233,6 +8317,8 @@ class NexoWattVis extends HostedAdapter {
8233
8317
  commandDpReadbackSupported: readbackSupported,
8234
8318
  commandDpReadbackOk: readbackOk,
8235
8319
  commandDpReadbackStatus: commandStatus,
8320
+ commandDpReadbackPending: !!(writeResult && writeResult.pending === true),
8321
+ commandConfirmationLevel: writeResult && writeResult.confirmationLevel || 'none',
8236
8322
  commandDpReadbackRows: writeResult && writeResult.readback ? [writeResult.readback] : [],
8237
8323
  requestSatisfied: writeOk && effectiveBatteryTargetW === w,
8238
8324
  partiallyAccepted: writeOk && effectiveBatteryTargetW !== w,
@@ -8618,9 +8704,21 @@ class NexoWattVis extends HostedAdapter {
8618
8704
  || commandFamily === 'signed'
8619
8705
  || (commandFamily === 'split' && (direction === 'charge' ? !!chargeId : !!dischargeId));
8620
8706
 
8707
+ // Explain this exact dispatch decision without redefining the status
8708
+ // capability flags or changing the allocator/write path above.
8709
+ const directionDispatchAvailable = eligibleForDispatch.includes(s);
8710
+ const blockedReasons = [...(direction === 'charge' ? (s.chargeBlockedReasons || [])
8711
+ : direction === 'discharge' ? (s.dischargeBlockedReasons || []) : [])];
8712
+ if (direction === 'discharge' && dispatchEligible.includes(s) && !directionDispatchAvailable) {
8713
+ blockedReasons.push(s._sfReportedSoc === null ? 'soc_missing' : 'soc_at_or_below_discharge_floor');
8714
+ }
8715
+ const effectiveDischargeLimit = direction === 'discharge'
8716
+ ? (directionDispatchAvailable ? getLimitW(s, 'discharge') : 0) : null;
8717
+
8621
8718
  const r = {
8622
8719
  name: s.name || '',
8623
- soc: Number.isFinite(Number(s.soc)) ? Number(s.soc) : null,
8720
+ dispatchKey: s._sfKey,
8721
+ soc: s._sfReportedSoc,
8624
8722
  state: s.state || '',
8625
8723
  online: !!s.online,
8626
8724
  dispatchAvailable: !!s.dispatchAvailable,
@@ -8628,7 +8726,10 @@ class NexoWattVis extends HostedAdapter {
8628
8726
  dischargeDispatchAvailable: !!s.dischargeDispatchAvailable,
8629
8727
  maxChargeW: (s.maxChargeW !== null && Number.isFinite(Number(s.maxChargeW))) ? Number(s.maxChargeW) : null,
8630
8728
  maxDischargeW: (s.maxDischargeW !== null && Number.isFinite(Number(s.maxDischargeW))) ? Number(s.maxDischargeW) : null,
8631
- blockedReasons: direction === 'charge' ? (s.chargeBlockedReasons || []) : (direction === 'discharge' ? (s.dischargeBlockedReasons || []) : []),
8729
+ directionDispatchAvailable,
8730
+ dischargeFloorSocPct: direction === 'discharge' ? dischargeFloorSoc : null,
8731
+ effectiveMaxDischargeW: Number.isFinite(effectiveDischargeLimit) ? effectiveDischargeLimit : null,
8732
+ blockedReasons,
8632
8733
  warnings: Array.isArray(s.dispatchWarnings) ? s.dispatchWarnings : [],
8633
8734
  statusMatch: String(s.statusMatch || ''),
8634
8735
  actualChargeW: Number.isFinite(Number(s.chargePowerW)) ? Number(s.chargePowerW) : null,
@@ -8747,20 +8848,30 @@ class NexoWattVis extends HostedAdapter {
8747
8848
  key,
8748
8849
  objectId: readback ? String(readback.objectId || '') : '',
8749
8850
  expected: readback && Number.isFinite(Number(readback.expected)) ? Number(readback.expected) : null,
8750
- actual: readback && Number.isFinite(Number(readback.actual)) ? Number(readback.actual) : (readback ? readback.actual : null),
8851
+ actual: readback && typeof readback.actual === 'number' && Number.isFinite(readback.actual)
8852
+ ? readback.actual : (readback ? readback.actual : null),
8751
8853
  supported: !!(wr && wr.readbackSupported === true),
8752
8854
  ok: wr && typeof wr.readbackOk === 'boolean' ? wr.readbackOk : null,
8855
+ pending: !!(readback && readback.pending === true),
8856
+ ack: readback && typeof readback.ack === 'boolean' ? readback.ack : null,
8857
+ ts: readback ? readback.ts : null,
8858
+ q: readback ? readback.q : null,
8859
+ confirmationLevel: readback ? String(readback.confirmationLevel || 'none') : 'none',
8753
8860
  status: readback ? String(readback.status || '') : String((wr && wr.reason) || ''),
8754
8861
  };
8755
8862
  }));
8756
8863
  const supportedCommandDpReadbacks = commandDpReadbackRows.filter((row) => row.supported);
8757
8864
  const commandDpReadbackSupported = supportedCommandDpReadbacks.length > 0;
8758
8865
  const commandDpReadbackOk = commandDpReadbackSupported
8759
- ? supportedCommandDpReadbacks.every((row) => row.ok === true)
8866
+ ? commandDpReadbackRows.every((row) => row.supported && row.ok === true)
8760
8867
  : true;
8761
8868
  const commandDpReadbackStatus = commandDpReadbackSupported
8762
- ? (commandDpReadbackOk ? 'confirmed' : 'command-dp-mismatch')
8869
+ ? (commandDpReadbackOk ? 'driver-acknowledged'
8870
+ : (commandDpReadbackRows.every(row => !row.supported || row.ok === true || row.pending === true) ? 'pending-ack' : 'command-dp-mismatch'))
8763
8871
  : 'unavailable';
8872
+ const commandDpReadbackPending = supportedCommandDpReadbacks.some(row => row.pending === true);
8873
+ const commandConfirmationLevel = commandDpReadbackSupported && commandDpReadbackOk
8874
+ ? 'driver-acknowledged' : (allConfiguredWritesAccepted ? 'requested' : 'none');
8764
8875
  const anyAcceptedPower = direction === 'idle' ? allConfiguredWritesAccepted : acceptedAbsW > 0;
8765
8876
  const requestSatisfied = direction === 'idle'
8766
8877
  ? allConfiguredWritesAccepted
@@ -8789,6 +8900,8 @@ class NexoWattVis extends HostedAdapter {
8789
8900
  commandDpReadbackSupported,
8790
8901
  commandDpReadbackOk,
8791
8902
  commandDpReadbackStatus,
8903
+ commandDpReadbackPending,
8904
+ commandConfirmationLevel,
8792
8905
  commandDpReadbackRows,
8793
8906
  requestSatisfied,
8794
8907
  status: dispatchStatus,
@@ -8803,7 +8916,8 @@ class NexoWattVis extends HostedAdapter {
8803
8916
  return Number.isFinite(v) ? Math.round(v) : null;
8804
8917
  })(),
8805
8918
  availableDischargePowerW: (() => {
8806
- const v = sumLimitW(storages.filter(s => s.dischargeDispatchAvailable === true), 'discharge');
8919
+ const v = sumLimitW(direction === 'discharge' ? eligibleForDispatch
8920
+ : storages.filter(s => s.dischargeDispatchAvailable === true), 'discharge');
8807
8921
  return Number.isFinite(v) ? Math.round(v) : null;
8808
8922
  })(),
8809
8923
  results: results.map(r => {
@@ -8811,6 +8925,7 @@ class NexoWattVis extends HostedAdapter {
8811
8925
  const authorityBlocks = writeRows.filter(wr => wr && wr.blocked === true);
8812
8926
  return {
8813
8927
  name: r.name || '',
8928
+ dispatchKey: r.dispatchKey,
8814
8929
  state: r.state || '',
8815
8930
  online: r.online,
8816
8931
  dispatchAvailable: r.dispatchAvailable,
@@ -8818,6 +8933,9 @@ class NexoWattVis extends HostedAdapter {
8818
8933
  dischargeDispatchAvailable: r.dischargeDispatchAvailable,
8819
8934
  maxChargeW: r.maxChargeW,
8820
8935
  maxDischargeW: r.maxDischargeW,
8936
+ directionDispatchAvailable: r.directionDispatchAvailable,
8937
+ dischargeFloorSocPct: r.dischargeFloorSocPct,
8938
+ effectiveMaxDischargeW: r.effectiveMaxDischargeW,
8821
8939
  blockedReasons: r.blockedReasons,
8822
8940
  warnings: r.warnings,
8823
8941
  statusMatch: r.statusMatch,
@@ -8875,6 +8993,8 @@ class NexoWattVis extends HostedAdapter {
8875
8993
  commandDpReadbackSupported,
8876
8994
  commandDpReadbackOk,
8877
8995
  commandDpReadbackStatus,
8996
+ commandDpReadbackPending,
8997
+ commandConfirmationLevel,
8878
8998
  commandDpReadbackRows,
8879
8999
  requestSatisfied,
8880
9000
  partiallyAccepted: !allConfiguredWritesAccepted && acceptedAbsW > 0,
@@ -12027,9 +12147,10 @@ async onReady() {
12027
12147
  try { await startupStep(() => this.initLogicEngine()); } catch (e) { this.log.warn('NexoLogic init failed: ' + (e && e.message ? e.message : e)); }
12028
12148
  if (this._nwShuttingDown) return;
12029
12149
  assertStartupAuthority();
12030
- this._hostedStartup = { state: this.emsEngine ? 'ready' : 'degraded', error: this.emsEngine ? '' : 'EOS_EMS_INIT_FAILED' };
12150
+ const emsReady = this._nwIsEmsReady();
12151
+ this._hostedStartup = { state: emsReady ? 'ready' : 'degraded', error: emsReady ? '' : 'EOS_EMS_INIT_FAILED' };
12031
12152
  this._bridge.deviceEmsConfigChanged?.();
12032
- if (this.emsEngine) this.log.info('NexoWatt EOS ist bereit.');
12153
+ if (emsReady) this.log.info('NexoWatt EOS ist bereit.');
12033
12154
  else this.log.warn('EOS_EMS_INIT_FAILED: Bedienoberfläche verfügbar, Betriebsstart unvollständig.');
12034
12155
  } catch (e) {
12035
12156
  if (this._nwShuttingDown) return;
@@ -12096,6 +12217,14 @@ async onReady() {
12096
12217
  throw e;
12097
12218
  }
12098
12219
  }
12220
+ // A retained engine can be fenced while asynchronous module cleanup is
12221
+ // unresolved. Its presence alone does not establish operational readiness.
12222
+ _nwIsEmsReady() {
12223
+ const engine = this.emsEngine;
12224
+ return !this._nwShuttingDown && !this._nwEmsInitError &&
12225
+ !!engine?._timer && engine._reconfiguring !== true;
12226
+ }
12227
+
12099
12228
  /**
12100
12229
  * Code-Teil: initEmsEngine
12101
12230
  * Zweck: Initialisiert diesen Bereich und verbindet abhängige Startlogik.
@@ -12104,38 +12233,52 @@ async onReady() {
12104
12233
  */
12105
12234
  async initEmsEngine(force) {
12106
12235
  if (this._nwShuttingDown) throw new Error('EOS_UI_STOPPING');
12107
- const doForce = !!force;
12108
-
12109
- if (this.emsEngine && !doForce) return;
12110
-
12111
- // A replacement must never reuse the old registry or overlap an old tick.
12112
- // Failure keeps the old engine paused and visible for the next apply attempt.
12113
- if (doForce && this.emsEngine) {
12114
- if (typeof this.emsEngine.stopForReconfigure === 'function') await this.emsEngine.stopForReconfigure();
12115
- else if (typeof this.emsEngine.stop === 'function') await this.emsEngine.stop();
12116
- this.emsEngine = null;
12117
- }
12118
-
12119
- // Reset last error
12120
- this._nwEmsInitError = '';
12121
-
12122
- try {
12123
- if (!this.emsEngine) this.emsEngine = new EmsEngine(this);
12124
- await this.emsEngine.init();
12125
- if (this._nwShuttingDown) throw new Error('EOS_UI_STOPPING');
12126
- await this._meshCoordinator?.syncAppLifecycle();
12236
+ if (this._nwEmsInitPending) return this._nwEmsInitPending;
12237
+ const initialize = async () => {
12238
+ if (!force && this._nwIsEmsReady()) return;
12239
+ // Failed initialization may already own asynchronous module work. Keep
12240
+ // that engine reachable until its bounded drain has actually completed.
12241
+ const drainPrevious = async () => {
12242
+ const previous = this.emsEngine;
12243
+ if (!previous) return;
12244
+ this._nwEmsInitError ||= 'EOS_EMS_CONFIG_APPLY_PENDING';
12245
+ if (typeof previous.stopForReconfigure === 'function') await previous.stopForReconfigure();
12246
+ else if (typeof previous.stop === 'function') await awaitEmsTransition(Promise.resolve(previous.stop()));
12247
+ else throw new Error('EOS_EMS_STOP_UNCONFIRMED');
12248
+ if (this.emsEngine === previous) this.emsEngine = null;
12249
+ };
12250
+ await drainPrevious();
12127
12251
  if (this._nwShuttingDown) throw new Error('EOS_UI_STOPPING');
12128
- this._nwEmsInitError = '';
12129
- } catch (e) {
12130
- this._nwEmsInitError = (e && e.message) ? String(e.message) : String(e);
12131
-
12252
+ this._nwEmsInitError = 'EOS_EMS_STARTING';
12132
12253
  try {
12133
- if (this.emsEngine && typeof this.emsEngine.stop === 'function') this.emsEngine.stop();
12134
- } catch (_e2) {}
12135
-
12136
- this.emsEngine = null;
12137
- throw e;
12254
+ this.emsEngine = new EmsEngine(this);
12255
+ await this.emsEngine.init();
12256
+ if (this._nwShuttingDown) throw new Error('EOS_UI_STOPPING');
12257
+ await this._meshCoordinator?.syncAppLifecycle();
12258
+ if (this._nwShuttingDown) throw new Error('EOS_UI_STOPPING');
12259
+ this._nwEmsInitError = '';
12260
+ if (this._hostedStartup?.state === 'degraded' && this._hostedStartup.error === 'EOS_EMS_INIT_FAILED' && this._nwIsEmsReady()) {
12261
+ this._hostedStartup = { state: 'ready', error: '' };
12262
+ }
12263
+ } catch (e) {
12264
+ this._nwEmsInitError = (e && e.message) ? String(e.message) : String(e);
12265
+ try { await drainPrevious(); }
12266
+ catch (_cleanupError) {
12267
+ this.log.warn('EOS_EMS_FAILED_START_CLEANUP_PENDING: Alte EMS-Laufzeit bleibt bis zum bestätigten Stopp gesperrt.');
12268
+ }
12269
+ throw e;
12270
+ }
12271
+ };
12272
+ const operation = initialize();
12273
+ this._nwEmsInitPending = operation;
12274
+ try { return await operation; }
12275
+ catch (error) {
12276
+ if (this._hostedStartup?.state === 'ready' && !this._nwIsEmsReady()) {
12277
+ this._hostedStartup = { state: 'degraded', error: 'EOS_EMS_INIT_FAILED' };
12278
+ }
12279
+ throw error;
12138
12280
  }
12281
+ finally { if (this._nwEmsInitPending === operation) this._nwEmsInitPending = null; }
12139
12282
  }
12140
12283
 
12141
12284
  /**
@@ -12618,7 +12761,7 @@ async onReady() {
12618
12761
 
12619
12762
  /** Öffentliche /config-Antwort von Datenpunktpfaden und Migrationsdiagnose befreien. */
12620
12763
  const nwSanitizePublicConfig = (payload, installerAccess = false) => {
12621
- if (installerAccess) return payload;
12764
+ if (installerAccess) return redactInfluxHistoryConfig(payload);
12622
12765
  const src = (payload && typeof payload === 'object') ? payload : {};
12623
12766
  const out = Object.assign({}, src);
12624
12767
  delete out.featureVisibilityTsPreview;
@@ -12672,7 +12815,7 @@ async onReady() {
12672
12815
  customerWritePolicy: 'session',
12673
12816
  remoteIp: '',
12674
12817
  };
12675
- return out;
12818
+ return redactInfluxHistoryConfig(out);
12676
12819
  };
12677
12820
  this._nwSanitizePublicConfig = nwSanitizePublicConfig;
12678
12821
 
@@ -12905,6 +13048,11 @@ app.get('/apple-touch-icon.png', (_req, res) => {
12905
13048
  res.type('image/png');
12906
13049
  res.sendFile(path.join(__dirname, 'www', 'apple-touch-icon.png'));
12907
13050
  });
13051
+ // Conventional iOS probes are fixed public image aliases, never a public directory.
13052
+ app.get(['/apple-touch-icon-precomposed.png', '/apple-touch-icon-180x180.png', '/apple-touch-icon-180x180-precomposed.png'], (_req, res) => {
13053
+ res.type('image/png');
13054
+ res.sendFile(path.join(__dirname, 'www', 'assets', 'icons', 'nexowatt-180.png'));
13055
+ });
12908
13056
  // API-Kommentar: GET-Route. Zweck: stellt einen Web-/API-Endpunkt bereit. Zusammenhang: Frontend-Dateien in www/* können diesen Endpunkt direkt nutzen. Route/Handler: '/favicon.ico', (_req, res) => {
12909
13057
  app.get('/favicon.ico', (_req, res) => {
12910
13058
  res.type('image/x-icon');
@@ -13270,7 +13418,7 @@ registerSmartHomeDeviceApi(app, {
13270
13418
  history: (id, options) => new Promise(resolve => {
13271
13419
  const instance = String(this._nwGetHistoryInstance() || '').trim();
13272
13420
  if (!instance) return resolve({ error: 'HISTORY_NOT_CONFIGURED' });
13273
- this.sendTo(instance, 'getHistory', { id, options: { ...options, addId: false, ignoreNull: true, limit: 1000 } }, resolve);
13421
+ this._nwDispatchHistory(instance, { id, options: { ...options, addId: false, ignoreNull: true, limit: 1000 } }, resolve);
13274
13422
  }),
13275
13423
  }, requireAuth, requireDpDiscovery);
13276
13424
 
@@ -15867,7 +16015,7 @@ app.get('/api/smarthome/type-detect', requireDpDiscovery, async (req, res) => {
15867
16015
  // Antworten werden zusätzlich durch die bestehende globale Redaction abgesichert.
15868
16016
  const _nwTariffSecretKeys = new Set(['accessToken','securityToken','clientSecret','bearerToken','apiKey','password','refreshToken']);
15869
16017
  const _nwMaskTariffProviderForUi = (cfg) => {
15870
- const clone = this._nwDeepClone(cfg || {}) || {};
16018
+ const clone = redactInfluxHistoryConfig(this._nwDeepClone(cfg || {}) || {});
15871
16019
  if (clone?.tariffProvider) delete clone.tariffProvider.retainedProviderCredentials;
15872
16020
  const creds = clone && clone.tariffProvider && clone.tariffProvider.credentials;
15873
16021
  if (creds && typeof creds === 'object') {
@@ -15878,7 +16026,7 @@ app.get('/api/smarthome/type-detect', requireDpDiscovery, async (req, res) => {
15878
16026
  return clone;
15879
16027
  };
15880
16028
  const stripRetainedTariffCredentials = (patch) => {
15881
- const clean = this._nwDeepClone(patch || {}) || {};
16029
+ const clean = protectInfluxHistoryConfig(this._nwDeepClone(patch || {}) || {}, this._nwHistorySecretCodec());
15882
16030
  if (clean.tariffProvider) delete clean.tariffProvider.retainedProviderCredentials;
15883
16031
  return clean;
15884
16032
  };
@@ -15921,6 +16069,61 @@ app.get('/api/smarthome/type-detect', requireDpDiscovery, async (req, res) => {
15921
16069
  };
15922
16070
 
15923
16071
  // Abschnitt: Installer/App-Center-APIs. Änderungen wirken direkt auf EMS-Module und DP-Mapping.
16072
+ const requireHistoryInstaller = (req, res, next) => {
16073
+ if (!['admin', 'installer'].includes(req.nwSession?.role)) return sendForbidden(res);
16074
+ return next();
16075
+ };
16076
+ const historyResponse = () => ({ ok: true, config: redactInfluxHistoryConfig({ history: this.config?.history || { provider: 'adapter' } }).history, configurationRevision: this._nwInstallerConfigRevision(), status: this._nwDirectHistory.status() });
16077
+ const historyFailure = (res, error) => {
16078
+ const rawCode = error?.code;
16079
+ const code = typeof rawCode === 'string' && /^EOS_INFLUX_[A-Z_]{1,64}$/.test(rawCode) ? rawCode : 'EOS_INFLUX_REQUEST_FAILED';
16080
+ const invalid = ['EOS_INFLUX_CONFIG_INVALID', 'EOS_INFLUX_PROVIDER_INVALID', 'EOS_INFLUX_TOKEN_INVALID', 'EOS_INFLUX_CA_INVALID', 'EOS_INFLUX_URL_INVALID', 'EOS_INFLUX_NEW_DESTINATION_REQUIRES_TOKEN'].includes(code);
16081
+ return res.status(invalid ? 400 : 503).json({ ok: false, error: code });
16082
+ };
16083
+ app.get('/api/installer/history', requireInstaller, requireHistoryInstaller, (_req, res) => {
16084
+ sendNoStore(res); this._nwConfigureHistory(); return res.json(historyResponse());
16085
+ });
16086
+ app.post('/api/installer/history/check', requireInstaller, requireHistoryInstaller, async (req, res) => {
16087
+ sendNoStore(res);
16088
+ if (this._nwShuttingDown || this._bridge.canWrite() !== true) return res.status(503).json({ ok: false, error: 'EOS_UI_OWNERSHIP_REQUIRED' });
16089
+ if (this._nwHistoryCheckInFlight) return res.status(409).json({ ok: false, error: 'EOS_INFLUX_CHECK_BUSY' });
16090
+ this._nwHistoryCheckInFlight = true;
16091
+ let client = null;
16092
+ try {
16093
+ const candidate = prepareInfluxHistoryChange(this.config?.history, req.body?.history || { provider: 'influxdb2' });
16094
+ if (candidate.provider !== 'influxdb2') return res.status(400).json({ ok: false, error: 'EOS_INFLUX_PROVIDER_INVALID' });
16095
+ client = new InfluxDirectClient(candidate.influxdb2);
16096
+ this._nwHistoryCheckClient = client;
16097
+ const check = await client.check();
16098
+ return res.json({ ok: true, check });
16099
+ } catch (error) { return historyFailure(res, error); }
16100
+ finally { client?.close(); this._nwHistoryCheckClient = null; this._nwHistoryCheckInFlight = false; }
16101
+ });
16102
+ app.post('/api/installer/history', requireInstaller, requireHistoryInstaller, async (req, res) => {
16103
+ sendNoStore(res);
16104
+ if (this._nwShuttingDown || this._bridge.canWrite() !== true) return res.status(503).json({ ok: false, error: 'EOS_UI_OWNERSHIP_REQUIRED' });
16105
+ const mutation = beginMeshAppSave();
16106
+ if (!mutation) return res.status(409).json({ ok: false, error: 'EOS_INFLUX_CONFIG_BUSY' });
16107
+ try {
16108
+ if (typeof req.body?.expectedConfigurationRevision !== 'string' || req.body.expectedConfigurationRevision !== this._nwInstallerConfigRevision()) {
16109
+ return res.status(409).json({ ok: false, error: 'EOS_INSTALLER_CONFIG_CONFLICT' });
16110
+ }
16111
+ const history = prepareInfluxHistoryChange(this.config?.history, req.body?.history);
16112
+ const patch = { ...this._nwDeepClone(this._nwInstallerConfigPatch || {}), history };
16113
+ if (await this.persistInstallerConfigToState(patch) === false) return res.status(503).json({ ok: false, error: 'EOS_INFLUX_CONFIG_SAVE_FAILED' });
16114
+ this._nwInstallerConfigPatch = patch;
16115
+ this.config = this.nwApplyInstallerPatchToRuntimeConfig(this.config, patch);
16116
+ if (this._nwShuttingDown || this._bridge.canWrite() !== true) return res.status(503).json({ ok: false, saved: true, error: 'EOS_UI_OWNERSHIP_REQUIRED' });
16117
+ this._nwConfigureHistory();
16118
+ await this.ensureHistorieExportStates();
16119
+ if (!this._nwShuttingDown && this._bridge.canWrite() === true) {
16120
+ void this.updateHistorieExportStates('history-save').catch(() => {});
16121
+ }
16122
+ try { await this.nwWriteUserdataBackup(patch, 'history-save'); } catch (_error) {}
16123
+ return res.json(historyResponse());
16124
+ } catch (error) { return historyFailure(res, error); }
16125
+ finally { endMeshAppSave(mutation); }
16126
+ });
15924
16127
  // API-Kommentar: GET-Route. Zweck: stellt einen Web-/API-Endpunkt bereit. Zusammenhang: Frontend-Dateien in www/* können diesen Endpunkt direkt nutzen. Route/Handler: '/api/installer/config', requireInstaller, async (_req, res) => {
15925
16128
  app.get('/api/installer/config', requireInstaller, async (_req, res) => {
15926
16129
  try {
@@ -16233,6 +16436,7 @@ app.get('/api/smarthome/type-detect', requireDpDiscovery, async (req, res) => {
16233
16436
  res.status(400).json({ ok: false, error: 'invalid backup/patch' });
16234
16437
  return;
16235
16438
  }
16439
+ patch = restoreInfluxHistoryConfig(patch, this._nwHistorySecretCodec());
16236
16440
  const tokenError = nwValidateStationTokenChanges(patch);
16237
16441
  if (tokenError) return res.status(400).json({ ok: false, error: 'invalid_station_token', message: tokenError });
16238
16442
 
@@ -16253,7 +16457,7 @@ app.get('/api/smarthome/type-detect', requireDpDiscovery, async (req, res) => {
16253
16457
  'settingsConfig',
16254
16458
 
16255
16459
  // Optional diagnostics settings
16256
- 'diagnostics',
16460
+ 'diagnostics', 'history',
16257
16461
  ]);
16258
16462
 
16259
16463
  // Build sanitized patch
@@ -16281,6 +16485,11 @@ app.get('/api/smarthome/type-detect', requireDpDiscovery, async (req, res) => {
16281
16485
  if (Object.prototype.hasOwnProperty.call(safePatch, 'nvpTopology')) finalPatch.nvpTopology = this._nwDeepClone(safePatch.nvpTopology);
16282
16486
  else if (this.config.nvpTopology !== undefined) finalPatch.nvpTopology = this._nwDeepClone(this.config.nvpTopology);
16283
16487
 
16488
+ // Credentials are atomic even for merge imports: a quarantined incoming
16489
+ // envelope must never inherit the previous destination's plaintext token.
16490
+ if (safePatch.history !== undefined) finalPatch.history = this._nwDeepClone(safePatch.history);
16491
+ else if (this.config.history !== undefined) finalPatch.history = this._nwDeepClone(this.config.history);
16492
+
16284
16493
  // Apply to runtime config based on instance native (drop old patch leftovers)
16285
16494
  let baseNative = {};
16286
16495
  try {
@@ -16326,7 +16535,7 @@ app.get('/api/smarthome/type-detect', requireDpDiscovery, async (req, res) => {
16326
16535
  await this._nwApplyInstallerRuntime(restartEms, 'import');
16327
16536
  try { await this.nwWriteUserdataBackup(finalPatch, 'import'); } catch (_e) {}
16328
16537
 
16329
- res.json({ ok: true, imported: true, restarted: !!restartEms, config: _nwPickPersistedInstallerConfig(), configurationRevision: this._nwInstallerConfigRevision() });
16538
+ res.json({ ok: true, imported: true, restarted: !!restartEms, config: _nwMaskTariffProviderForUi(_nwPickPersistedInstallerConfig()), configurationRevision: this._nwInstallerConfigRevision() });
16330
16539
  this._bridge.deviceEmsConfigChanged?.();
16331
16540
  } catch (e) {
16332
16541
  const failure = safeConfigurationFailure(e);
@@ -17346,7 +17555,7 @@ app.get('/api/smarthome/type-detect', requireDpDiscovery, async (req, res) => {
17346
17555
  app.get('/api/ems/status', requireInstaller, async (req, res) => {
17347
17556
  try {
17348
17557
  const engine = this.emsEngine;
17349
- const running = !!(engine && engine._timer);
17558
+ const running = this._nwIsEmsReady();
17350
17559
  const intervalMs = engine && typeof engine._intervalMs === 'number' ? engine._intervalMs : null;
17351
17560
 
17352
17561
  const mm = engine && engine.mm ? engine.mm : null;
@@ -18545,7 +18754,7 @@ app.get('/api/history', async (req, res) => {
18545
18754
  * Zusammenhang: Gehört zu ioBroker-Adapterkern (Adapter-Lifecycle, Webserver, REST-/SSE-API, State-Anlage, Lizenz und EMS-Engine) und wird von benachbarten UI-/API-/EMS-Bausteinen genutzt.
18546
18755
  * Wartung/TypeScript: Änderungen können Adapterstart, APIs, States und Webserver beeinflussen; unload/connection immer mittesten. Beim TS-Umbau Parameter, Rückgabe und genutzte State-/Config-Objekte explizit typisieren.
18547
18756
  */
18548
- const densifyHoldLast = (values, rangeStart = start, rangeEnd = end, rangeStepMs = stepMs) => {
18757
+ const densifyHoldLast = (values, rangeStart = start, rangeEnd = end, rangeStepMs = stepMs, maxHoldMs = Infinity) => {
18549
18758
  const rStart = Number(rangeStart);
18550
18759
  const rEnd = Number(rangeEnd);
18551
18760
  const rStep = Number(rangeStepMs);
@@ -18572,12 +18781,15 @@ app.get('/api/history', async (req, res) => {
18572
18781
  const out = [];
18573
18782
  let havePrev = false;
18574
18783
  let prev = null;
18784
+ let prevTs = -Infinity;
18575
18785
  for (let i = 0; i <= n; i++) {
18576
18786
  if (byIdx.has(i)) {
18577
18787
  prev = byIdx.get(i);
18578
18788
  havePrev = true;
18789
+ prevTs = rStart + i * rStep;
18579
18790
  }
18580
- out.push([rStart + i * rStep, havePrev ? prev : null]);
18791
+ const ts = rStart + i * rStep;
18792
+ out.push([ts, havePrev && ts - prevTs <= maxHoldMs ? prev : null]);
18581
18793
  }
18582
18794
 
18583
18795
  // Ensure the series reaches exactly `rangeEnd` so the chart does not visually "stop"
@@ -18586,7 +18798,7 @@ app.get('/api/history', async (req, res) => {
18586
18798
  if (out.length) {
18587
18799
  const lastTs = out[out.length - 1][0];
18588
18800
  if (Number.isFinite(lastTs) && lastTs < rEnd) {
18589
- out.push([rEnd, havePrev ? prev : null]);
18801
+ out.push([rEnd, havePrev && rEnd - prevTs <= maxHoldMs ? prev : null]);
18590
18802
  }
18591
18803
  }
18592
18804
  return out;
@@ -18691,11 +18903,21 @@ app.get('/api/history', async (req, res) => {
18691
18903
  const cacheKey = `${cacheId}|${queryStart}|${queryEnd}|${queryStepMs}`;
18692
18904
  if (requestSeriesCache.has(cacheKey)) return requestSeriesCache.get(cacheKey);
18693
18905
  const options = { start: queryStart, end: queryEnd, step: queryStepMs, aggregate: 'average', addId: false, ignoreNull: true };
18906
+ // Canonical power/SoC states are exported periodically even when unchanged
18907
+ // (tolAbs=0, Influx changesOnly=false). Missing later buckets are unknown,
18908
+ // not permission to extend an old measurement across a device outage.
18909
+ // Explicit legacy mappings and tariff states can be on-change: keep their
18910
+ // established sparse-series contract instead of inventing a freshness age.
18911
+ const periodicHistory = ['core.', 'evcs.', 'consumers.', 'producers.']
18912
+ .some(part => sid?.startsWith(`${this.namespace}.historie.${part}`));
18913
+ const exportRaw = Number(this.config?.history?.exportIntervalMs || this.config?.history?.intervalMs);
18914
+ const exportMs = Math.max(600000, Math.min(3600000, Number.isFinite(exportRaw) ? Math.round(exportRaw) : 600000));
18915
+ const maxHoldMs = periodicHistory ? Math.max(exportMs, queryStepMs) : Infinity;
18694
18916
  const promise = !sid ? Promise.resolve({ id: sid || id, values: [] }) : historyRequest(
18695
- callback => this.sendTo(inst, 'getHistory', { id: sid, options }, callback),
18917
+ callback => this._nwDispatchHistory(inst, { id: sid, options }, callback),
18696
18918
  result => ({ id: sid, values: densifyHoldLast(
18697
18919
  this._nwNormalizeHistoryResult(result, 10000).map(point => [point.ts, point.val]),
18698
- queryStart, queryEnd, queryStepMs,
18920
+ queryStart, queryEnd, queryStepMs, maxHoldMs,
18699
18921
  ) }),
18700
18922
  );
18701
18923
 
@@ -18726,7 +18948,7 @@ app.get('/api/history', async (req, res) => {
18726
18948
  const netFeeActiveNow = !!(this.stateCache && this.stateCache['settings.netFeeEnabled'] && this.stateCache['settings.netFeeEnabled'].value);
18727
18949
  const pricingActiveNow = !!(dynamicTariffActiveNow || netFeeActiveNow);
18728
18950
  const wantSocSeries = stepMs <= (10 * 60 * 1000);
18729
- const manualGrossPriceNow = Number(this.stateCache?.['settings.price']?.value);
18951
+ const manualGrossPriceNow = tariffPriceNumber(this.stateCache?.['settings.price']?.value);
18730
18952
  const grossPriceCandidates = [
18731
18953
  `${this.namespace}.historie.tariff.providerCurrentEurPerKwh`,
18732
18954
  `${this.namespace}.tarif.preisAktuellEurProKwh`,
@@ -18820,13 +19042,13 @@ app.get('/api/history', async (req, res) => {
18820
19042
  : ((!dynamicTariffActive && Number.isFinite(manualGrossPrice)) ? manualGrossPrice : rawTotal);
18821
19043
  if (!Number.isFinite(total) && Number.isFinite(rawBase)) total = rawBase + netFee;
18822
19044
  if (!Number.isFinite(total) && Number.isFinite(manualGrossPrice)) total = manualGrossPrice;
18823
- if (!Number.isFinite(total)) total = 0;
18824
- total = Math.max(-5, total);
19045
+ // These archived values already use EUR/kWh. Keep genuine signed
19046
+ // prices; neither missing values nor a lower clamp create a quote.
19047
+ if (!Number.isFinite(total)) total = null;
18825
19048
 
18826
- let base = total - netFee;
19049
+ let base = total === null ? null : total - netFee;
18827
19050
  if (!Number.isFinite(base) && Number.isFinite(rawBase)) base = rawBase;
18828
19051
  if (!Number.isFinite(base)) base = total;
18829
- base = Math.max(-5, base);
18830
19052
 
18831
19053
  baseOut.push([ts, base]);
18832
19054
  totalOut.push([ts, total]);
@@ -18888,6 +19110,7 @@ app.get('/api/history', async (req, res) => {
18888
19110
  lpIds.push(`${this.namespace}.historie.evcs.lp${i}.powerW`);
18889
19111
  }
18890
19112
  const sumByTs = new Map();
19113
+ const samplesByTs = new Map();
18891
19114
  // Avoid keeping up to 200 full charge-point arrays alive together.
18892
19115
  // Eight parallel reads still share the whole request deadline.
18893
19116
  for (let offset = 0; offset < lpIds.length; offset += 8) {
@@ -18895,18 +19118,21 @@ app.get('/api/history', async (req, res) => {
18895
19118
  const lpSeries = await Promise.all(batchIds.map(id => ask(id)));
18896
19119
  for (const series of lpSeries) {
18897
19120
  for (const point of series.values) {
18898
- if (point[1] === null || point[1] === undefined) continue;
18899
19121
  const ts = Number(point[0]);
19122
+ if (!Number.isFinite(ts)) continue;
19123
+ if (!sumByTs.has(ts)) sumByTs.set(ts, 0);
19124
+ if (point[1] === null || point[1] === undefined) continue;
18900
19125
  const value = Number(point[1]);
18901
19126
  if (!Number.isFinite(ts) || !Number.isFinite(value)) continue;
18902
19127
  sumByTs.set(ts, (sumByTs.get(ts) || 0) + value);
19128
+ samplesByTs.set(ts, (samplesByTs.get(ts) || 0) + 1);
18903
19129
  }
18904
19130
  }
18905
19131
  for (const id of batchIds) requestSeriesCache.delete(`${id}|${start}|${end}|${Math.max(60000, stepS * 1000)}`);
18906
19132
  }
18907
19133
  const vals = Array.from(sumByTs.entries())
18908
19134
  .sort((a, b) => a[0] - b[0])
18909
- .map(([ts, v]) => [ts, v]);
19135
+ .map(([ts, v]) => [ts, samplesByTs.get(ts) === count ? v : null]);
18910
19136
  if (vals.length >= 2) {
18911
19137
  evcs.id = `${this.namespace}.historie.evcs.sum.powerW`;
18912
19138
  evcs.values = vals;
@@ -18945,7 +19171,7 @@ const readCounterPoint = (id, newest) => {
18945
19171
  count: 1, returnNewestEntries: !!newest, removeBorderValues: false,
18946
19172
  };
18947
19173
  return historyRequest(
18948
- callback => this.sendTo(inst, 'getHistory', { id, options }, callback),
19174
+ callback => this._nwDispatchHistory(inst, { id, options }, callback),
18949
19175
  result => {
18950
19176
  const points = this._nwNormalizeHistoryResult(result, 10000);
18951
19177
  return points.length ? (newest ? points[points.length - 1] : points[0]) : null;
@@ -19102,21 +19328,25 @@ const buildEnergyExact = async () => {
19102
19328
  if (count > 0) {
19103
19329
  const query = { start, end: energyExactEnd, stepMs: energyExactStepMs };
19104
19330
  const sumByTs = new Map();
19331
+ const samplesByTs = new Map();
19105
19332
  for (let offset = 0; offset < count; offset += 8) {
19106
19333
  const ids = Array.from({ length: Math.min(8, count - offset) }, (_value, index) => `${this.namespace}.historie.evcs.lp${offset + index + 1}.powerW`);
19107
19334
  const lpSeries = await Promise.all(ids.map(id => ask(id, query)));
19108
19335
  for (const series of lpSeries) {
19109
19336
  for (const row of series.values) {
19110
- if (row[1] === null || row[1] === undefined) continue;
19111
19337
  const ts = Number(row[0]);
19338
+ if (!Number.isFinite(ts) || ts > energyExactEnd) continue;
19339
+ if (!sumByTs.has(ts)) sumByTs.set(ts, 0);
19340
+ if (row[1] === null || row[1] === undefined) continue;
19112
19341
  const value = Number(row[1]);
19113
19342
  if (!Number.isFinite(ts) || !Number.isFinite(value) || ts > energyExactEnd) continue;
19114
19343
  sumByTs.set(ts, (sumByTs.get(ts) || 0) + value);
19344
+ samplesByTs.set(ts, (samplesByTs.get(ts) || 0) + 1);
19115
19345
  }
19116
19346
  }
19117
19347
  for (const id of ids) requestSeriesCache.delete(`${id}|${start}|${energyExactEnd}|${energyExactStepMs}`);
19118
19348
  }
19119
- const vals = Array.from(sumByTs.entries()).sort((a, b) => a[0] - b[0]).map(([ts, v]) => [ts, v]);
19349
+ const vals = Array.from(sumByTs.entries()).sort((a, b) => a[0] - b[0]).map(([ts, v]) => [ts, samplesByTs.get(ts) === count ? v : null]);
19120
19350
  if (vals.length >= 2) evExact = clipSeriesForIntegration({ id: `${this.namespace}.historie.evcs.sum.powerW`, values: vals }, energyExactEnd);
19121
19351
  }
19122
19352
  }
@@ -19147,7 +19377,8 @@ if (performance.now() >= historyDeadlineMs) throw Object.assign(new Error('EOS_H
19147
19377
  active: !!((this.stateCache && this.stateCache['settings.dynamicTariff'] && this.stateCache['settings.dynamicTariff'].value) || (this.stateCache && this.stateCache['settings.netFeeEnabled'] && this.stateCache['settings.netFeeEnabled'].value)),
19148
19378
  dynamicTariff: dynamicTariffActiveNow,
19149
19379
  netFeeEnabled: !!(this.stateCache && this.stateCache['settings.netFeeEnabled'] && this.stateCache['settings.netFeeEnabled'].value),
19150
- historyReady: [normalizedPricingSeries.base, priceNetFee, normalizedPricingSeries.total].some(s => Array.isArray(s && s.values) && s.values.length >= 2),
19380
+ historyReady: [normalizedPricingSeries.base, normalizedPricingSeries.total].some(s => Array.isArray(s && s.values)
19381
+ && s.values.some(point => Number.isFinite(tariffPriceNumber(point?.[1])))),
19151
19382
  series: { base: normalizedPricingSeries.base, netFee: priceNetFee, total: normalizedPricingSeries.total },
19152
19383
  };
19153
19384
  return { ok:true, start, end, step: stepS, series: out, extras: { consumers: extraConsumers, producers: extraProducers }, energy, energyExact, pricing };
@@ -19179,6 +19410,9 @@ if (performance.now() >= historyDeadlineMs) throw Object.assign(new Error('EOS_H
19179
19410
  app.get('/api/tariff/report', async (req, res) => {
19180
19411
  try {
19181
19412
  const intervalMs = 15 * 60 * 1000;
19413
+ const retentionTargetDays = 730;
19414
+ const maxDurationMs = retentionTargetDays * 24 * 3600 * 1000;
19415
+ const maxReportBuckets = Math.ceil(maxDurationMs / intervalMs) + 1;
19182
19416
  /**
19183
19417
  * Code-Teil: parseTs
19184
19418
  * Zweck: Wandelt Rohwerte in ein stabiles internes Format um, damit spätere Logik konsistent arbeiten kann.
@@ -19187,6 +19421,7 @@ if (performance.now() >= historyDeadlineMs) throw Object.assign(new Error('EOS_H
19187
19421
  */
19188
19422
  const parseTs = (raw, { endOfDay = false } = {}) => {
19189
19423
  if (raw === null || raw === undefined || raw === '') return null;
19424
+ if (typeof raw !== 'number' && typeof raw !== 'string') return null;
19190
19425
  if (typeof raw === 'number' && Number.isFinite(raw)) return raw < 1e12 ? raw * 1000 : raw;
19191
19426
  const s = String(raw).trim();
19192
19427
  if (!s) return null;
@@ -19198,6 +19433,7 @@ if (performance.now() >= historyDeadlineMs) throw Object.assign(new Error('EOS_H
19198
19433
  if (/^\d{4}-\d{2}-\d{2}$/.test(s)) {
19199
19434
  const [y, m, d] = s.split('-').map((n) => Number(n));
19200
19435
  const dt = new Date(y, m - 1, d, 0, 0, 0, 0);
19436
+ if (dt.getFullYear() !== y || dt.getMonth() !== m - 1 || dt.getDate() !== d) return null;
19201
19437
  if (endOfDay) dt.setHours(23, 59, 59, 999);
19202
19438
  return dt.getTime();
19203
19439
  }
@@ -19226,48 +19462,46 @@ if (performance.now() >= historyDeadlineMs) throw Object.assign(new Error('EOS_H
19226
19462
  * TypeScript: Parameter, Rückgabewert und verwendete Config-/State-Objekte später explizit typisieren.
19227
19463
  */
19228
19464
  const defaultFrom = (() => { const d = new Date(now); d.setHours(0, 0, 0, 0); return d.getTime(); })();
19229
- const requestedFrom = parseTs(req.query.from) ?? defaultFrom;
19230
- const requestedTo = parseTs(req.query.to, { endOfDay: true }) ?? now;
19465
+ const requestedFrom = req.query.from === undefined ? defaultFrom : parseTs(req.query.from);
19466
+ const requestedTo = req.query.to === undefined ? now : parseTs(req.query.to, { endOfDay: true });
19231
19467
  const start = alignDown(requestedFrom);
19232
- const end = Math.max(start + intervalMs, alignUp(requestedTo));
19468
+ const end = alignUp(requestedTo);
19469
+ const bucketCount = Math.ceil((end - start) / intervalMs);
19470
+ // Keep the existing two-year report horizon, including one boundary
19471
+ // bucket, but reject malformed or unbounded requests before any IO.
19472
+ if (!Number.isSafeInteger(requestedFrom) || !Number.isSafeInteger(requestedTo) || requestedFrom < 0 ||
19473
+ requestedTo <= requestedFrom || requestedTo > 8640000000000000 || requestedTo - requestedFrom > maxDurationMs ||
19474
+ !Number.isSafeInteger(start) || !Number.isSafeInteger(end) || !Number.isSafeInteger(bucketCount) ||
19475
+ bucketCount < 1 || bucketCount > maxReportBuckets) {
19476
+ return res.status(400).json({ ok: false, error: 'EOS_HISTORY_RANGE_INVALID' });
19477
+ }
19233
19478
  /**
19234
- * Code-Teil: densifyHoldLast
19479
+ * Code-Teil: intervalSeries
19235
19480
  * Zweck: Kapselt einen lokalen Verarbeitungsschritt, damit Aufrufer nicht direkt in Detaildaten eingreifen.
19236
19481
  * Zusammenhang: Teil von Adapterkern: Lifecycle, Webserver, API, States, EMS-Engine; Aufrufstellen und abhängige States/APIs beim Ändern mitprüfen.
19237
19482
  * TypeScript: Parameter, Rückgabewert und verwendete Config-/State-Objekte später explizit typisieren.
19238
19483
  */
19239
- const densifyHoldLast = (series) => {
19484
+ const intervalSeries = (series) => {
19240
19485
  const src = Array.isArray(series) ? series : [];
19241
- const count = Math.max(1, Math.ceil((end - start) / intervalMs));
19242
19486
  const byIdx = new Map();
19243
- let havePrev = false;
19244
- let prev = null;
19245
19487
  for (const p of src) {
19246
19488
  const ts = this._nwNormTsMs(p && p.ts);
19247
- const val = Number(p && p.val);
19248
- if (!Number.isFinite(ts) || !Number.isFinite(val)) continue;
19249
- if (ts < start) {
19250
- prev = val;
19251
- havePrev = true;
19252
- continue;
19253
- }
19254
- const idx = Math.round((ts - start) / intervalMs);
19255
- if (idx < 0 || idx >= count) continue;
19489
+ const val = tariffPriceNumber(p && p.val);
19490
+ if (!Number.isFinite(ts) || ts < start || ts >= end) continue;
19491
+ const idx = Math.floor((ts - start) / intervalMs);
19256
19492
  byIdx.set(idx, val);
19257
19493
  }
19258
19494
  const out = [];
19259
- for (let i = 0; i < count; i++) {
19260
- if (byIdx.has(i)) {
19261
- prev = byIdx.get(i);
19262
- havePrev = true;
19263
- }
19264
- out.push({ ts: start + (i * intervalMs), val: havePrev ? prev : null });
19495
+ for (let i = 0; i < bucketCount; i++) {
19496
+ // Missing averages are gaps, not zero and not another quarter's value.
19497
+ out.push({ ts: start + (i * intervalMs), val: byIdx.has(i) ? byIdx.get(i) : null });
19265
19498
  }
19266
19499
  return out;
19267
19500
  };
19268
19501
 
19269
19502
  const dynamicTariffActive = !!(this.stateCache?.['settings.dynamicTariff']?.value);
19270
- const manualGrossPrice = Number(this.stateCache?.['settings.price']?.value);
19503
+ const netFeeEnabled = !!(this.stateCache?.['settings.netFeeEnabled']?.value);
19504
+ const manualGrossPrice = tariffPriceNumber(this.stateCache?.['settings.price']?.value);
19271
19505
  const grossPriceCandidates = [
19272
19506
  `${this.namespace}.historie.tariff.providerCurrentEurPerKwh`,
19273
19507
  `${this.namespace}.tarif.preisAktuellEurProKwh`,
@@ -19278,14 +19512,14 @@ if (performance.now() >= historyDeadlineMs) throw Object.assign(new Error('EOS_H
19278
19512
  * Zusammenhang: Teil von Adapterkern: Lifecycle, Webserver, API, States, EMS-Engine; Aufrufstellen und abhängige States/APIs beim Ändern mitprüfen.
19279
19513
  * TypeScript: Parameter, Rückgabewert und verwendete Config-/State-Objekte später explizit typisieren.
19280
19514
  */
19281
- const seriesFor = async (name) => densifyHoldLast(await this._nwGetHistoryAvgSeriesAny(this._nwGetHistoryDpCandidates(name), Math.max(0, start - intervalMs), end, intervalMs));
19515
+ const seriesFor = async (name) => intervalSeries(await this._nwGetHistoryAvgSeriesAny(this._nwGetHistoryDpCandidates(name), start, end, intervalMs));
19282
19516
  /**
19283
19517
  * Code-Teil: seriesForIds
19284
19518
  * Zweck: Kapselt einen lokalen Verarbeitungsschritt, damit Aufrufer nicht direkt in Detaildaten eingreifen.
19285
19519
  * Zusammenhang: Teil von Adapterkern: Lifecycle, Webserver, API, States, EMS-Engine; Aufrufstellen und abhängige States/APIs beim Ändern mitprüfen.
19286
19520
  * TypeScript: Parameter, Rückgabewert und verwendete Config-/State-Objekte später explizit typisieren.
19287
19521
  */
19288
- const seriesForIds = async (ids) => densifyHoldLast(await this._nwGetHistoryAvgSeriesAny(ids, Math.max(0, start - intervalMs), end, intervalMs));
19522
+ const seriesForIds = async (ids) => intervalSeries(await this._nwGetHistoryAvgSeriesAny(ids, start, end, intervalMs));
19289
19523
  const [baseSeries, netFeeSeries, totalSeries, grossSeries, buySeries] = await Promise.all([
19290
19524
  seriesFor('priceBase'),
19291
19525
  seriesFor('priceNetFee'),
@@ -19294,36 +19528,31 @@ if (performance.now() >= historyDeadlineMs) throw Object.assign(new Error('EOS_H
19294
19528
  seriesFor('gridBuyPower'),
19295
19529
  ]);
19296
19530
 
19297
- const bucketCount = Math.max(1, Math.ceil((end - start) / intervalMs));
19298
19531
  const intervals = [];
19299
19532
  for (let i = 0; i < bucketCount; i++) {
19300
19533
  const rowStart = start + (i * intervalMs);
19301
19534
  const rowEnd = rowStart + intervalMs;
19302
- const rawBase = Number(baseSeries[i] && baseSeries[i].val);
19303
- const rawNet = Number(netFeeSeries[i] && netFeeSeries[i].val);
19304
- const rawTotal = Number(totalSeries[i] && totalSeries[i].val);
19305
- const rawGross = Number(grossSeries[i] && grossSeries[i].val);
19306
- const rawBuy = Number(buySeries[i] && buySeries[i].val);
19307
-
19308
- let netFee = Number.isFinite(rawNet) ? Math.max(0, rawNet) : 0;
19309
- let total = Number.isFinite(rawGross)
19310
- ? rawGross
19311
- : ((!dynamicTariffActive && Number.isFinite(manualGrossPrice)) ? manualGrossPrice : rawTotal);
19312
- if (!Number.isFinite(total) && Number.isFinite(rawBase)) total = rawBase + netFee;
19313
- if (!Number.isFinite(total) && Number.isFinite(manualGrossPrice)) total = manualGrossPrice;
19314
- if (!Number.isFinite(total)) total = 0;
19315
- total = Math.max(-5, total);
19316
-
19317
- let base = total - netFee;
19318
- if (!Number.isFinite(base) && Number.isFinite(rawBase)) base = rawBase;
19319
- if (!Number.isFinite(base)) base = total;
19320
- base = Math.max(-5, base);
19321
-
19322
- const importAvgW = Number.isFinite(rawBuy) ? Math.max(0, rawBuy) : 0;
19323
- const importKwh = (importAvgW * intervalMs) / 3600000000;
19324
- const baseCostEur = importKwh * base;
19325
- const netFeeCostEur = importKwh * netFee;
19326
- const totalCostEur = importKwh * total;
19535
+ const rawBase = tariffPriceNumber(baseSeries.at(i)?.val);
19536
+ const rawNet = tariffPriceNumber(netFeeSeries.at(i)?.val);
19537
+ const rawTotal = tariffPriceNumber(totalSeries.at(i)?.val);
19538
+ const rawGross = tariffPriceNumber(grossSeries.at(i)?.val);
19539
+ const rawBuy = tariffPriceNumber(buySeries.at(i)?.val);
19540
+
19541
+ const netFee = Number.isFinite(rawNet) ? Math.max(0, rawNet) : netFeeEnabled ? null : 0;
19542
+ let total = Number.isFinite(rawGross) ? rawGross : rawTotal;
19543
+ if (!Number.isFinite(total) && Number.isFinite(rawBase) && Number.isFinite(netFee)) total = rawBase + netFee;
19544
+ const configuredPriceFallback = !Number.isFinite(total) && !dynamicTariffActive && Number.isFinite(manualGrossPrice);
19545
+ if (configuredPriceFallback) total = manualGrossPrice;
19546
+
19547
+ const base = Number.isFinite(total) && Number.isFinite(netFee) ? total - netFee : rawBase;
19548
+
19549
+ const importAvgW = Number.isFinite(rawBuy) ? Math.max(0, rawBuy) : null;
19550
+ const intervalClosed = rowEnd <= now;
19551
+ const importKwh = Number.isFinite(importAvgW) && intervalClosed ? (importAvgW * intervalMs) / 3600000000 : null;
19552
+ const cost = price => Number.isFinite(importKwh) && Number.isFinite(price) ? importKwh * price : null;
19553
+ const baseCostEur = cost(base);
19554
+ const netFeeCostEur = cost(netFee);
19555
+ const totalCostEur = cost(total);
19327
19556
 
19328
19557
  intervals.push({
19329
19558
  startTs: rowStart,
@@ -19336,16 +19565,27 @@ if (performance.now() >= historyDeadlineMs) throw Object.assign(new Error('EOS_H
19336
19565
  baseCostEur,
19337
19566
  netFeeCostEur,
19338
19567
  totalCostEur,
19568
+ complete: [baseCostEur, netFeeCostEur, totalCostEur].every(Number.isFinite),
19569
+ intervalClosed,
19570
+ configuredPriceFallback,
19339
19571
  });
19340
19572
  }
19341
- const prices = intervals.map((row) => Number(row.totalEurPerKwh)).filter(Number.isFinite);
19342
- const totalImportKwh = intervals.reduce((sum, row) => sum + (Number(row.importKwh) || 0), 0);
19343
- const totalBaseCost = intervals.reduce((sum, row) => sum + (Number(row.baseCostEur) || 0), 0);
19344
- const totalNetFeeCost = intervals.reduce((sum, row) => sum + (Number(row.netFeeCostEur) || 0), 0);
19345
- const totalCost = intervals.reduce((sum, row) => sum + (Number(row.totalCostEur) || 0), 0);
19346
- const avgPrice = totalImportKwh > 0.0001
19573
+ const prices = intervals.map(row => row.totalEurPerKwh).filter(Number.isFinite);
19574
+ const completeSum = value => intervals.every(row => Number.isFinite(value(row)))
19575
+ ? intervals.reduce((sum, row) => sum + value(row), 0) : null;
19576
+ const totalImportKwh = completeSum(row => row.importKwh);
19577
+ const totalBaseCost = completeSum(row => row.baseCostEur);
19578
+ const totalNetFeeCost = completeSum(row => row.netFeeCostEur);
19579
+ const totalCost = completeSum(row => row.totalCostEur);
19580
+ const avgPrice = !Number.isFinite(totalImportKwh) || !Number.isFinite(totalCost) ? null : totalImportKwh > 0.0001
19347
19581
  ? (totalCost / totalImportKwh)
19348
- : (prices.length ? prices.reduce((a, b) => a + b, 0) / prices.length : null);
19582
+ : (prices.length === bucketCount ? prices.reduce((a, b) => a + b, 0) / prices.length : null);
19583
+ const completeIntervals = intervals.filter(row => row.complete).length;
19584
+ const coverage = { complete: completeIntervals === bucketCount, completeIntervals,
19585
+ missingIntervals: bucketCount - completeIntervals, priceIntervals: prices.length,
19586
+ importIntervals: intervals.filter(row => Number.isFinite(row.importKwh)).length,
19587
+ openIntervals: intervals.filter(row => !row.intervalClosed).length,
19588
+ configuredPriceIntervals: intervals.filter(row => row.configuredPriceFallback).length };
19349
19589
 
19350
19590
  const historyInstance = String(this._nwGetHistoryInstance() || '').trim();
19351
19591
  res.json({
@@ -19360,17 +19600,19 @@ if (performance.now() >= historyDeadlineMs) throw Object.assign(new Error('EOS_H
19360
19600
  netFeeEnabled: !!(this.stateCache?.['settings.netFeeEnabled']?.value),
19361
19601
  historyInstance,
19362
19602
  historyReady: !!historyInstance,
19363
- retentionTargetDays: 730,
19603
+ retentionTargetDays,
19604
+ coverage,
19364
19605
  },
19365
19606
  summary: {
19366
- minPrice: prices.length ? Math.min(...prices) : null,
19367
- maxPrice: prices.length ? Math.max(...prices) : null,
19607
+ minPrice: prices.length ? prices.reduce((a, b) => Math.min(a, b), Infinity) : null,
19608
+ maxPrice: prices.length ? prices.reduce((a, b) => Math.max(a, b), -Infinity) : null,
19368
19609
  avgPrice,
19369
19610
  importKwh: totalImportKwh,
19370
19611
  baseCost: totalBaseCost,
19371
19612
  netFeeCost: totalNetFeeCost,
19372
19613
  totalCost,
19373
19614
  intervals: intervals.length,
19615
+ complete: coverage.complete,
19374
19616
  },
19375
19617
  intervals,
19376
19618
  });
@@ -19401,6 +19643,7 @@ if (performance.now() >= historyDeadlineMs) throw Object.assign(new Error('EOS_H
19401
19643
  if (/^\d{4}-\d{2}-\d{2}$/.test(s)) {
19402
19644
  const [y, m, d] = s.split('-').map((n) => Number(n));
19403
19645
  const dt = new Date(y, m - 1, d, 0, 0, 0, 0);
19646
+ if (dt.getFullYear() !== y || dt.getMonth() !== m - 1 || dt.getDate() !== d) return null;
19404
19647
  if (endOfDay) dt.setHours(23, 59, 59, 999);
19405
19648
  return dt.getTime();
19406
19649
  }
@@ -19409,10 +19652,13 @@ if (performance.now() >= historyDeadlineMs) throw Object.assign(new Error('EOS_H
19409
19652
  };
19410
19653
 
19411
19654
  const now = Date.now();
19412
- const requestedFrom = parseTs(req.query.from) ?? (now - (30 * 24 * 3600 * 1000));
19413
- const requestedTo = parseTs(req.query.to, { endOfDay: true }) ?? now;
19655
+ const requestedFrom = req.query.from === undefined ? now - (30 * 24 * 3600 * 1000) : parseTs(req.query.from);
19656
+ const requestedTo = req.query.to === undefined ? now : parseTs(req.query.to, { endOfDay: true });
19414
19657
  const start = requestedFrom;
19415
- const end = Math.max(start + 60000, requestedTo);
19658
+ const end = requestedTo;
19659
+ if (!Number.isSafeInteger(start) || !Number.isSafeInteger(end) || start < 0 || end <= start || end - start > 730 * 86400000) {
19660
+ return res.status(400).json({ ok: false, error: 'EOS_HISTORY_RANGE_INVALID' });
19661
+ }
19416
19662
  const historyInstance = String(this._nwGetHistoryInstance() || '').trim();
19417
19663
  /**
19418
19664
  * Code-Teil: getRawHistory
@@ -19420,9 +19666,10 @@ if (performance.now() >= historyDeadlineMs) throw Object.assign(new Error('EOS_H
19420
19666
  * Zusammenhang: Teil von Adapterkern: Lifecycle, Webserver, API, States, EMS-Engine; Aufrufstellen und abhängige States/APIs beim Ändern mitprüfen.
19421
19667
  * TypeScript: Parameter, Rückgabewert und verwendete Config-/State-Objekte später explizit typisieren.
19422
19668
  */
19423
- const getRawHistory = (id) => new Promise((resolve) => {
19669
+ const getRawHistory = (id) => new Promise((resolve, reject) => {
19670
+ const unavailable = () => Object.assign(new Error('EOS_HISTORY_UNAVAILABLE'), { code: 'EOS_HISTORY_UNAVAILABLE' });
19424
19671
  const sid = this._nwTrimId(id);
19425
- if (!historyInstance || !sid) return resolve([]);
19672
+ if (!historyInstance || !sid) return reject(unavailable());
19426
19673
  const spanMs = Math.max(1, end - start);
19427
19674
  const approxCount = Math.max(200, Math.min(50000, Math.ceil(spanMs / 60000) + 500));
19428
19675
  const options = {
@@ -19439,13 +19686,15 @@ if (performance.now() >= historyDeadlineMs) throw Object.assign(new Error('EOS_H
19439
19686
  const timer = setTimeout(() => {
19440
19687
  if (done) return;
19441
19688
  done = true;
19442
- resolve([]);
19443
- }, 8000);
19689
+ reject(unavailable());
19690
+ }, 5000);
19444
19691
  try {
19445
- this.sendTo(historyInstance, 'getHistory', { id: sid, options }, (resu) => {
19692
+ this._nwDispatchHistory(historyInstance, { id: sid, options }, (resu) => {
19446
19693
  if (done) return;
19447
19694
  done = true;
19448
19695
  clearTimeout(timer);
19696
+ if (resu?.error) return reject(unavailable());
19697
+ try {
19449
19698
  let outArr = [];
19450
19699
  if (Array.isArray(resu)) outArr = resu;
19451
19700
  else if (resu && Array.isArray(resu.result)) {
@@ -19455,7 +19704,8 @@ if (performance.now() >= historyDeadlineMs) throw Object.assign(new Error('EOS_H
19455
19704
  outArr = resu.series[0].values.map((v) => ({ ts: v[0], val: v[1] }));
19456
19705
  } else if (resu && Array.isArray(resu.data)) {
19457
19706
  outArr = resu.data;
19458
- }
19707
+ } else return reject(unavailable());
19708
+ if (outArr.length > 50000) return reject(unavailable());
19459
19709
  const norm = (outArr || []).map((p) => {
19460
19710
  const tRaw = Array.isArray(p) ? p[0] : (p.ts ?? p.time ?? p.t ?? p[0]);
19461
19711
  const vRaw = Array.isArray(p) ? p[1] : (p.val ?? p.value ?? p[1]);
@@ -19464,10 +19714,12 @@ if (performance.now() >= historyDeadlineMs) throw Object.assign(new Error('EOS_H
19464
19714
  return { ts, value: vRaw };
19465
19715
  }).filter(Boolean).sort((a, b) => a.ts - b.ts);
19466
19716
  resolve(norm);
19717
+ } catch (_error) { reject(unavailable()); }
19467
19718
  });
19468
19719
  } catch (_e) {
19720
+ done = true;
19469
19721
  clearTimeout(timer);
19470
- resolve([]);
19722
+ reject(unavailable());
19471
19723
  }
19472
19724
  });
19473
19725
 
@@ -19538,6 +19790,7 @@ if (performance.now() >= historyDeadlineMs) throw Object.assign(new Error('EOS_H
19538
19790
  events,
19539
19791
  });
19540
19792
  } catch (e) {
19793
+ if (e?.code === 'EOS_HISTORY_UNAVAILABLE') return res.status(503).json({ ok: false, error: e.code });
19541
19794
  res.json({ ok: false, error: 'internal_error' });
19542
19795
  }
19543
19796
  });
@@ -19580,6 +19833,7 @@ const nwBuildEvcsReport = async (query = {}) => {
19580
19833
  if (/^\d{4}-\d{2}-\d{2}$/.test(s)) {
19581
19834
  const [y, m, d] = s.split('-').map(n => Number(n));
19582
19835
  const dt = new Date(y, m - 1, d, 0, 0, 0, 0);
19836
+ if (dt.getFullYear() !== y || dt.getMonth() !== m - 1 || dt.getDate() !== d) return null;
19583
19837
  if (endOfDay) dt.setHours(23, 59, 59, 999);
19584
19838
  return dt.getTime();
19585
19839
  }
@@ -19595,14 +19849,19 @@ const nwBuildEvcsReport = async (query = {}) => {
19595
19849
  const defFrom = nowMs - 7 * 24 * 3600 * 1000;
19596
19850
  const defTo = nowMs;
19597
19851
 
19598
- const fromQ = parseTs((query.from !== undefined ? query.from : defFrom)) ?? defFrom;
19599
- const toQ = parseTs((query.to !== undefined ? query.to : defTo), { endOfDay: true }) ?? defTo;
19852
+ const fromQ = parseTs(query.from !== undefined ? query.from : defFrom);
19853
+ const toQ = parseTs(query.to !== undefined ? query.to : defTo, { endOfDay: true });
19854
+ const rangeFailure = () => Object.assign(new Error('EOS_HISTORY_RANGE_INVALID'), { code: 'EOS_HISTORY_RANGE_INVALID' });
19855
+ if (!Number.isSafeInteger(fromQ) || !Number.isSafeInteger(toQ) || fromQ < 0 || toQ < fromQ) throw rangeFailure();
19600
19856
 
19601
19857
  // normalize to full local days
19602
19858
  const d0 = new Date(fromQ); d0.setHours(0, 0, 0, 0);
19603
19859
  const d1 = new Date(toQ); d1.setHours(23, 59, 59, 999);
19604
19860
  const start = +d0;
19605
19861
  const end = +d1;
19862
+ // Limit calendar days before allocation, including DST transition days.
19863
+ const calendarDays = (Date.UTC(d1.getFullYear(), d1.getMonth(), d1.getDate()) - Date.UTC(d0.getFullYear(), d0.getMonth(), d0.getDate())) / 86400000 + 1;
19864
+ if (!Number.isSafeInteger(start) || !Number.isSafeInteger(end) || !Number.isInteger(calendarDays) || calendarDays < 1 || calendarDays > 730) throw rangeFailure();
19606
19865
  /**
19607
19866
  * Code-Teil: dayKeyOf
19608
19867
  * Zweck: Kapselt einen lokalen Verarbeitungsschritt, damit Aufrufer nicht direkt in Detaildaten eingreifen.
@@ -19678,7 +19937,7 @@ const nwBuildEvcsReport = async (query = {}) => {
19678
19937
  * Zusammenhang: Gehört zu ioBroker-Adapterkern (Adapter-Lifecycle, Webserver, REST-/SSE-API, State-Anlage, Lizenz und EMS-Engine) und wird von benachbarten UI-/API-/EMS-Bausteinen genutzt.
19679
19938
  * Wartung/TypeScript: Änderungen können Adapterstart, APIs, States und Webserver beeinflussen; unload/connection immer mittesten. Beim TS-Umbau Parameter, Rückgabe und genutzte State-/Config-Objekte explizit typisieren.
19680
19939
  */
19681
- const getHist = (id, startMs, endMs, aggregate = 'none', step = 0) => new Promise(resolve => {
19940
+ const getHist = (id, startMs, endMs, aggregate = 'none', step = 0) => new Promise((resolve, reject) => {
19682
19941
  if (!id) return resolve([]);
19683
19942
  const agg = aggregate || 'none';
19684
19943
  const spanMs = Number(endMs) - Number(startMs);
@@ -19698,7 +19957,8 @@ const nwBuildEvcsReport = async (query = {}) => {
19698
19957
  if (wantsStep) options.step = stepMs;
19699
19958
 
19700
19959
  try {
19701
- this.sendTo(inst, 'getHistory', { id, options }, (resu) => {
19960
+ this._nwDispatchHistory(inst, { id, options }, (resu) => {
19961
+ if (resu?.error) return reject(Object.assign(new Error('EOS_HISTORY_UNAVAILABLE'), { code: 'EOS_HISTORY_UNAVAILABLE' }));
19702
19962
  let outArr = [];
19703
19963
  if (Array.isArray(resu)) outArr = resu;
19704
19964
  else if (resu && Array.isArray(resu.result)) {
@@ -19725,7 +19985,7 @@ const nwBuildEvcsReport = async (query = {}) => {
19725
19985
  resolve(norm);
19726
19986
  });
19727
19987
  } catch (e) {
19728
- resolve([]);
19988
+ reject(Object.assign(new Error('EOS_HISTORY_UNAVAILABLE'), { code: 'EOS_HISTORY_UNAVAILABLE' }));
19729
19989
  }
19730
19990
  });
19731
19991
 
@@ -19888,6 +20148,8 @@ app.get('/api/evcs/report', async (req, res) => {
19888
20148
  const report = await nwBuildEvcsReport(req.query || {});
19889
20149
  res.json({ ok: true, ...report });
19890
20150
  } catch (e) {
20151
+ if (e?.code === 'EOS_HISTORY_RANGE_INVALID') return res.status(400).json({ ok: false, error: e.code });
20152
+ if (e?.code === 'EOS_HISTORY_UNAVAILABLE') return res.status(503).json({ ok: false, error: e.code });
19891
20153
  res.json({ ok: false, error: 'internal_error' });
19892
20154
  }
19893
20155
  });
@@ -20018,6 +20280,8 @@ app.get('/api/evcs/report.csv', async (req, res) => {
20018
20280
  res.setHeader('Content-Disposition', `attachment; filename="${filename}"`);
20019
20281
  res.status(200).send(csv);
20020
20282
  } catch (e) {
20283
+ if (e?.code === 'EOS_HISTORY_RANGE_INVALID') return res.status(400).json({ ok: false, error: e.code });
20284
+ if (e?.code === 'EOS_HISTORY_UNAVAILABLE') return res.status(503).json({ ok: false, error: e.code });
20021
20285
  res.status(500).type('text/plain').send('EVCS CSV Fehler.');
20022
20286
  }
20023
20287
  });
@@ -27235,7 +27499,7 @@ return res.json(out);
27235
27499
  */
27236
27500
  _nwRequestImmediateEmsTick(reason = 'customer-control', delayMs) {
27237
27501
  try {
27238
- if (this._nwShuttingDown) return false;
27502
+ if (!this._nwIsEmsReady()) return false;
27239
27503
  const engine = this.emsEngine;
27240
27504
  if (engine && typeof engine.requestImmediateTick === 'function') {
27241
27505
  if (Number.isFinite(Number(delayMs))) {
@@ -27588,7 +27852,7 @@ return res.json(out);
27588
27852
  */
27589
27853
  setLocalStateWithCache(id, val, ts) {
27590
27854
  const t = Number(ts) || Date.now();
27591
- this.setStateAsync(id, val, true).catch(()=>{});
27855
+ this.setStateAsync(id, { val, ack: true, ts: t }).catch(()=>{});
27592
27856
  try { this.updateValue(id, val, t); } catch(_e) {}
27593
27857
  }
27594
27858
 
@@ -28184,6 +28448,15 @@ return res.json(out);
28184
28448
  * TypeScript: Parameter, Rückgabewert und verwendete Config-/State-Objekte später explizit typisieren.
28185
28449
  */
28186
28450
  async _nwEnsureInfluxCustom(localId, inst, opts = null) {
28451
+ this._nwConfigureHistory();
28452
+ this._nwDirectHistory.register(localId, opts?.changesOnly === true);
28453
+ if (this.config?.history?.provider === 'influxdb2') {
28454
+ const object = await this.getObjectAsync(localId).catch(() => null);
28455
+ const custom = object?.common?.custom;
28456
+ const active = custom && typeof custom === 'object' && Object.entries(custom).some(([id, entry]) => /^influxdb\.\d+$/.test(id) && entry?.enabled === true);
28457
+ this._nwDirectHistory.legacyRecording(localId, !!active);
28458
+ return;
28459
+ }
28187
28460
  try {
28188
28461
  const instance = String(inst || '').trim();
28189
28462
  if (!instance) return;
@@ -30531,8 +30804,8 @@ return res.json(out);
30531
30804
  */
30532
30805
  _nwSetHistorieValue(localId, val, ts, tolAbs = 1) {
30533
30806
  try {
30534
- const n = Number(val);
30535
- if (!Number.isFinite(n)) return;
30807
+ const n = numericMeasurement(val);
30808
+ if (n === null) return;
30536
30809
  if (!this._nwHistorieLast) this._nwHistorieLast = {};
30537
30810
  const last = this._nwHistorieLast[localId];
30538
30811
  const tol = Number.isFinite(Number(tolAbs)) ? Math.max(0, Number(tolAbs)) : 0;
@@ -30806,26 +31079,50 @@ return res.json(out);
30806
31079
  const {
30807
31080
  gridBuyW,
30808
31081
  gridSellW,
31082
+ hasGrid,
30809
31083
  } = this._nwResolveGridImportExportFromCache();
30810
31084
  const historyCoreMaxAgeMs = Math.max(30000, Number(this.config?.settings?.deviceStaleTimeoutSec || 60) * 1000);
30811
- const pvDerivedW = this._nwGetNumberFromCacheFresh('derived.core.pv.totalW', historyCoreMaxAgeMs, null, now);
30812
- const pvW = this._nwGetNumberFromCache('pvPower') ?? this._nwGetNumberFromCache('productionTotal');
30813
- const loadDerivedW = this._nwGetNumberFromCacheFresh('derived.core.building.loadTotalW', historyCoreMaxAgeMs, null, now);
30814
- const loadW = Number.isFinite(Number(loadDerivedW)) ? Number(loadDerivedW) : this._nwGetNumberFromCache('consumptionTotal');
31085
+ // History samples are observations, not a refresh of the last cached value.
31086
+ // Missing timestamps, stale values and missing measurements remain gaps.
31087
+ const readHistory = (key, maxAgeMs = historyCoreMaxAgeMs) => {
31088
+ // Flow slots may supply a cache key. Only own data records are observations:
31089
+ // no prototype lookup, getter invocation, or object path traversal is allowed.
31090
+ if (typeof key !== 'string' || !/^[A-Za-z0-9_.-]{1,256}$/.test(key)
31091
+ || key.split('.').some(part => ['__proto__', 'prototype', 'constructor'].includes(part))
31092
+ || !this.stateCache || typeof this.stateCache !== 'object') return null;
31093
+ const entry = Object.getOwnPropertyDescriptor(this.stateCache, key);
31094
+ if (!entry || !('value' in entry) || !entry.value || typeof entry.value !== 'object') return null;
31095
+ const timestamp = Object.getOwnPropertyDescriptor(entry.value, 'ts');
31096
+ const measurement = Object.getOwnPropertyDescriptor(entry.value, 'value');
31097
+ const quality = Object.getOwnPropertyDescriptor(entry.value, 'q');
31098
+ if (!timestamp || !('value' in timestamp) || !measurement || !('value' in measurement)
31099
+ || (quality && (!('value' in quality) || (quality.value !== undefined && quality.value !== 0)))) return null;
31100
+ const stamp = numericMeasurement(timestamp.value);
31101
+ if (stamp === null || stamp <= 0 || stamp > now || now - stamp > maxAgeMs) return null;
31102
+ return numericMeasurement(measurement.value);
31103
+ };
31104
+ const pvDerivedW = readHistory('derived.core.pv.totalW');
31105
+ const pvW = readHistory('pvPower') ?? readHistory('productionTotal');
31106
+ const loadDerivedW = readHistory('derived.core.building.loadTotalW');
31107
+ const loadW = loadDerivedW !== null ? loadDerivedW : readHistory('consumptionTotal');
30815
31108
  const storageAuthorityHist = (typeof this._nwGetStorageControlAuthority === 'function')
30816
31109
  ? this._nwGetStorageControlAuthority()
30817
31110
  : { selectedTopology: 'none', writerActive: false };
30818
31111
  const selectedStorageTopologyHist = String(storageAuthorityHist.selectedTopology || 'none');
30819
- const storageFlowHist = this._nwResolveBatteryFlowFromCache({ now });
30820
- let chgW = Number(storageFlowHist.chargeW);
30821
- let dchgW = Number(storageFlowHist.dischargeW);
31112
+ const storageFlowHist = this._nwResolveBatteryFlowFromCache({ now, strictStale: true });
31113
+ const storageMissing = ['missing', 'mapped-missing', 'storageFarm-missing-power', 'storageFarm-unavailable'].includes(storageFlowHist.src);
31114
+ const farmPowerAge = storageFlowHist.staleMs && numericMeasurement(storageFlowHist.staleMs.farmPower);
31115
+ const farmPowerStale = selectedStorageTopologyHist === 'farm'
31116
+ && (farmPowerAge === null || farmPowerAge === undefined || farmPowerAge > historyCoreMaxAgeMs);
31117
+ const chgW = storageMissing || farmPowerStale ? null : numericMeasurement(storageFlowHist.chargeW);
31118
+ const dchgW = storageMissing || farmPowerStale ? null : numericMeasurement(storageFlowHist.dischargeW);
30822
31119
  // Mess-/Anzeigehoheit und Speicher-Schreibhoheit sind bewusst getrennt:
30823
31120
  // Ein im Energiefluss manuell zugeordneter SoC-DP muss auch dann in die
30824
31121
  // Historie gelangen, wenn NexoWatt den Speicher nur visualisiert und die
30825
31122
  // Speicherregelung/Farm nicht aktiv ist (z. B. herstellereigene 0-Einspeisung).
30826
31123
  const explicitStorageSocMapped = !!String(historyDps.storageSoc || '').trim();
30827
31124
  const explicitStorageSocValue = explicitStorageSocMapped
30828
- ? this._nwGetNumberFromCache('storageSoc')
31125
+ ? readHistory('storageSoc')
30829
31126
  : null;
30830
31127
  const explicitStorageSocValid = explicitStorageSocMapped
30831
31128
  && explicitStorageSocValue !== null
@@ -30835,21 +31132,22 @@ return res.json(out);
30835
31132
  let soc = explicitStorageSocValid
30836
31133
  ? Math.max(0, Math.min(100, Number(explicitStorageSocValue)))
30837
31134
  : (selectedStorageTopologyHist === 'single'
30838
- ? this._nwGetNumberFromCache('storageSoc')
31135
+ ? readHistory('storageSoc')
30839
31136
  : null);
30840
- const evW = this._nwGetNumberFromCache('evcs.totalPowerW');
31137
+ const evW = readHistory('evcs.totalPowerW');
31138
+ const historyEvAbsent = Number(this.evcsCount) === 0 && !String(historyDps.consumptionEvcs || '').trim();
30841
31139
 
30842
- const gridBuy = Number.isFinite(gridBuyW) ? Math.max(0, gridBuyW) : 0;
30843
- const gridSell = Number.isFinite(gridSellW) ? Math.max(0, gridSellW) : 0;
30844
- const gridNet = gridBuy - gridSell;
31140
+ const gridBuy = hasGrid === true && Number.isFinite(gridBuyW) ? Math.max(0, gridBuyW) : null;
31141
+ const gridSell = hasGrid === true && Number.isFinite(gridSellW) ? Math.max(0, gridSellW) : null;
31142
+ const gridNet = gridBuy !== null && gridSell !== null ? gridBuy - gridSell : null;
30845
31143
 
30846
31144
  // Der bereits abgeleitete PV-Gesamtwert ist die kanonische Quelle für LIVE,
30847
31145
  // Historie und Budgetierung. Nur wenn er fehlt/veraltet ist, wird die Farm-PV
30848
31146
  // hier noch einmal mit dem direkten Anlagen-PV-DP zusammengeführt.
30849
- let pvTotal = Number.isFinite(Number(pvDerivedW))
30850
- ? Math.max(0, Number(pvDerivedW))
30851
- : (Number.isFinite(Number(pvW)) ? Math.max(0, Number(pvW)) : null);
30852
- const pvTotalFromDerived = Number.isFinite(Number(pvDerivedW));
31147
+ let pvTotal = pvDerivedW !== null
31148
+ ? Math.max(0, pvDerivedW)
31149
+ : (pvW !== null ? Math.max(0, pvW) : null);
31150
+ const pvTotalFromDerived = pvDerivedW !== null;
30853
31151
 
30854
31152
  // Historie und LIVE verwenden dieselbe zentrale Farm-PV-Zusammenführung. Dadurch
30855
31153
  // stimmen die aktuellen Energieflüsse, History-States und späteren Energiesummen
@@ -30863,7 +31161,8 @@ return res.json(out);
30863
31161
  && this.config.storage
30864
31162
  && String(this.config.storage.coupling || '').trim().toLowerCase() === 'dc');
30865
31163
 
30866
- if (!pvTotalFromDerived && sfEnabled && typeof this._nwMergeStorageFarmPvWithBase === 'function') {
31164
+ if (!pvTotalFromDerived && sfEnabled && readHistory('storageFarm.totalPvPowerW') !== null
31165
+ && typeof this._nwMergeStorageFarmPvWithBase === 'function') {
30867
31166
  const baseSourceId = String(historyDps.pvPower || historyDps.productionTotal || '').trim();
30868
31167
  const merged = this._nwMergeStorageFarmPvWithBase(pvTotal || 0, {
30869
31168
  now,
@@ -30871,8 +31170,8 @@ return res.json(out);
30871
31170
  baseSourceId,
30872
31171
  });
30873
31172
  pvTotal = Math.max(0, Number(merged.totalW) || 0);
30874
- } else if (singleStorageDcEnabled) {
30875
- const dcValueW = this._nwGetNumberFromCache('speicher.dcPvPowerW');
31173
+ } else if (!pvTotalFromDerived && singleStorageDcEnabled) {
31174
+ const dcValueW = readHistory('speicher.dcPvPowerW');
30876
31175
  if (Number.isFinite(dcValueW) && Number(dcValueW) !== 0) {
30877
31176
  const dcAbs = Math.abs(Number(dcValueW));
30878
31177
  if (pvTotal === null || pvTotal === 0) pvTotal = dcAbs;
@@ -30889,38 +31188,31 @@ return res.json(out);
30889
31188
  // autoritativ und wird nicht durch Writer-/App-Lifecycle auf null gesetzt.
30890
31189
  if (!explicitStorageSocValid) {
30891
31190
  if (selectedStorageTopologyHist === 'farm') {
30892
- const socFarm = farmMetricsHist && Number.isFinite(Number(farmMetricsHist.soc))
30893
- ? Number(farmMetricsHist.soc)
30894
- : this._nwGetNumberFromCache('storageFarm.totalSocOnline');
30895
- const socFarmFallback = Number.isFinite(Number(socFarm))
30896
- ? Number(socFarm)
30897
- : this._nwGetNumberFromCache('storageFarm.totalSoc');
30898
- soc = Number.isFinite(Number(socFarmFallback))
30899
- ? Math.max(0, Math.min(100, Number(socFarmFallback)))
30900
- : null;
31191
+ const socFarm = readHistory('storageFarm.totalSocOnline') ?? readHistory('storageFarm.totalSoc');
31192
+ soc = socFarm !== null ? Math.max(0, Math.min(100, socFarm)) : null;
30901
31193
  } else if (selectedStorageTopologyHist !== 'single') {
30902
31194
  soc = null;
30903
31195
  }
30904
31196
  }
30905
31197
 
30906
31198
  let loadTotal = Number.isFinite(loadW) ? Math.max(0, loadW) : null;
30907
- const chg = Number.isFinite(chgW) ? Math.max(0, chgW) : 0;
30908
- const dchg = Number.isFinite(dchgW) ? Math.max(0, dchgW) : 0;
30909
- const evAbs = Number.isFinite(evW) ? Math.abs(evW) : 0;
31199
+ const chg = Number.isFinite(chgW) ? Math.max(0, chgW) : null;
31200
+ const dchg = Number.isFinite(dchgW) ? Math.max(0, dchgW) : null;
31201
+ const evAbs = Number.isFinite(evW) ? Math.abs(evW) : null;
30910
31202
 
30911
- if (loadTotal === null) {
30912
- const pvUse = pvTotal || 0;
30913
- loadTotal = Math.max(0, pvUse + gridBuy + dchg - gridSell - chg);
31203
+ if (loadTotal === null && pvTotal !== null && gridBuy !== null && gridSell !== null && chg !== null && dchg !== null) {
31204
+ loadTotal = Math.max(0, pvTotal + gridBuy + dchg - gridSell - chg);
30914
31205
  }
30915
31206
 
30916
31207
  // Energiefluss-Display (Rest) = Gesamtverbrauch - EV - optionale Verbraucher
30917
31208
  let extrasConsumersSum = 0;
30918
31209
  for (let i = 1; i <= 10; i++) {
30919
- const v = this._nwGetNumberFromCache(`consumer${i}Power`);
31210
+ const v = readHistory(`consumer${i}Power`);
30920
31211
  if (!Number.isFinite(v)) continue;
30921
31212
  extrasConsumersSum += Math.max(0, Math.abs(v));
30922
31213
  }
30923
- const loadRest = Math.max(0, (loadTotal || 0) - evAbs - extrasConsumersSum);
31214
+ const loadRest = loadTotal !== null && (evAbs !== null || historyEvAbsent)
31215
+ ? Math.max(0, loadTotal - (evAbs ?? 0) - extrasConsumersSum) : null;
30924
31216
  /**
30925
31217
  * Code-Teil: _rawCacheValue
30926
31218
  * Zweck: Kapselt einen lokalen Verarbeitungsschritt, damit Aufrufer nicht direkt in Detaildaten eingreifen.
@@ -30943,8 +31235,8 @@ return res.json(out);
30943
31235
  */
30944
31236
  const _numOr = (key, fallback = null) => {
30945
31237
  try {
30946
- const n = Number(_rawCacheValue(key));
30947
- return Number.isFinite(n) ? n : fallback;
31238
+ const n = numericMeasurement(_rawCacheValue(key));
31239
+ return n !== null ? n : fallback;
30948
31240
  } catch (_e) {
30949
31241
  return fallback;
30950
31242
  }
@@ -31068,8 +31360,11 @@ return res.json(out);
31068
31360
  };
31069
31361
 
31070
31362
  const dynamicTariffActive = _boolOr('settings.dynamicTariff', false);
31071
- const providerPrice = _numOr('tarif.preisAktuellEurProKwh', null);
31072
- const providerAveragePrice = _numOr('tarif.preisDurchschnittEurProKwh', null);
31363
+ const tariffMaxAgeMs = Math.max(15 * 60000, Math.min(360 * 60000, _numOr('tarif.currentPriceMaxAgeMs', 90 * 60000)));
31364
+ const providerPrice = _rawCacheValue('tarif.currentPriceFresh') === false
31365
+ ? null : readHistory('tarif.preisAktuellEurProKwh', tariffMaxAgeMs);
31366
+ const providerAveragePrice = _rawCacheValue('tarif.curveFresh') === false
31367
+ ? null : readHistory('tarif.preisDurchschnittEurProKwh', tariffMaxAgeMs);
31073
31368
  const manualPrice = _numOr('settings.price', 0.25);
31074
31369
 
31075
31370
  // Die in LIVE und vom Provider gelieferten Strompreise werden als Bruttopreise
@@ -31080,7 +31375,7 @@ return res.json(out);
31080
31375
  // So bleiben LIVE-Sicht und Historie konsistent.
31081
31376
  let tariffDisplayedGrossPrice = Number.isFinite(providerPrice) && dynamicTariffActive ? providerPrice : manualPrice;
31082
31377
  if (!Number.isFinite(tariffDisplayedGrossPrice)) tariffDisplayedGrossPrice = Number.isFinite(providerPrice) ? providerPrice : 0;
31083
- tariffDisplayedGrossPrice = Math.max(-5, tariffDisplayedGrossPrice);
31378
+ // Canonical EUR/kWh prices are already validated by the provider; retain negative prices unchanged.
31084
31379
 
31085
31380
  const netFeeModeNow = _computeNetFeeModeNow();
31086
31381
  const netFeePriceNt = Math.max(0, Number(_numOr('settings.netFeePriceNt', 0)) || 0);
@@ -31090,19 +31385,19 @@ return res.json(out);
31090
31385
  if (_boolOr('settings.netFeeEnabled', false)) {
31091
31386
  tariffNetFeePrice = (netFeeModeNow === 'NT') ? netFeePriceNt : (netFeeModeNow === 'HT') ? netFeePriceHt : netFeePriceSt;
31092
31387
  }
31093
- const tariffTotalPrice = Math.max(-5, tariffDisplayedGrossPrice);
31388
+ const tariffTotalPrice = tariffDisplayedGrossPrice;
31094
31389
  let tariffBasePrice = tariffTotalPrice - tariffNetFeePrice;
31095
31390
  if (!Number.isFinite(tariffBasePrice)) tariffBasePrice = tariffTotalPrice;
31096
- tariffBasePrice = Math.max(-5, tariffBasePrice);
31391
+
31097
31392
 
31098
31393
  // Core series
31099
31394
  this._nwSetHistorieValue('historie.core.grid.buyW', gridBuy, now, 0);
31100
31395
  this._nwSetHistorieValue('historie.core.grid.sellW', gridSell, now, 0);
31101
31396
  this._nwSetHistorieValue('historie.core.grid.netW', gridNet, now, 0);
31102
31397
 
31103
- this._nwSetHistorieValue('historie.core.pv.totalW', pvTotal || 0, now, 0);
31104
- this._nwSetHistorieValue('historie.core.building.loadTotalW', loadTotal || 0, now, 0);
31105
- this._nwSetHistorieValue('historie.core.building.loadRestW', loadRest || 0, now, 0);
31398
+ this._nwSetHistorieValue('historie.core.pv.totalW', pvTotal, now, 0);
31399
+ this._nwSetHistorieValue('historie.core.building.loadTotalW', loadTotal, now, 0);
31400
+ this._nwSetHistorieValue('historie.core.building.loadRestW', loadRest, now, 0);
31106
31401
 
31107
31402
  this._nwSetHistorieValue('historie.core.storage.chargeW', chg, now, 0);
31108
31403
  this._nwSetHistorieValue('historie.core.storage.dischargeW', dchg, now, 0);
@@ -31227,7 +31522,7 @@ return res.json(out);
31227
31522
  const evcsCount = Number(this.evcsCount || 0);
31228
31523
  if (Number.isFinite(evcsCount) && evcsCount > 0) {
31229
31524
  for (let i = 1; i <= evcsCount; i++) {
31230
- const v = this._nwGetNumberFromCache(`evcs.${i}.powerW`);
31525
+ const v = readHistory(`evcs.${i}.powerW`);
31231
31526
  if (Number.isFinite(v)) this._nwSetHistorieValue(`historie.evcs.lp${i}.powerW`, Math.max(0, Math.abs(v)), now, 0);
31232
31527
  }
31233
31528
  }
@@ -31236,13 +31531,13 @@ return res.json(out);
31236
31531
  for (let i = 1; i <= 10; i++) {
31237
31532
  const info = this._nwGetFlowSlotInfo ? this._nwGetFlowSlotInfo('consumers', i) : null;
31238
31533
  if (!info || !String(info.objectId || '').trim()) continue;
31239
- const v = this._nwGetNumberFromCache(info.stateKey || info.key || `consumer${i}Power`);
31534
+ const v = readHistory(info.stateKey || info.key || `consumer${i}Power`);
31240
31535
  if (Number.isFinite(v)) this._nwSetHistorieValue(`historie.consumers.c${i}.powerW`, Math.abs(v), now, 0);
31241
31536
  }
31242
31537
  for (let i = 1; i <= 5; i++) {
31243
31538
  const info = this._nwGetFlowSlotInfo ? this._nwGetFlowSlotInfo('producers', i) : null;
31244
31539
  if (!info || !String(info.objectId || '').trim()) continue;
31245
- const v = this._nwGetNumberFromCache(info.stateKey || info.key || `producer${i}Power`);
31540
+ const v = readHistory(info.stateKey || info.key || `producer${i}Power`);
31246
31541
  if (Number.isFinite(v)) this._nwSetHistorieValue(`historie.producers.p${i}.powerW`, Math.abs(v), now, 0);
31247
31542
  }
31248
31543
  }
@@ -31479,7 +31774,32 @@ return res.json(out);
31479
31774
  * Zusammenhang: Teil von Adapterkern: Lifecycle, Webserver, API, States, EMS-Engine; Aufrufstellen und abhängige States/APIs beim Ändern mitprüfen.
31480
31775
  * TypeScript: Parameter, Rückgabewert und verwendete Config-/State-Objekte später explizit typisieren.
31481
31776
  */
31777
+ _nwHistorySecretCodec() {
31778
+ return { encrypt: value => this._owner.encrypt(value), decrypt: value => this._owner.decrypt(value) };
31779
+ }
31780
+
31781
+ _nwConfigureHistory() {
31782
+ if (this._nwShuttingDown) return;
31783
+ if (!this._nwDirectHistory) this._nwDirectHistory = new InfluxHistoryRuntime(this.namespace);
31784
+ this._nwDirectHistory.configure(this.config?.history);
31785
+ if (this._nwHistoryProviderSignature !== JSON.stringify(this.config?.history || {})) {
31786
+ this._nwHistoryProviderSignature = JSON.stringify(this.config?.history || {});
31787
+ this._nwHistoryApiCache?.clear();
31788
+ this._nwPara14aInfluxProvision = null;
31789
+ }
31790
+ }
31791
+
31792
+ _nwDispatchHistory(instance, payload, callback) {
31793
+ if (this.config?.history?.provider !== 'influxdb2') return this.sendTo(instance, 'getHistory', payload, callback);
31794
+ this._nwConfigureHistory();
31795
+ return this._nwDirectHistory.query(payload.id, payload.options).then(
31796
+ result => callback(result),
31797
+ error => callback({ error: error.code || 'EOS_INFLUX_REQUEST_FAILED' })
31798
+ );
31799
+ }
31800
+
31482
31801
  async _nwDetectInfluxInstance() {
31802
+ if (this.config?.history?.provider === 'influxdb2') return 'eos-direct-influxdb2';
31483
31803
  try {
31484
31804
  // If user did not specify a history instance, try to detect an installed influxdb.X instance.
31485
31805
  if (this._nwTrimId((this.config && this.config.history && this.config.history.instance) || '')) return this._nwTrimId(this.config.history.instance);
@@ -31502,6 +31822,7 @@ return res.json(out);
31502
31822
  * TypeScript: Parameter, Rückgabewert und verwendete Config-/State-Objekte später explizit typisieren.
31503
31823
  */
31504
31824
  _nwGetHistoryInstance() {
31825
+ if (this.config?.history?.provider === 'influxdb2') return 'eos-direct-influxdb2';
31505
31826
  const hcfg = (this.config && this.config.history) || {};
31506
31827
  const inst = this._nwTrimId(hcfg.instance) || this._nwTrimId(this._nwDetectedInfluxInstance) || 'influxdb.0';
31507
31828
  return inst;
@@ -31655,6 +31976,11 @@ return res.json(out);
31655
31976
  * TypeScript: Parameter, Rückgabewert und verwendete Config-/State-Objekte später explizit typisieren.
31656
31977
  */
31657
31978
  async _nwEnsurePara14aInfluxInstance(force = false) {
31979
+ if (this.config?.history?.provider === 'influxdb2') {
31980
+ this._nwConfigureHistory();
31981
+ const status = this._nwDirectHistory.status();
31982
+ return { instance: 'eos-direct-influxdb2', ready: status.state === 'ready', dedicated: false, autoProvisioned: false, provisionState: 'direct', provisionError: status.lastError };
31983
+ }
31658
31984
  const now = Date.now();
31659
31985
  const cached = this._nwPara14aInfluxProvision;
31660
31986
  if (!force && cached && cached.result && (now - Number(cached.ts || 0) < 10 * 60 * 1000)) {
@@ -32974,7 +33300,7 @@ return res.json(out);
32974
33300
  timer = setTimeout(() => finish(failure('EOS_HISTORY_TIMEOUT')), remainingMs);
32975
33301
  timer.unref?.();
32976
33302
  try {
32977
- this.sendTo(inst, 'getHistory', { id: sid, options }, /** @param {unknown} resu */ (resu) => {
33303
+ this._nwDispatchHistory(inst, { id: sid, options }, /** @param {unknown} resu */ (resu) => {
32978
33304
  if (settled) return;
32979
33305
  if (this._nwShuttingDown) return cancel();
32980
33306
  // A delayed event loop must not accept a callback beyond the budget.
@@ -34017,6 +34343,8 @@ return res.json(out);
34017
34343
  this._nwSmartHomeHydrating = false;
34018
34344
  this._nwPreservedUiStates = null;
34019
34345
  cleanup.capture(() => this._nwCancelHistoryRequests?.());
34346
+ cleanup.capture(() => this._nwDirectHistory?.drainAndClose(3000));
34347
+ cleanup.capture(() => this._nwHistoryCheckClient?.close());
34020
34348
  cleanup.capture(() => this._nwHistoryApiCache?.clear());
34021
34349
  cleanup.capture(() => this._nwShcfgDetectCache?.clear());
34022
34350
  cleanup.capture(() => this._nwTypeDetectorObjectsCache?.close());
@@ -34190,7 +34518,7 @@ function createHostedRuntime(owner, bridge) {
34190
34518
  revokeSessions() { runtime._nwCloseSseClients(); },
34191
34519
  status() { return { ...(stopUnconfirmed ? { state: 'stop-unconfirmed', error: 'EOS_UI_STOP_UNCONFIRMED' }
34192
34520
  : stopRequested ? { state: stopConfirmed ? 'stopped' : 'stopping', error: '' } : runtime._hostedStartup || { state: 'stopped', error: '' }),
34193
- active: started && !stopRequested, emsReady: !stopRequested && runtime._hostedStartup?.state === 'ready' && !!runtime.emsEngine, canWrite: guardedBridge.canWrite() === true }; },
34521
+ active: started && !stopRequested, emsReady: !stopRequested && runtime._hostedStartup?.state === 'ready' && runtime._nwIsEmsReady(), canWrite: guardedBridge.canWrite() === true }; },
34194
34522
  stop() {
34195
34523
  if (!stopping) {
34196
34524
  // Sofortige, dauerhafte Sperre vor jedem await und jedem Cleanup-Callback.