iobroker.eos-admin 9.0.17 → 9.0.19

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 (291) hide show
  1. package/NEXOWATT_EOS_BUILD_INFO.json +11 -14
  2. package/README.md +7 -3
  3. package/START_HIER_9.0.18.md +47 -0
  4. package/START_HIER_9.0.19.md +52 -0
  5. package/adminWww/.vite/manifest.json +114 -114
  6. package/adminWww/NEXOWATT_EOS_FRONTEND_MANIFEST.json +13759 -13759
  7. package/adminWww/assets/{AdapterUpdateDialog-Cpo3dAfY.js → AdapterUpdateDialog-JOf2z4Vg.js} +1 -1
  8. package/adminWww/assets/{Adapters-n2ukPDdC.js → Adapters-C9fcSdWm.js} +1 -1
  9. package/adminWww/assets/{ConfigManager-BVZ6_Ebo.js → ConfigManager-BeeLlT6D.js} +1 -1
  10. package/adminWww/assets/{Enums-CQ6yHG2W.js → Enums-FqnXWl8U.js} +1 -1
  11. package/adminWww/assets/{Fields-CaJqzoW-.js → Fields-DMgrt5Pi.js} +1 -1
  12. package/adminWww/assets/{Files-DfvpKGa3.js → Files-CIHtt12g.js} +1 -1
  13. package/adminWww/assets/{Hosts-3xLBsdG6.js → Hosts-fPLBzvTy.js} +1 -1
  14. package/adminWww/assets/{Instances-B7hKEhyw.js → Instances-4XaVQlrT.js} +1 -1
  15. package/adminWww/assets/{Intro-BV4kYZdT.js → Intro-5TKriiLO.js} +1 -1
  16. package/adminWww/assets/{Logs-DpL9eY69.js → Logs-33zcIds-.js} +1 -1
  17. package/adminWww/assets/{Objects-dN06jhQk.js → Objects-CNQPVbNG.js} +1 -1
  18. package/adminWww/assets/{Overview-Lip63_ej.js → Overview-BskXGOc8.js} +1 -1
  19. package/adminWww/assets/{State-BSO2X_xN.js → State-C8SJ_Iqo.js} +1 -1
  20. package/adminWww/assets/{UsedResources-DvqzszKI.js → UsedResources-CgqRa9ei.js} +1 -1
  21. package/adminWww/assets/{Users-Csqd1xA-.js → Users-0JVYWR9u.js} +1 -1
  22. package/adminWww/assets/{bootstrap-C3HM8kNL.js → bootstrap-D16lu6rd.js} +3 -3
  23. package/adminWww/assets/{hostInit-DdxBUeXQ.js → hostInit-C8YZJuzi.js} +1 -1
  24. package/adminWww/assets/{icons-material-D1Tb_725.js → icons-material-CiNJ_6Ur.js} +1 -1
  25. package/adminWww/assets/{index-BOujTMyH.js → index-DA9Sphgh.js} +2 -2
  26. package/adminWww/assets/{installSVGRenderer-BZyrUVAo.js → installSVGRenderer-DPdkRa_d.js} +1 -1
  27. package/adminWww/assets/{mf-entry-bootstrap-0-3418586b.js → mf-entry-bootstrap-0-a7ab91de.js} +2 -2
  28. package/adminWww/index.html +23 -23
  29. package/adminWww/mf-manifest.json +1 -1
  30. package/adminWww/mf-stats.json +1 -1
  31. package/adminWww/{remoteEntry-eos-9.0.17.js → remoteEntry-eos-9.0.19.js} +1 -1
  32. package/adminWww/remoteEntry.js +1 -1
  33. package/build/lib/eosCookieNamespace.js +12 -2
  34. package/build/lib/eosCookieNamespace.js.map +1 -1
  35. package/build/lib/eosDeviceEmsPlan.js +1147 -0
  36. package/build/lib/eosDeviceEmsPlan.js.map +1 -0
  37. package/build/lib/eosDeviceEmsService.js +473 -0
  38. package/build/lib/eosDeviceEmsService.js.map +1 -0
  39. package/build/lib/eosModuleHost.js +227 -51
  40. package/build/lib/eosModuleHost.js.map +1 -1
  41. package/build/lib/eosModuleHttp.js +1 -1
  42. package/build/lib/eosModuleHttp.js.map +1 -1
  43. package/build/lib/web.js +31 -0
  44. package/build/lib/web.js.map +1 -1
  45. package/docs/reports/unified-9.0.18/ALIAS_V1_COVERAGE.json +5056 -0
  46. package/docs/reports/unified-9.0.18/ALIAS_V1_VERTRAG.md +257 -0
  47. package/docs/reports/unified-9.0.18/ANFORDERUNGEN.md +55 -0
  48. package/docs/reports/unified-9.0.18/CUSTOMER_TARIFF_REVIEW.md +33 -0
  49. package/docs/reports/unified-9.0.18/GERAETE_EMS_EINRICHTUNG.md +86 -0
  50. package/docs/reports/unified-9.0.18/INSTALLER_LIFECYCLE_REVIEW.md +29 -0
  51. package/docs/reports/unified-9.0.18/KUNDENTARIF_EINRICHTUNG.md +27 -0
  52. package/docs/reports/unified-9.0.18/PRUEFBERICHT.md +87 -0
  53. package/docs/reports/unified-9.0.18/UNABHAENGIGER_REVIEW.md +63 -0
  54. package/docs/reports/unified-9.0.18/raw/INDEX.json +331 -0
  55. package/docs/reports/unified-9.0.18/raw/audit-full.log +345 -0
  56. package/docs/reports/unified-9.0.18/raw/audit-full.result.json +14 -0
  57. package/docs/reports/unified-9.0.18/raw/audit-runtime.log +23 -0
  58. package/docs/reports/unified-9.0.18/raw/audit-runtime.result.json +15 -0
  59. package/docs/reports/unified-9.0.18/raw/backend-final.log +5 -0
  60. package/docs/reports/unified-9.0.18/raw/backend-final.result.json +14 -0
  61. package/docs/reports/unified-9.0.18/raw/frontend-build.log +152 -0
  62. package/docs/reports/unified-9.0.18/raw/frontend-build.result.json +14 -0
  63. package/docs/reports/unified-9.0.18/raw/installer-build.log +26 -0
  64. package/docs/reports/unified-9.0.18/raw/installer-build.result.json +14 -0
  65. package/docs/reports/unified-9.0.18/raw/keygen-source.json +6 -0
  66. package/docs/reports/unified-9.0.18/raw/lint-final.log +5 -0
  67. package/docs/reports/unified-9.0.18/raw/lint-final.result.json +14 -0
  68. package/docs/reports/unified-9.0.18/raw/modules-build.log +5 -0
  69. package/docs/reports/unified-9.0.18/raw/modules-build.result.json +14 -0
  70. package/docs/reports/unified-9.0.18/raw/node22-tests-final.log +9859 -0
  71. package/docs/reports/unified-9.0.18/raw/node22-tests-final.result.json +13 -0
  72. package/docs/reports/unified-9.0.18/raw/node22-typecheck-final.log +7 -0
  73. package/docs/reports/unified-9.0.18/raw/node22-typecheck-final.result.json +14 -0
  74. package/docs/reports/unified-9.0.18/raw/node22-version.log +1 -0
  75. package/docs/reports/unified-9.0.18/raw/node24-tests-final.log +1663 -0
  76. package/docs/reports/unified-9.0.18/raw/node24-tests-final.result.json +13 -0
  77. package/docs/reports/unified-9.0.18/raw/node24-typecheck-final.log +5 -0
  78. package/docs/reports/unified-9.0.18/raw/node24-typecheck-final.result.json +14 -0
  79. package/docs/reports/unified-9.0.18/raw/node24-version.log +1 -0
  80. package/docs/reports/unified-9.0.18/raw/sbom-runtime.log +7 -0
  81. package/docs/reports/unified-9.0.18/raw/sbom-runtime.result.json +14 -0
  82. package/docs/reports/unified-9.0.18/raw/sbom-vendor-check.log +1 -0
  83. package/docs/reports/unified-9.0.18/raw/sbom-vendor-check.result.json +14 -0
  84. package/docs/reports/unified-9.0.18/raw/ui-docs-check.log +6 -0
  85. package/docs/reports/unified-9.0.18/raw/ui-docs-check.result.json +14 -0
  86. package/docs/reports/unified-9.0.18/raw/ui-runtime-final.log +7 -0
  87. package/docs/reports/unified-9.0.18/raw/ui-runtime-final.result.json +14 -0
  88. package/docs/reports/unified-9.0.18/raw/ui-runtime-sync.log +6 -0
  89. package/docs/reports/unified-9.0.18/raw/ui-runtime-sync.result.json +14 -0
  90. package/docs/reports/unified-9.0.18/raw/ui-sbom-check.log +6 -0
  91. package/docs/reports/unified-9.0.18/raw/ui-sbom-check.result.json +14 -0
  92. package/docs/reports/unified-9.0.18/raw/ui-sbom-final.log +14 -0
  93. package/docs/reports/unified-9.0.18/raw/ui-sbom-final.result.json +14 -0
  94. package/docs/reports/unified-9.0.18/raw/ui-secret-final.log +6 -0
  95. package/docs/reports/unified-9.0.18/raw/ui-secret-final.result.json +14 -0
  96. package/docs/reports/unified-9.0.18/raw/ui-security-final.log +8 -0
  97. package/docs/reports/unified-9.0.18/raw/ui-security-final.result.json +14 -0
  98. package/docs/reports/unified-9.0.19/ALIAS_MESSWERTFRISCHE.md +31 -0
  99. package/docs/reports/unified-9.0.19/COMMISSIONING_PLAN_REVIEW.md +56 -0
  100. package/docs/reports/unified-9.0.19/EMS_ABSCHLUSSREVIEW.md +43 -0
  101. package/docs/reports/unified-9.0.19/EMS_KATEGORIEN_ABDECKUNG.md +66 -0
  102. package/docs/reports/unified-9.0.19/EMS_VERGLEICH_UND_KOPPLUNG.md +25 -0
  103. package/docs/reports/unified-9.0.19/EVCS_STATE_OBJECTS.md +47 -0
  104. package/docs/reports/unified-9.0.19/GERAETE_EMS_EINRICHTUNG.md +100 -0
  105. package/docs/reports/unified-9.0.19/GERAETE_STARTAUSFALL.md +37 -0
  106. package/docs/reports/unified-9.0.19/INSTALLER_LIFECYCLE_REVIEW.md +59 -0
  107. package/docs/reports/unified-9.0.19/LEGACY_REGRESSION_REVIEW.md +42 -0
  108. package/docs/reports/unified-9.0.19/MODBUS_AUTHORIZATION_READS.md +25 -0
  109. package/docs/reports/unified-9.0.19/PRUEFBERICHT.md +56 -0
  110. package/docs/reports/unified-9.0.19/RUNTIME_START_UEBERNAHME.md +33 -0
  111. package/docs/reports/unified-9.0.19/SMA_RECEIVER_LIFECYCLE.md +42 -0
  112. package/docs/reports/unified-9.0.19/STATIC_REVIEW_DE.md +11 -0
  113. package/docs/reports/unified-9.0.19/TARIFF_PRICE_VALUES_REVIEW.md +31 -0
  114. package/docs/reports/unified-9.0.19/TARIF_VIERTELSTUNDEN_RUNTIME.md +17 -0
  115. package/docs/reports/unified-9.0.19/UNABHAENGIGER_REVIEW.md +49 -0
  116. package/docs/reports/unified-9.0.19/raw/INDEX.json +751 -0
  117. package/docs/reports/unified-9.0.19/raw/audit-full.log +345 -0
  118. package/docs/reports/unified-9.0.19/raw/audit-full.result.json +14 -0
  119. package/docs/reports/unified-9.0.19/raw/audit-runtime.log +23 -0
  120. package/docs/reports/unified-9.0.19/raw/audit-runtime.result.json +15 -0
  121. package/docs/reports/unified-9.0.19/raw/backend-final.log +5 -0
  122. package/docs/reports/unified-9.0.19/raw/backend-final.result.json +14 -0
  123. package/docs/reports/unified-9.0.19/raw/devices-hosted-typecheck-node22.log +0 -0
  124. package/docs/reports/unified-9.0.19/raw/devices-hosted-typecheck-node22.result.json +15 -0
  125. package/docs/reports/unified-9.0.19/raw/devices-hosted-typecheck-node24.log +0 -0
  126. package/docs/reports/unified-9.0.19/raw/devices-hosted-typecheck-node24.result.json +15 -0
  127. package/docs/reports/unified-9.0.19/raw/devices-incident-build.log +5 -0
  128. package/docs/reports/unified-9.0.19/raw/devices-incident-host-final.log +70 -0
  129. package/docs/reports/unified-9.0.19/raw/devices-incident-lease-918-before.log +26 -0
  130. package/docs/reports/unified-9.0.19/raw/devices-incident-lease-after.log +9 -0
  131. package/docs/reports/unified-9.0.19/raw/devices-incident-metadata-after.log +11 -0
  132. package/docs/reports/unified-9.0.19/raw/devices-incident-metadata-before.log +28 -0
  133. package/docs/reports/unified-9.0.19/raw/devices-incident-web-pipeline.log +22 -0
  134. package/docs/reports/unified-9.0.19/raw/frontend-build.log +152 -0
  135. package/docs/reports/unified-9.0.19/raw/frontend-build.result.json +14 -0
  136. package/docs/reports/unified-9.0.19/raw/installer-build.log +26 -0
  137. package/docs/reports/unified-9.0.19/raw/installer-build.result.json +14 -0
  138. package/docs/reports/unified-9.0.19/raw/keygen-source.json +6 -0
  139. package/docs/reports/unified-9.0.19/raw/legacy-auto-pv.log +6 -0
  140. package/docs/reports/unified-9.0.19/raw/legacy-auto-pv.result.json +14 -0
  141. package/docs/reports/unified-9.0.19/raw/legacy-charging-grid-cap-clamp.log +6 -0
  142. package/docs/reports/unified-9.0.19/raw/legacy-charging-grid-cap-clamp.result.json +14 -0
  143. package/docs/reports/unified-9.0.19/raw/legacy-charging-grid-cap-safe.log +6 -0
  144. package/docs/reports/unified-9.0.19/raw/legacy-charging-grid-cap-safe.result.json +14 -0
  145. package/docs/reports/unified-9.0.19/raw/legacy-charging-mode-recovery.log +539 -0
  146. package/docs/reports/unified-9.0.19/raw/legacy-charging-mode-recovery.result.json +14 -0
  147. package/docs/reports/unified-9.0.19/raw/legacy-core-limits-phase1.log +6 -0
  148. package/docs/reports/unified-9.0.19/raw/legacy-core-limits-phase1.result.json +14 -0
  149. package/docs/reports/unified-9.0.19/raw/legacy-core-limits-phase2.log +6 -0
  150. package/docs/reports/unified-9.0.19/raw/legacy-core-limits-phase2.result.json +14 -0
  151. package/docs/reports/unified-9.0.19/raw/legacy-core-limits-tariff-final.log +6 -0
  152. package/docs/reports/unified-9.0.19/raw/legacy-core-limits-tariff-final.result.json +14 -0
  153. package/docs/reports/unified-9.0.19/raw/legacy-energy-wallet-final.log +6 -0
  154. package/docs/reports/unified-9.0.19/raw/legacy-energy-wallet-final.result.json +14 -0
  155. package/docs/reports/unified-9.0.19/raw/legacy-farm-dispatch-loader-current.log +2 -0
  156. package/docs/reports/unified-9.0.19/raw/legacy-farm-dispatch-loader-current.result.json +14 -0
  157. package/docs/reports/unified-9.0.19/raw/legacy-final-write-envelope.log +6 -0
  158. package/docs/reports/unified-9.0.19/raw/legacy-final-write-envelope.result.json +14 -0
  159. package/docs/reports/unified-9.0.19/raw/legacy-history-http.log +39 -0
  160. package/docs/reports/unified-9.0.19/raw/legacy-history-http.result.json +15 -0
  161. package/docs/reports/unified-9.0.19/raw/legacy-import-grid-budget.log +30 -0
  162. package/docs/reports/unified-9.0.19/raw/legacy-import-grid-budget.result.json +14 -0
  163. package/docs/reports/unified-9.0.19/raw/legacy-import-grid-contract-current.log +2 -0
  164. package/docs/reports/unified-9.0.19/raw/legacy-import-grid-contract-current.result.json +14 -0
  165. package/docs/reports/unified-9.0.19/raw/legacy-live-mode-loader-current.log +203 -0
  166. package/docs/reports/unified-9.0.19/raw/legacy-live-mode-loader-current.result.json +14 -0
  167. package/docs/reports/unified-9.0.19/raw/legacy-load-grid-sanity.log +6 -0
  168. package/docs/reports/unified-9.0.19/raw/legacy-load-grid-sanity.result.json +14 -0
  169. package/docs/reports/unified-9.0.19/raw/legacy-ocpp-stability.log +6 -0
  170. package/docs/reports/unified-9.0.19/raw/legacy-ocpp-stability.result.json +14 -0
  171. package/docs/reports/unified-9.0.19/raw/legacy-ocpp21-storage-safety.log +6 -0
  172. package/docs/reports/unified-9.0.19/raw/legacy-ocpp21-storage-safety.result.json +14 -0
  173. package/docs/reports/unified-9.0.19/raw/legacy-permanent-grid-protection.log +18 -0
  174. package/docs/reports/unified-9.0.19/raw/legacy-permanent-grid-protection.result.json +14 -0
  175. package/docs/reports/unified-9.0.19/raw/legacy-storage-dp-persistence.log +6 -0
  176. package/docs/reports/unified-9.0.19/raw/legacy-storage-dp-persistence.result.json +14 -0
  177. package/docs/reports/unified-9.0.19/raw/legacy-storage-farm-dispatch-recovery.log +16 -0
  178. package/docs/reports/unified-9.0.19/raw/legacy-storage-farm-dispatch-recovery.result.json +14 -0
  179. package/docs/reports/unified-9.0.19/raw/legacy-storage-functional-safety.log +6 -0
  180. package/docs/reports/unified-9.0.19/raw/legacy-storage-functional-safety.result.json +14 -0
  181. package/docs/reports/unified-9.0.19/raw/legacy-storage-topology-loader-current.log +2 -0
  182. package/docs/reports/unified-9.0.19/raw/legacy-storage-topology-loader-current.result.json +14 -0
  183. package/docs/reports/unified-9.0.19/raw/legacy-test-loader.cjs +47 -0
  184. package/docs/reports/unified-9.0.19/raw/lint-final.log +16 -0
  185. package/docs/reports/unified-9.0.19/raw/lint-final.result.json +14 -0
  186. package/docs/reports/unified-9.0.19/raw/modules-build.log +5 -0
  187. package/docs/reports/unified-9.0.19/raw/modules-build.result.json +14 -0
  188. package/docs/reports/unified-9.0.19/raw/node22-tests-final.log +10719 -0
  189. package/docs/reports/unified-9.0.19/raw/node22-tests-final.result.json +13 -0
  190. package/docs/reports/unified-9.0.19/raw/node22-typecheck-final.log +7 -0
  191. package/docs/reports/unified-9.0.19/raw/node22-typecheck-final.result.json +14 -0
  192. package/docs/reports/unified-9.0.19/raw/node22-version.log +1 -0
  193. package/docs/reports/unified-9.0.19/raw/node24-tests-final.log +1805 -0
  194. package/docs/reports/unified-9.0.19/raw/node24-tests-final.result.json +13 -0
  195. package/docs/reports/unified-9.0.19/raw/node24-typecheck-final.log +5 -0
  196. package/docs/reports/unified-9.0.19/raw/node24-typecheck-final.result.json +14 -0
  197. package/docs/reports/unified-9.0.19/raw/node24-version.log +1 -0
  198. package/docs/reports/unified-9.0.19/raw/sbom-runtime.log +7 -0
  199. package/docs/reports/unified-9.0.19/raw/sbom-runtime.result.json +14 -0
  200. package/docs/reports/unified-9.0.19/raw/sbom-vendor-check.log +1 -0
  201. package/docs/reports/unified-9.0.19/raw/sbom-vendor-check.result.json +14 -0
  202. package/docs/reports/unified-9.0.19/raw/tariff-price-chain-919.log +11 -0
  203. package/docs/reports/unified-9.0.19/raw/tariff-price-chain-919.result.json +14 -0
  204. package/docs/reports/unified-9.0.19/raw/tariff-price-chain-old-918.log +68 -0
  205. package/docs/reports/unified-9.0.19/raw/tariff-price-chain-old-918.result.json +14 -0
  206. package/docs/reports/unified-9.0.19/raw/ui-docs-check.log +6 -0
  207. package/docs/reports/unified-9.0.19/raw/ui-docs-check.result.json +14 -0
  208. package/docs/reports/unified-9.0.19/raw/ui-runtime-final.log +7 -0
  209. package/docs/reports/unified-9.0.19/raw/ui-runtime-final.result.json +14 -0
  210. package/docs/reports/unified-9.0.19/raw/ui-runtime-sync.log +6 -0
  211. package/docs/reports/unified-9.0.19/raw/ui-runtime-sync.result.json +14 -0
  212. package/docs/reports/unified-9.0.19/raw/ui-sbom-check.log +6 -0
  213. package/docs/reports/unified-9.0.19/raw/ui-sbom-check.result.json +14 -0
  214. package/docs/reports/unified-9.0.19/raw/ui-sbom-final.log +6 -0
  215. package/docs/reports/unified-9.0.19/raw/ui-sbom-final.result.json +14 -0
  216. package/docs/reports/unified-9.0.19/raw/ui-secret-final.log +6 -0
  217. package/docs/reports/unified-9.0.19/raw/ui-secret-final.result.json +14 -0
  218. package/docs/reports/unified-9.0.19/raw/ui-security-final.log +8 -0
  219. package/docs/reports/unified-9.0.19/raw/ui-security-final.result.json +14 -0
  220. package/io-package.json +12 -12
  221. package/modules/devices/admin/alias-contract-v1.json +189 -0
  222. package/modules/devices/admin/ems-assignment.d.ts +16 -0
  223. package/modules/devices/admin/ems-assignment.js +356 -0
  224. package/modules/devices/admin/host-bridge.js +76 -4
  225. package/modules/devices/admin/index.html +40 -1
  226. package/modules/devices/admin/index_m.js +158 -2
  227. package/modules/devices/admin/style.css +32 -4
  228. package/modules/devices/checks/emsAssignment.check.js +132 -0
  229. package/modules/devices/contracts.d.ts +1 -1
  230. package/modules/devices/eslint.hosted.config.mjs +1 -1
  231. package/modules/devices/index.js +64 -16
  232. package/modules/devices/lib/alias-contract-v1.json +189 -0
  233. package/modules/devices/lib/aliasContract.js +7 -1
  234. package/modules/devices/lib/device-alias-semantics-v1.json +1605 -0
  235. package/modules/devices/lib/deviceAliasFreshness.js +65 -0
  236. package/modules/devices/lib/deviceAliasSemantics.js +109 -0
  237. package/modules/devices/lib/deviceRuntime.js +204 -127
  238. package/modules/devices/lib/drivers/modbus.js +18 -3
  239. package/modules/devices/lib/drivers/speedwire.js +42 -22
  240. package/modules/devices/test/aliasContractV1.test.js +1 -1
  241. package/modules/devices/test/deviceAliasFreshness.test.js +149 -0
  242. package/modules/devices/test/deviceAliasSemantics.test.js +163 -0
  243. package/modules/devices/test/emsAssignmentUi.test.js +298 -0
  244. package/modules/devices/test/modbusAuthorizationReads.test.js +112 -0
  245. package/modules/devices/test/runtimeLiveness.test.js +1 -1
  246. package/modules/devices/test/speedwireLifecycle.test.js +118 -0
  247. package/modules/devices/tsconfig.alias-semantics.json +17 -0
  248. package/modules/devices/tsconfig.ems-ui.json +9 -0
  249. package/modules/devices/tsconfig.hosted.json +1 -1
  250. package/package.json +11 -7
  251. package/release-manifests/unified/build-environment.cdx.json +1483 -7370
  252. package/release-manifests/unified/files.json +392 -121
  253. package/release-manifests/unified/frontend.cdx.json +2688 -5952
  254. package/release-manifests/unified/installer.cdx.json +2053 -821
  255. package/release-manifests/unified/obsolete-admin-assets.json +172 -6
  256. package/release-manifests/unified/runtime.cdx.json +40 -3283
  257. package/release-manifests/unified/validation.json +15 -15
  258. package/tools/eos-release-check.cjs +1 -1
  259. package/tools/eos-release-manifest.cjs +5 -5
  260. package/ui/docs/security/eslint-reviewed-findings.json +32 -18
  261. package/ui/ems/datapoints.js +22 -1
  262. package/ui/ems/engine.js +54 -7
  263. package/ui/ems/module-manager.js +44 -21
  264. package/ui/ems/modules/core-limits.js +5 -3
  265. package/ui/ems/modules/energy-wallet.js +31 -32
  266. package/ui/ems/modules/storage-control.js +5 -4
  267. package/ui/ems/modules/tarif-vis.js +36 -24
  268. package/ui/ems/modules/tariff-provider.js +259 -59
  269. package/ui/ems/services/tariff-provider-registry.js +11 -8
  270. package/ui/io-package.json +5 -1
  271. package/ui/lib/customer-tariff.js +245 -0
  272. package/ui/lib/installer-lifecycle.js +220 -0
  273. package/ui/lib/storage-farm-overview.js +115 -0
  274. package/ui/lib/tariff-price.js +115 -0
  275. package/ui/main.js +400 -163
  276. package/ui/package.json +14 -4
  277. package/ui/www/app.js +47 -134
  278. package/ui/www/customer-tariff.css +21 -0
  279. package/ui/www/customer-tariff.js +333 -0
  280. package/ui/www/ems-apps.html +2 -0
  281. package/ui/www/ems-apps.js +29 -7
  282. package/ui/www/index.html +2 -0
  283. package/ui/www/licenses/smarthome-markdown-components.json +156 -156
  284. package/ui/www/manifest.webmanifest +2 -2
  285. package/ui/www/power-measurements.js +62 -0
  286. package/ui/www/settings.html +47 -0
  287. package/ui/www/storagefarm-summary.css +17 -0
  288. package/ui/www/storagefarm-summary.js +136 -0
  289. package/ui/www/storagefarm.html +16 -1
  290. package/ui/www/storagefarm.js +10 -22
  291. package/ui/www/tariff-display.js +161 -0
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:943ab11ea87203ba5cb746b4cff421200465a216442283405516f331a92eac0a
10
+ * Quell-Hash: sha256:29a6433294bddf757bdbe2e7ffba84bffe0fc70f2e3fbdbd63c6ea2e9dce4a16
11
11
  * Erzeugung: npm run sync:ts-runtime-executables
12
12
  *
13
13
  * Zweck:
@@ -54,6 +54,10 @@ 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');
58
+ const { buildFarmOverview } = require('./lib/storage-farm-overview');
59
+ const { tariffDisplayConfig } = require('./lib/tariff-price');
60
+ const { customerTariffView, prepareCustomerTariffChange } = require('./lib/customer-tariff');
57
61
  const https = require('https');
58
62
  const pkg = require('./package.json');
59
63
  const { defaultEnergyOriginConfig, registerEnergyOriginApi } = require('./lib/energy-origin-api');
@@ -2564,13 +2568,14 @@ class NexoWattVis extends HostedAdapter {
2564
2568
  if (!Number.isFinite(n) || n <= 0) return value;
2565
2569
  return Math.round(hardLimitW > 0 ? Math.min(n, hardLimitW) : n);
2566
2570
  };
2567
- p.storage.ratedPowerW = normalizePositiveW(p.storage.ratedPowerW);
2568
- p.storage.maxChargeW = normalizePositiveW(p.storage.maxChargeW);
2569
- p.storage.maxDischargeW = normalizePositiveW(p.storage.maxDischargeW);
2570
- p.storage.selfMaxChargeW = normalizePositiveW(p.storage.selfMaxChargeW);
2571
- p.storage.selfMaxDischargeW = normalizePositiveW(p.storage.selfMaxDischargeW);
2572
- p.storage.lskMaxChargeW = normalizePositiveW(p.storage.lskMaxChargeW);
2573
- p.storage.lskMaxDischargeW = normalizePositiveW(p.storage.lskMaxDischargeW);
2571
+ // Optionale, nicht gesetzte Grenzen bleiben abwesend. Ein leeres Speicher-
2572
+ // Objekt darf durch die Lizenznormalisierung keine undefined-Eigenschaften
2573
+ // erhalten, die einen späteren Geräteplan ungültig machen; 0/null bleiben exakt erhalten.
2574
+ for (const key of ['ratedPowerW', 'maxChargeW', 'maxDischargeW', 'selfMaxChargeW', 'selfMaxDischargeW', 'lskMaxChargeW', 'lskMaxDischargeW']) {
2575
+ const value = Reflect.get(p.storage, key);
2576
+ if (value === undefined) Reflect.deleteProperty(p.storage, key);
2577
+ else Reflect.set(p.storage, key, normalizePositiveW(value));
2578
+ }
2574
2579
  }
2575
2580
  // Home: Auch Farm-Zeilen behalten die bestehende Leistungsgrenze.
2576
2581
  // Der finale gemeinsame Speicherbefehl wird zusätzlich zentral begrenzt.
@@ -3350,6 +3355,7 @@ class NexoWattVis extends HostedAdapter {
3350
3355
  'settingsConfig',
3351
3356
  'datapoints',
3352
3357
  'installerConfig',
3358
+ 'eosDeviceEms', // Server-owned commissioning identities survive updates and app changes.
3353
3359
  'countryProfile',
3354
3360
  'emsApps',
3355
3361
  'schedulerIntervalMs',
@@ -4843,6 +4849,153 @@ class NexoWattVis extends HostedAdapter {
4843
4849
  }
4844
4850
  }
4845
4851
 
4852
+ _nwInstallerConfigRevision() {
4853
+ return installerRevision(this._nwInstallerConfigPatch || {});
4854
+ }
4855
+
4856
+ _nwAssertInstallerConfigRevision(expected) {
4857
+ assertInstallerRevision(expected, this._nwInstallerConfigPatch || {});
4858
+ }
4859
+
4860
+ async _nwProvisionInstallerObjects(nextConfig) {
4861
+ const rows = nextConfig?.settingsConfig?.evcsList;
4862
+ const count = Math.max(Array.isArray(rows) ? rows.length : 0, Number(nextConfig?.settingsConfig?.evcsCount) || 0);
4863
+ await provisionInstallerObjects({
4864
+ canWrite: () => !this._nwShuttingDown && this._bridge.canWrite() === true,
4865
+ steps: [() => this.ensureInstallerStates(), () => this.ensureSettingsStates(),
4866
+ () => this.ensureStorageFarmStates(), () => this.ensureEvcsStates(Math.min(50, Math.max(0, Math.round(count)))),
4867
+ () => this.ensureRfidStates(true)],
4868
+ });
4869
+ }
4870
+
4871
+ async _nwApplyInstallerRuntime(restartEms, reason) {
4872
+ const currentTariffModule = this.emsEngine?.mm?.modules?.find(entry => entry.key === 'tariffProvider')?.instance;
4873
+ if (currentTariffModule && typeof currentTariffModule.invalidateConfiguration === 'function') await currentTariffModule.invalidateConfiguration();
4874
+ if (currentTariffModule && typeof currentTariffModule.applyTariffMappings === 'function') await currentTariffModule.applyTariffMappings();
4875
+ await this._nwProvisionInstallerObjects(this.config);
4876
+ await this.syncInstallerConfigToStates();
4877
+ await this.syncSettingsToStates(reason === 'device-commissioning');
4878
+ await this.syncSettingsConfigToStates();
4879
+ await this.ensureEvcsStates();
4880
+ await this.subscribeEvcsMappedStates();
4881
+ await this.subscribeConfiguredStates();
4882
+ await this.ensureHistorieExportStates();
4883
+ if (this._nwHistoryApiCache instanceof Map) this._nwHistoryApiCache.clear();
4884
+ // In-flight history requests retain their existing deduplication/lifecycle fencing.
4885
+ this.startHistorieExportTimer();
4886
+ await this.syncStorageFarmConfigFromAdmin();
4887
+ if (this._nwStorageFarmTimer) {
4888
+ this._nwClearInterval(this._nwStorageFarmTimer);
4889
+ this._nwStorageFarmTimer = null;
4890
+ }
4891
+ if (this._nwGetStorageFarmRuntimeInfo().active) {
4892
+ const interval = Math.max(250, Math.min(1000, Math.round(Number(this.config?.storageFarm?.schedulerIntervalMs) || 1000)));
4893
+ await this.updateStorageFarmDerived(reason);
4894
+ this._nwStorageFarmTimer = this._nwSetInterval(() => { this.updateStorageFarmDerived('timer').catch(() => {}); }, interval);
4895
+ }
4896
+ if (restartEms) {
4897
+ try { await this.initEmsEngine(true); }
4898
+ catch (_error) {
4899
+ throw createPublicHttpError(503, 'EOS_EMS_APPLY_FAILED', 'Einstellungen sind gespeichert. Die EMS-Laufzeit konnte sie noch nicht übernehmen; Status prüfen und erneut anwenden.');
4900
+ }
4901
+ }
4902
+ await this._meshCoordinator?.syncAppLifecycle();
4903
+ }
4904
+
4905
+ /** Gerätezuordnungen und ausdrücklich gespeicherte EMS-Inbetriebnahmen verwenden
4906
+ * denselben Mutationsschutz wie AppCenter. Der Planner verbraucht bestätigte
4907
+ * Einzelaufträge; Neustarts erteilen keine neue App-/Stellfreigabe. */
4908
+ async reconcileDeviceEms(devices) {
4909
+ const assertReady = () => {
4910
+ if (this._nwShuttingDown || this._bridge.canWrite() !== true) throw new Error('EOS_UI_OWNERSHIP_REQUIRED');
4911
+ if (!['ready', 'degraded'].includes(this._hostedStartup?.state)) throw new Error('EOS_UI_STARTING');
4912
+ if (!centralLicenseSnapshot(this._bridge).ok) throw new Error('EOS_LICENSE_REQUIRED');
4913
+ };
4914
+ assertReady();
4915
+ const token = this._nwBeginInstallerConfigMutation();
4916
+ if (!token) throw new Error('EOS_DEVICE_EMS_BUSY');
4917
+ try {
4918
+ assertReady();
4919
+ if (typeof this._bridge.deviceEmsPlan !== 'function') throw new Error('EOS_DEVICE_EMS_UNAVAILABLE');
4920
+ const effective = this.nwApplyInstallerPatchToRuntimeConfig(this.config || {}, this._nwInstallerConfigPatch || {});
4921
+ const allowedApps = ['charging', 'storage', 'storagefarm'].filter(id => this._nwLicenseAllowsAppId(id));
4922
+ const plan = await this._bridge.deviceEmsPlan({ config: effective, devices, allowedApps });
4923
+ assertReady();
4924
+ if (!plan.changed && !this._nwDeviceEmsApplyPending) return { changed: false, statuses: plan.statuses };
4925
+ const patch = this.nwDeepMerge(this._nwDeepClone(this._nwInstallerConfigPatch || {}), plan.patch);
4926
+ if (plan.changed) {
4927
+ await prepareDynamicGridInstallerPatch(this, patch, plan.patch, currentDynamicGridConfig(this).configVersion);
4928
+ }
4929
+ const next = this.nwApplyInstallerPatchToRuntimeConfig(this.config || {}, patch);
4930
+ assertDeviceAppActivations(effective, { emsApps: patch.emsApps }, id => this._nwLicenseAllowsAppId(id));
4931
+ const storageLicense = this._nwValidateStorageFarmLicense(next);
4932
+ if (!storageLicense.ok) throw new Error(String(storageLicense.error || 'EOS_EMS_STORAGE_LICENSE_REQUIRED'));
4933
+ await this._nwProvisionInstallerObjects(next);
4934
+ assertReady();
4935
+ if (plan.changed) {
4936
+ if (await this.persistInstallerConfigToState(patch) === false) throw new Error('EOS_DEVICE_EMS_PERSIST_FAILED');
4937
+ this._nwInstallerConfigPatch = patch;
4938
+ this._nwInstallerConfigRawPatch = this._nwDeepClone(patch);
4939
+ }
4940
+ this._nwDeviceEmsApplyPending = true;
4941
+ this._nwEmsInitError = 'EOS_EMS_CONFIG_APPLY_PENDING';
4942
+ assertReady();
4943
+ if (this.emsEngine?.stopForReconfigure) await this.emsEngine.stopForReconfigure();
4944
+ assertReady();
4945
+ this.config = next;
4946
+ await this._nwApplyInstallerRuntime(true, 'device-commissioning');
4947
+ this._nwDeviceEmsApplyPending = false;
4948
+ try { await this.nwWriteUserdataBackup(patch, 'device-commissioning'); }
4949
+ catch (_error) { this.log.warn('EOS_DEVICE_EMS_BACKUP_FAILED: Einstellungen gespeichert; zusätzliche Sicherung fehlgeschlagen.'); }
4950
+ return { changed: plan.changed, statuses: plan.statuses };
4951
+ } finally { this._nwEndInstallerConfigMutation(token); }
4952
+ }
4953
+
4954
+ /** Profil-/Protokollwechsel darf eine laufende Regelung nicht unter unveränderten
4955
+ * Geräte-DP-IDs auf andere Register umlenken. Derselbe Save-Token bleibt bis zum
4956
+ * abgeschlossenen Geräte-Commit beim Host; reine Umbenennungen rufen diesen Pfad nicht auf. */
4957
+ async reserveDeviceProfileChange(input) {
4958
+ const codeError = (code) => Object.assign(new Error(code), { code });
4959
+ const assertReady = () => {
4960
+ if (this._nwShuttingDown || this._bridge.canWrite() !== true || !['ready', 'degraded'].includes(this._hostedStartup?.state)) {
4961
+ throw codeError('EOS_DEVICES_PROFILE_CHECK_UNAVAILABLE');
4962
+ }
4963
+ };
4964
+ assertReady();
4965
+ const namespace = typeof input?.namespace === 'string' ? input.namespace : '';
4966
+ const changes = Array.isArray(input?.changes) ? input.changes : null;
4967
+ if (!/^[a-zA-Z0-9_-]+\.\d+$/.test(namespace) || !changes || changes.length < 1 || changes.length > 128) throw codeError('EOS_DEVICES_PROFILE_CHECK_UNAVAILABLE');
4968
+ const prefixes = changes.map(change => {
4969
+ const id = typeof change?.deviceId === 'string' ? change.deviceId : '';
4970
+ if (!id || id.length > 128 || !id.split('.').every(part => /^[a-zA-Z0-9_-]+$/.test(part))) throw codeError('EOS_DEVICES_PROFILE_CHECK_UNAVAILABLE');
4971
+ return `${namespace}.devices.${id}.`;
4972
+ });
4973
+ const token = this._nwBeginInstallerConfigMutation();
4974
+ if (!token) throw codeError('EOS_DEVICE_EMS_BUSY');
4975
+ let retained = false;
4976
+ try {
4977
+ const effective = this.nwApplyInstallerPatchToRuntimeConfig(this.config || {}, this._nwInstallerConfigPatch || {});
4978
+ const refs = activeDeviceProfileReferences(effective);
4979
+ const touches = id => typeof id === 'string' && prefixes.some(prefix => id.startsWith(prefix));
4980
+ if ([...refs.read, ...refs.write].some(touches)) throw codeError('EOS_DEVICES_PROFILE_IN_USE');
4981
+ if (refs.read.length || refs.write.length) {
4982
+ if (typeof this._bridge.resolveDeviceProfileReferences !== 'function') throw codeError('EOS_DEVICES_PROFILE_CHECK_UNAVAILABLE');
4983
+ // A small reference-only projection avoids passing unrelated optional native
4984
+ // fields/secrets into the strict alias resolver.
4985
+ const resolved = await this._bridge.resolveDeviceProfileReferences({ storage: { profileReferences: [
4986
+ ...refs.read.map(id => ({ readObjectId: id })), ...refs.write.map(id => ({ writeObjectId: id })),
4987
+ ] } });
4988
+ assertReady();
4989
+ if (!resolved || !resolved.readTargets || !resolved.writeTargets || typeof resolved.readTargets !== 'object' || typeof resolved.writeTargets !== 'object') throw codeError('EOS_DEVICES_PROFILE_CHECK_UNAVAILABLE');
4990
+ if ([...Object.values(resolved.readTargets), ...Object.values(resolved.writeTargets)].some(touches)) throw codeError('EOS_DEVICES_PROFILE_IN_USE');
4991
+ }
4992
+ assertReady();
4993
+ retained = true;
4994
+ let released = false;
4995
+ return () => { if (!released) { released = true; this._nwEndInstallerConfigMutation(token); } };
4996
+ } finally { if (!retained) this._nwEndInstallerConfigMutation(token); }
4997
+ }
4998
+
4846
4999
  async persistInstallerConfigToState(patchObj) {
4847
5000
  // Auch interne Save-/Importpfade dürfen verbindliche Mesh-Grenzen nicht lösen.
4848
5001
  const nextRuntime = this.nwApplyInstallerPatchToRuntimeConfig(this.config, patchObj);
@@ -5700,6 +5853,7 @@ class NexoWattVis extends HostedAdapter {
5700
5853
  feneconControlMode,
5701
5854
  // Messwerte
5702
5855
  socId: textFrom('socId', 'socObjectId', 'socDp', 'storageSocId', 'storageSoc'),
5856
+ batteryFlowPowerId: textFrom('batteryFlowPowerId'),
5703
5857
  signedPowerId: textFrom('signedPowerId', 'batteryPowerObjectId', 'signedPowerDp', 'powerObjectId', 'powerId', 'batteryPower'),
5704
5858
  chargePowerId: textFrom('chargePowerId', 'batteryChargePowerObjectId', 'chargePowerDp', 'chargeDp', 'storageChargePower'),
5705
5859
  dischargePowerId: textFrom('dischargePowerId', 'batteryDischargePowerObjectId', 'dischargePowerDp', 'dischargeDp', 'storageDischargePower'),
@@ -5836,10 +5990,10 @@ class NexoWattVis extends HostedAdapter {
5836
5990
  const appCenterActive = !!(app && app.installed === true && app.enabled === true);
5837
5991
  const legacyActive = cfg.enableStorageFarm === true;
5838
5992
 
5839
- // Eine Farm ist erst ab zwei real konfigurierten Speichern fachlich aktiv.
5993
+ // Eine ausdrücklich aktivierte Farm darf mit einem real konfigurierten Speicher beginnen.
5840
5994
  const configuredCount = configuredRows.length;
5841
5995
  const enabledByConfig = appRecordPresent ? appCenterActive : legacyActive;
5842
- const active = !!(enabledByConfig && configuredCount >= 2);
5996
+ const active = !!(enabledByConfig && configuredCount >= 1);
5843
5997
  const writableRows = configuredRows.filter((row) => this._nwStorageFarmRowHasWritableDatapoint(row));
5844
5998
  const writableCount = writableRows.length;
5845
5999
  return {
@@ -5901,7 +6055,8 @@ class NexoWattVis extends HostedAdapter {
5901
6055
  const singleAppRecordPresent = !!singleApp;
5902
6056
  const singleAppCenterActive = !!(singleApp && singleApp.installed === true && singleApp.enabled === true);
5903
6057
  const singleLegacyActive = cfg.enableStorageControl === true;
5904
- const singleAppActive = singleAppRecordPresent ? singleAppCenterActive : singleLegacyActive;
6058
+ const deviceAssignmentDisabled = cfg.storage?._eosDevice?.v === 1 && cfg.storage?.enabled === false;
6059
+ const singleAppActive = !deviceAssignmentDisabled && (singleAppRecordPresent ? singleAppCenterActive : singleLegacyActive);
5905
6060
 
5906
6061
  const farm = (typeof this._nwGetStorageFarmRuntimeInfo === 'function')
5907
6062
  ? this._nwGetStorageFarmRuntimeInfo()
@@ -6003,6 +6158,12 @@ class NexoWattVis extends HostedAdapter {
6003
6158
  socDegraded: { type: 'boolean', role: 'indicator', def: false, name: 'SoC Qualität reduziert (Debug)' },
6004
6159
  medianSoc: { type: 'number', role: 'value', def: 0, name: 'SoC Median (%) (abgeleitet)' },
6005
6160
  totalPowerW: { type: 'number', role: 'value.power', def: 0, name: 'Gesamtleistung Speicherfarm (W, + Entladen / - Laden)' },
6161
+ totalBatteryPowerW: { type: 'number', role: 'value.power', def: 0, name: 'Physischer Batteriefluss ohne durchgeleitete PV (W)' },
6162
+ totalBatteryChargePowerW: { type: 'number', role: 'value.power', def: 0, name: 'Physische Brutto-Ladeleistung aller Farmbatterien (W)' },
6163
+ totalBatteryDischargePowerW: { type: 'number', role: 'value.power', def: 0, name: 'Physische Brutto-Entladeleistung aller Farmbatterien (W)' },
6164
+ displayMeanSoc: { type: 'number', role: 'value', def: 0, unit: '%', name: 'Arithmetischer SoC-Mittelwert frischer Farmproben (siehe Abdeckung)' },
6165
+ totalCapacityKWh: { type: 'number', role: 'value', def: 0, unit: 'kWh', name: 'Vollständige konfigurierte Nennkapazität der Farm' },
6166
+ overviewJson: { type: 'string', role: 'json', def: '{}', name: 'Gemeinsame Farmübersicht mit Frische und Messabdeckung' },
6006
6167
  powerSourcesTotal: { type: 'number', role: 'value', def: 0, name: 'Eindeutige Speicher-Leistungsquellen der Farm' },
6007
6168
  powerSourcesOnline: { type: 'number', role: 'value', def: 0, name: 'Aktive Speicher-Leistungsquellen der Farm' },
6008
6169
  totalChargePowerW: { type: 'number', role: 'value.power', def: 0, name: 'Brutto-Ladeleistung aller Speicher (W) (abgeleitet)' },
@@ -6034,7 +6195,7 @@ class NexoWattVis extends HostedAdapter {
6034
6195
  read: true,
6035
6196
  write: false,
6036
6197
  def: c.def,
6037
- ...(key.endsWith('PowerW') ? { unit: 'W' } : {}),
6198
+ ...(key.endsWith('PowerW') ? { unit: 'W' } : (c.unit ? { unit: c.unit } : {})),
6038
6199
  },
6039
6200
  native: {},
6040
6201
  });
@@ -6292,7 +6453,7 @@ class NexoWattVis extends HostedAdapter {
6292
6453
  try {
6293
6454
  if (val === null || val === undefined) return NaN;
6294
6455
  if (typeof val === 'number') return val;
6295
- if (typeof val === 'boolean') return val ? 1 : 0;
6456
+ if (typeof val === 'boolean') return NaN;
6296
6457
  if (typeof val === 'string') {
6297
6458
  let s = val.trim();
6298
6459
  if (!s) return NaN;
@@ -6391,6 +6552,7 @@ class NexoWattVis extends HostedAdapter {
6391
6552
 
6392
6553
  const st = await getState(sid);
6393
6554
  if (!st || st.val === undefined || st.val === null) return NaN;
6555
+ if (opts.display === true && ((st.q !== undefined && st.q !== 0) || !Number.isFinite(st.ts) || st.ts > now + 1000)) return NaN;
6394
6556
 
6395
6557
  // IMPORTANT: We intentionally do NOT apply stale filtering here.
6396
6558
  // Some devices update SoC or power only sporadically; the UI should still show
@@ -6406,13 +6568,14 @@ class NexoWattVis extends HostedAdapter {
6406
6568
  let n = parseNum(st.val);
6407
6569
  if (!Number.isFinite(n)) return NaN;
6408
6570
 
6409
- if (kind === 'soc') {
6571
+ if (kind === 'soc' || kind === 'soc-display') {
6410
6572
  // Accept both percent (0..100) and fraction (0..1) formats.
6411
6573
  const unit = await getUnit(sid);
6412
6574
  const ul = String(unit || '').toLowerCase();
6413
6575
  if (!ul.includes('%')) {
6414
6576
  if (n > 0 && n <= 1) n = n * 100;
6415
6577
  }
6578
+ if (kind === 'soc-display' && (n < 0 || n > 100)) return NaN;
6416
6579
  if (Number.isFinite(n)) {
6417
6580
  if (n < 0) n = 0;
6418
6581
  if (n > 100) n = 100;
@@ -6434,6 +6597,7 @@ class NexoWattVis extends HostedAdapter {
6434
6597
  else if (sl.endsWith('w')) unit = 'W';
6435
6598
  }
6436
6599
 
6600
+ if (opts.display === true && unit && !/^(?:[kmg]?w|(?:kilo|mega|giga)?watts?)$/i.test(String(unit).trim().replace(/\s+/g, ''))) return NaN;
6437
6601
  return scalePowerToW(n, unit);
6438
6602
  }
6439
6603
 
@@ -6442,6 +6606,7 @@ class NexoWattVis extends HostedAdapter {
6442
6606
 
6443
6607
  let totalCharge = 0;
6444
6608
  let totalDischarge = 0;
6609
+ const batteryFlowSources = new Set();
6445
6610
  let totalPvAc = 0;
6446
6611
  let totalPvDc = 0;
6447
6612
  let totalPvUnknown = 0;
@@ -6473,6 +6638,8 @@ class NexoWattVis extends HostedAdapter {
6473
6638
  let socSourcesOnline = 0;
6474
6639
 
6475
6640
  const statusRows = [];
6641
+ const overviewMembers = [];
6642
+ const overviewPvSources = [];
6476
6643
  const farmWritableStorageCount = list.filter((row) => this._nwStorageFarmRowHasWritableDatapoint(row)).length;
6477
6644
 
6478
6645
  const maxLicensedStorages = this._nwLicenseMaxStorages();
@@ -6983,6 +7150,12 @@ class NexoWattVis extends HostedAdapter {
6983
7150
  status.pvSourceOnline = !!pvFresh;
6984
7151
  if (pvAgeMs !== null) status.pvSourceAgeSec = Math.floor(pvAgeMs / 1000);
6985
7152
  if (pvFresh && Number.isFinite(pvValue)) status.pvPowerW = pvAbs;
7153
+ const displayPv = !explicitOffline ? await readNumber(pvSourceId, 'power', { allowStale: false, display: true }) : NaN;
7154
+ // Gepunktete Geräte-IDs enden erst vor `.aliases.`, nicht am ersten Punkt.
7155
+ // Unbekannte manuelle Pfade bleiben exakte Quellen statt geratenen Geräteklassen.
7156
+ const aliasDeviceBase = pvSourceId.match(/^(.*\.devices\..+?)\.aliases(?:\.|$)/)?.[1];
7157
+ const overviewPvKey = aliasDeviceBase || pvSourceId;
7158
+ overviewPvSources.push({ key: overviewPvKey, powerW: Number.isFinite(displayPv) ? Math.max(0, Math.abs(displayPv)) : null });
6986
7159
  pvSourceRows.push({
6987
7160
  id: pvSourceId,
6988
7161
  physicalKey,
@@ -6995,6 +7168,27 @@ class NexoWattVis extends HostedAdapter {
6995
7168
  });
6996
7169
  }
6997
7170
 
7171
+ // Physischer Batteriefluss ist bei Hybridgeräten nicht die gesamte
7172
+ // ESS-Konverterleistung. Die vorhandenen Regler-Summen bleiben unverändert;
7173
+ // nur Anzeige/History erhalten bei expliziter Zuordnung die Batteriemessung.
7174
+ const batteryFlowId = String(row.batteryFlowPowerId || '').trim();
7175
+ const batteryFlowKey = batteryFlowId ? `power:${batteryFlowId}` : (signedFeedbackUsable ? `power:${signedId}` : powerSourceKey);
7176
+ const duplicateBatteryFlow = !!batteryFlowKey && batteryFlowSources.has(batteryFlowKey);
7177
+ if (batteryFlowKey) batteryFlowSources.add(batteryFlowKey);
7178
+ const overviewSoc = !explicitOffline && socId
7179
+ ? await readNumber(socId, 'soc-display', { allowStale: false, display: true }) : NaN;
7180
+ const overviewCapacity = numericMeasurement(row.capacityKWh);
7181
+ const overviewMember = {
7182
+ key: String(batteryFlowKey || row._eosDevice?.baseId || (socId ? `soc:${socId}` : status.dispatchKey)),
7183
+ fresh: isFreshOnline,
7184
+ batteryPowerW: null,
7185
+ socPct: Number.isFinite(overviewSoc) ? overviewSoc : null,
7186
+ capacityKWh: overviewCapacity !== null && overviewCapacity > 0 ? overviewCapacity : null,
7187
+ };
7188
+ overviewMembers.push(overviewMember);
7189
+ status.displaySocPct = overviewMember.socPct;
7190
+ status.capacityKWh = overviewMember.capacityKWh;
7191
+
6998
7192
  // Only fresh-online storages contribute live power values to the farm totals.
6999
7193
  // Degraded/stale systems stay visible and may remain dispatchable, but they are
7000
7194
  // excluded from live power aggregation to avoid reporting cached Istleistung as active power.
@@ -7062,6 +7256,29 @@ class NexoWattVis extends HostedAdapter {
7062
7256
  powerSourcesOnline++;
7063
7257
  }
7064
7258
 
7259
+ if (batteryFlowKey) {
7260
+ // Die neue Anzeige akzeptiert keinen halben Split-Messsatz als vollständige
7261
+ // Batteriequelle. Vorhandene Regler-Summen behalten ihre bisherigen Regeln.
7262
+ let physicalPower = NaN;
7263
+ if (batteryFlowId && !isMappedSetpointPowerId(batteryFlowId)) {
7264
+ physicalPower = await readNumber(batteryFlowId, 'power', { allowStale: false, display: true });
7265
+ } else if (!batteryFlowId && signedFeedbackUsable) {
7266
+ const signed = await readNumber(signedId, 'power', { allowStale: false, display: true });
7267
+ physicalPower = invSigned ? -signed : signed;
7268
+ } else if (!batteryFlowId && (chargeFeedbackUsable || dischargeFeedbackUsable)) {
7269
+ const charge = chargeFeedbackUsable ? await readNumber(chgId, 'power', { allowStale: false, display: true }) : 0;
7270
+ const discharge = dischargeFeedbackUsable ? await readNumber(dchgId, 'power', { allowStale: false, display: true }) : 0;
7271
+ if (Number.isFinite(charge) && Number.isFinite(discharge)) physicalPower =
7272
+ Math.max(0, invDchg ? -discharge : discharge) - Math.max(0, invChg ? -charge : charge);
7273
+ }
7274
+ if (Number.isFinite(physicalPower)) {
7275
+ status.batteryFlowPowerW = physicalPower;
7276
+ overviewMember.batteryPowerW = physicalPower;
7277
+ if (duplicateBatteryFlow) status.batteryFlowDuplicate = true;
7278
+ } else {
7279
+ status.batteryFlowMissing = true;
7280
+ }
7281
+ }
7065
7282
  statusRows.push(status);
7066
7283
  available++;
7067
7284
  }
@@ -7111,6 +7328,9 @@ class NexoWattVis extends HostedAdapter {
7111
7328
  const capacityWeightedSocState = Math.round(capacityWeightedSoc * 10) / 10;
7112
7329
  const capacityWeightedSocOnlineState = Math.round(capacityWeightedSocOnline * 10) / 10;
7113
7330
  const totalPowerState = Math.round(totalPower);
7331
+ const farmOverview = buildFarmOverview(overviewMembers, overviewPvSources, now);
7332
+ const farmOverviewJson = JSON.stringify(farmOverview);
7333
+ const totalBatteryPowerState = farmOverview.battery.netW;
7114
7334
  const totalChargeState = Math.round(totalCharge);
7115
7335
  const totalDischargeState = Math.round(totalDischarge);
7116
7336
  const totalPvState = Math.round(totalPv);
@@ -7128,6 +7348,12 @@ class NexoWattVis extends HostedAdapter {
7128
7348
  await this.setStateAsync('storageFarm.socSourcesOnline', { val: socSourcesOnline, ack: true });
7129
7349
  await this.setStateAsync('storageFarm.socDegraded', { val: !!socDegraded, ack: true });
7130
7350
  await this.setStateAsync('storageFarm.totalPowerW', { val: totalPowerState, ack: true });
7351
+ await this.setStateAsync('storageFarm.totalBatteryPowerW', { val: totalBatteryPowerState, ack: true });
7352
+ await this.setStateAsync('storageFarm.totalBatteryChargePowerW', { val: farmOverview.battery.chargeW, ack: true });
7353
+ await this.setStateAsync('storageFarm.totalBatteryDischargePowerW', { val: farmOverview.battery.dischargeW, ack: true });
7354
+ await this.setStateAsync('storageFarm.displayMeanSoc', { val: farmOverview.soc.meanPct, ack: true });
7355
+ await this.setStateAsync('storageFarm.totalCapacityKWh', { val: farmOverview.capacity.totalKWh, ack: true });
7356
+ await this.setStateAsync('storageFarm.overviewJson', { val: farmOverviewJson, ack: true });
7131
7357
  await this.setStateAsync('storageFarm.powerSourcesTotal', { val: seenPowerSourceKeys.size, ack: true });
7132
7358
  await this.setStateAsync('storageFarm.powerSourcesOnline', { val: powerSourcesOnline, ack: true });
7133
7359
  await this.setStateAsync('storageFarm.totalChargePowerW', { val: totalChargeState, ack: true });
@@ -7162,6 +7388,12 @@ class NexoWattVis extends HostedAdapter {
7162
7388
  this.updateValue('storageFarm.socSourcesOnline', socSourcesOnline, now);
7163
7389
  this.updateValue('storageFarm.socDegraded', !!socDegraded, now);
7164
7390
  this.updateValue('storageFarm.totalPowerW', totalPowerState, now);
7391
+ this.updateValue('storageFarm.totalBatteryPowerW', totalBatteryPowerState, now);
7392
+ this.updateValue('storageFarm.totalBatteryChargePowerW', farmOverview.battery.chargeW, now);
7393
+ this.updateValue('storageFarm.totalBatteryDischargePowerW', farmOverview.battery.dischargeW, now);
7394
+ this.updateValue('storageFarm.displayMeanSoc', farmOverview.soc.meanPct, now);
7395
+ this.updateValue('storageFarm.totalCapacityKWh', farmOverview.capacity.totalKWh, now);
7396
+ this.updateValue('storageFarm.overviewJson', farmOverviewJson, now);
7165
7397
  this.updateValue('storageFarm.powerSourcesTotal', seenPowerSourceKeys.size, now);
7166
7398
  this.updateValue('storageFarm.powerSourcesOnline', powerSourcesOnline, now);
7167
7399
  this.updateValue('storageFarm.totalChargePowerW', totalChargeState, now);
@@ -7186,8 +7418,8 @@ class NexoWattVis extends HostedAdapter {
7186
7418
  // keinen ausdrücklichen Einzel-Speicher-Override gesetzt hat. So bleibt eine
7187
7419
  // Kundenanlage ohne Farm und auch eine bewusst abweichende Messquelle autoritativ.
7188
7420
  try {
7189
- const netCharge = totalPowerState < 0 ? Math.abs(totalPowerState) : 0;
7190
- const netDischarge = totalPowerState > 0 ? totalPowerState : 0;
7421
+ const netCharge = totalBatteryPowerState === null ? null : totalBatteryPowerState < 0 ? Math.abs(totalBatteryPowerState) : 0;
7422
+ const netDischarge = totalBatteryPowerState === null ? null : totalBatteryPowerState > 0 ? totalBatteryPowerState : 0;
7191
7423
  const mapped = (this.config && this.config.datapoints && typeof this.config.datapoints === 'object')
7192
7424
  ? this.config.datapoints
7193
7425
  : {};
@@ -7201,7 +7433,7 @@ class NexoWattVis extends HostedAdapter {
7201
7433
  if (!hasPowerOverride) {
7202
7434
  this.updateValue('storageChargePower', netCharge, now, { raw: false });
7203
7435
  this.updateValue('storageDischargePower', netDischarge, now, { raw: false });
7204
- this.updateValue('batteryPower', totalPowerState, now, { raw: false });
7436
+ this.updateValue('batteryPower', totalBatteryPowerState, now, { raw: false });
7205
7437
  }
7206
7438
 
7207
7439
  // PV bleibt ausschließlich in storageFarm.totalPv*. Die zentrale
@@ -9126,7 +9358,7 @@ class NexoWattVis extends HostedAdapter {
9126
9358
  }
9127
9359
 
9128
9360
  _nwIsReadOnlyEvcsMirrorKey(key) {
9129
- return /^evcs\.\d+\.(powerW|energyTotalKwh|vehicleSoc|status|online|active|vehicleConnected|chargeDemand|heartbeat|phaseFeedback|lock|rfidLast)$/.test(String(key || ''));
9361
+ return /^evcs\.\d+\.(powerW|energyTotalKwh|vehicleSoc|status|online|dataFresh|active|chargingState|vehicleConnected|chargeDemand|heartbeat|phaseFeedback|lock|rfidLast)$/.test(String(key || ''));
9130
9362
  }
9131
9363
 
9132
9364
  _nwEvcsMirrorValue(binding, value) {
@@ -9237,8 +9469,8 @@ class NexoWattVis extends HostedAdapter {
9237
9469
  * Zusammenhang: Teil von Adapterkern: Lifecycle, Webserver, API, States, EMS-Engine; Aufrufstellen und abhängige States/APIs beim Ändern mitprüfen.
9238
9470
  * TypeScript: Parameter, Rückgabewert und verwendete Config-/State-Objekte später explizit typisieren.
9239
9471
  */
9240
- async ensureEvcsStates() {
9241
- const count = Math.max(0, Math.round(Number(this.evcsCount || 0) || 0));
9472
+ async ensureEvcsStates(provisionCount) {
9473
+ const count = Math.max(0, Math.round(Number(provisionCount === undefined ? this.evcsCount : provisionCount) || 0));
9242
9474
 
9243
9475
  await this.setObjectNotExistsAsync('evcs', {
9244
9476
  type: 'channel',
@@ -9271,11 +9503,15 @@ class NexoWattVis extends HostedAdapter {
9271
9503
  _dayBaseDate: { type: 'string', role: 'text', def: '', read: true, write: false },
9272
9504
  status: { type: 'string', role: 'state', def: '', read: true, write: false },
9273
9505
  online: { type: 'boolean', role: 'indicator.reachable', def: false, read: true, write: false },
9506
+ // Separate OCPP freshness from transport reachability. Every input
9507
+ // mirror needs its own object before subscription or the first read.
9508
+ dataFresh: { type: 'boolean', role: 'indicator', def: false, read: true, write: false },
9274
9509
  active: { type: 'boolean', role: 'switch', def: false, read: true, write: false },
9275
9510
  // Rohspiegel der optionalen Semantik-/Heartbeat-/Phasen-DPs. Die eigentliche
9276
9511
  // Auswertung bleibt im Charging-Management am Original-DP; der Stringspiegel
9277
9512
  // dient UI, Diagnose und History ohne verlustbehaftete Typkonvertierung.
9278
9513
  vehicleConnected: { type: 'string', role: 'text', def: '', read: true, write: false },
9514
+ chargingState: { type: 'string', role: 'text', def: '', read: true, write: false },
9279
9515
  chargeDemand: { type: 'string', role: 'text', def: '', read: true, write: false },
9280
9516
  heartbeat: { type: 'string', role: 'text', def: '', read: true, write: false },
9281
9517
  phaseFeedback: { type: 'string', role: 'text', def: '', read: true, write: false },
@@ -9322,7 +9558,7 @@ class NexoWattVis extends HostedAdapter {
9322
9558
 
9323
9559
  // write static names/notes from config into local states
9324
9560
  try {
9325
- if (Array.isArray(this.evcsList)) {
9561
+ if (provisionCount === undefined && Array.isArray(this.evcsList)) {
9326
9562
  for (const wb of this.evcsList) {
9327
9563
  await this.setStateAsync(`evcs.${wb.index}.name`, wb.name, true);
9328
9564
  await this.setStateAsync(`evcs.${wb.index}.note`, wb.note || '', true);
@@ -9338,7 +9574,7 @@ class NexoWattVis extends HostedAdapter {
9338
9574
  * Zusammenhang: Teil von Adapterkern: Lifecycle, Webserver, API, States, EMS-Engine; Aufrufstellen und abhängige States/APIs beim Ändern mitprüfen.
9339
9575
  * TypeScript: Parameter, Rückgabewert und verwendete Config-/State-Objekte später explizit typisieren.
9340
9576
  */
9341
- async ensureRfidStates() {
9577
+ async ensureRfidStates(provisionOnly = false) {
9342
9578
  // Base RFID states for EVCS access control (Whitelist + Learning)
9343
9579
  await this.setObjectNotExistsAsync('evcs.rfid', {
9344
9580
  type: 'channel',
@@ -9412,9 +9648,10 @@ class NexoWattVis extends HostedAdapter {
9412
9648
  });
9413
9649
  }
9414
9650
 
9415
- // Seed defaults only if states are missing (do not overwrite existing values)
9651
+ if (provisionOnly) return;
9652
+ // A database read failure must never replace an existing customer whitelist.
9416
9653
  for (const [id, c] of Object.entries(defs)) {
9417
- const st = await this.getStateAsync(id).catch(() => null);
9654
+ const st = await this.getStateAsync(id);
9418
9655
  if (!st || st.val === undefined || st.val === null) {
9419
9656
  await this.setStateAsync(id, c.def, true);
9420
9657
  }
@@ -11759,9 +11996,8 @@ async onReady() {
11759
11996
  this.log.debug('Live core refresh init failed: ' + (e && e.message ? e.message : e));
11760
11997
  }
11761
11998
 
11762
- // Cleanup: remove stale/orphaned dynamic objects no longer configured.
11763
- // This keeps the Objects tree tidy when mappings/counts are reduced.
11764
- try { await startupStep(() => this.cleanupOrphanedObjects()); } catch (_e) {}
11999
+ // Persisted device/history objects remain available when an app or device is disabled.
12000
+ // Removal requires an explicit maintenance operation, never startup/update.
11765
12001
 
11766
12002
  // Energy totals: if no kWh counters are mapped, derive totals from history/influxdb
11767
12003
  this._hostedStartupPhase = 'history';
@@ -11792,6 +12028,7 @@ async onReady() {
11792
12028
  if (this._nwShuttingDown) return;
11793
12029
  assertStartupAuthority();
11794
12030
  this._hostedStartup = { state: this.emsEngine ? 'ready' : 'degraded', error: this.emsEngine ? '' : 'EOS_EMS_INIT_FAILED' };
12031
+ this._bridge.deviceEmsConfigChanged?.();
11795
12032
  if (this.emsEngine) this.log.info('NexoWatt EOS ist bereit.');
11796
12033
  else this.log.warn('EOS_EMS_INIT_FAILED: Bedienoberfläche verfügbar, Betriebsstart unvollständig.');
11797
12034
  } catch (e) {
@@ -11871,9 +12108,12 @@ async onReady() {
11871
12108
 
11872
12109
  if (this.emsEngine && !doForce) return;
11873
12110
 
11874
- // Force: stop + drop existing engine so we can recover from init failures
11875
- if (doForce && this.emsEngine && typeof this.emsEngine.stop === 'function') {
11876
- try { this.emsEngine.stop(); } catch (_e) {}
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;
11877
12117
  }
11878
12118
 
11879
12119
  // Reset last error
@@ -12044,6 +12284,9 @@ async onReady() {
12044
12284
  await primeKey('tarif.statusText');
12045
12285
  await primeKey('tarif.netFeeMode');
12046
12286
  await primeKey('tariffProvider.currentPriceEurPerKwh');
12287
+ await primeKey('tariffProvider.averagePriceEurPerKwh');
12288
+ await primeKey('tariffProvider.fresh');
12289
+ await primeKey('tariffProvider.statusJson');
12047
12290
  await primeKey('chargingManagement.control.tsControlProductiveJson');
12048
12291
  await primeKey('chargingManagement.control.tsAllocationShadowJson');
12049
12292
  await primeKey('chargingManagement.control.tsAllocationProductivePrepJson');
@@ -15625,6 +15868,7 @@ app.get('/api/smarthome/type-detect', requireDpDiscovery, async (req, res) => {
15625
15868
  const _nwTariffSecretKeys = new Set(['accessToken','securityToken','clientSecret','bearerToken','apiKey','password','refreshToken']);
15626
15869
  const _nwMaskTariffProviderForUi = (cfg) => {
15627
15870
  const clone = this._nwDeepClone(cfg || {}) || {};
15871
+ if (clone?.tariffProvider) delete clone.tariffProvider.retainedProviderCredentials;
15628
15872
  const creds = clone && clone.tariffProvider && clone.tariffProvider.credentials;
15629
15873
  if (creds && typeof creds === 'object') {
15630
15874
  for (const key of Object.keys(creds)) {
@@ -15633,6 +15877,11 @@ app.get('/api/smarthome/type-detect', requireDpDiscovery, async (req, res) => {
15633
15877
  }
15634
15878
  return clone;
15635
15879
  };
15880
+ const stripRetainedTariffCredentials = (patch) => {
15881
+ const clean = this._nwDeepClone(patch || {}) || {};
15882
+ if (clean.tariffProvider) delete clean.tariffProvider.retainedProviderCredentials;
15883
+ return clean;
15884
+ };
15636
15885
  const _nwMergeTariffProviderSecrets = (incoming, existing) => {
15637
15886
  const next = this._nwDeepClone(incoming || {}) || {};
15638
15887
  const prev = existing && typeof existing === 'object' ? existing : {};
@@ -15676,6 +15925,7 @@ app.get('/api/smarthome/type-detect', requireDpDiscovery, async (req, res) => {
15676
15925
  app.get('/api/installer/config', requireInstaller, async (_req, res) => {
15677
15926
  try {
15678
15927
  sendNoStore(res);
15928
+ const configurationRevision = this._nwInstallerConfigRevision();
15679
15929
  // A license can be saved through the Admin tab while the App-Center is already open.
15680
15930
  // Refresh the runtime license cache here before filtering apps. This also covers the
15681
15931
  // startup edge case where the HTTP gate is open but _nwLicenseInfo has not yet been
@@ -15702,7 +15952,7 @@ app.get('/api/smarthome/type-detect', requireDpDiscovery, async (req, res) => {
15702
15952
  cfgOut.locale = this._nwBuildLocaleInfo();
15703
15953
  cfgOut.countryProfile = Object.assign({}, cfgOut.countryProfile || {}, this._nwBuildCountryProfileInfo());
15704
15954
  cfgOut.regressionSafety = this._nwInstallerRegressionSafetyLastReport || { schema: 'nexowatt.installer-regression-safety.v1', ok: true, checks: [] };
15705
- res.json({ ok: true, license: cfgOut.license, config: cfgOut });
15955
+ res.json({ ok: true, license: cfgOut.license, config: cfgOut, configurationRevision });
15706
15956
  } catch (e) {
15707
15957
  this.log.warn('Installer config API error: ' + e.message);
15708
15958
  res.status(500).json({ ok: false, error: 'internal error' });
@@ -15716,6 +15966,7 @@ app.get('/api/smarthome/type-detect', requireDpDiscovery, async (req, res) => {
15716
15966
  try {
15717
15967
  sendNoStore(res);
15718
15968
  const body = req.body || {};
15969
+ this._nwAssertInstallerConfigRevision(body.expectedConfigurationRevision);
15719
15970
  const patch = body.patch && typeof body.patch === 'object' ? body.patch : {};
15720
15971
  const restartEms = body.restartEms !== false; // default true
15721
15972
  const tokenError = nwValidateStationTokenChanges(patch);
@@ -15862,72 +16113,19 @@ app.get('/api/smarthome/type-detect', requireDpDiscovery, async (req, res) => {
15862
16113
  try { this._meshCoordinator?.assertAppChange(this.nwApplyInstallerPatchToRuntimeConfig(this.config, mergedPatch)); }
15863
16114
  catch (error) { const failure = safeConfigurationFailure(error); return res.status(failure.status).json(failure.body); }
15864
16115
  // Persist patch to states (no ioBroker restart)
16116
+ await this._nwProvisionInstallerObjects(this.nwApplyInstallerPatchToRuntimeConfig(this.config, mergedPatch));
15865
16117
  if (await this.persistInstallerConfigToState(mergedPatch) === false) throw new Error('Installer-Konfiguration konnte nicht gespeichert werden.');
15866
16118
  this._nwInstallerConfigPatch = mergedPatch;
15867
16119
 
15868
16120
  // Persist an additional uninstall-proof backup into 0_userdata.0 (best-effort)
15869
16121
  try { await this.nwWriteUserdataBackup(mergedPatch, 'config-save'); } catch (_e) {}
15870
16122
 
16123
+ // Pause old writers before exposing the new mappings to runtime consumers.
16124
+ if (restartEms && this.emsEngine?.stopForReconfigure) await this.emsEngine.stopForReconfigure();
15871
16125
  // Apply patch to runtime config (App-Center SoT: replace installer-managed sections)
15872
16126
  this.config = (this.config && typeof this.config === 'object') ? this.config : {};
15873
16127
  this.config = this.nwApplyInstallerPatchToRuntimeConfig(this.config, mergedPatch);
15874
- await this._meshCoordinator?.syncAppLifecycle();
15875
-
15876
- // Apply updated VIS/EVCS configuration to runtime (best-effort)
15877
-
15878
- try { await this.syncInstallerConfigToStates(); } catch (_e) {}
15879
- try { await this.syncSettingsToStates(); } catch (_e) {}
15880
- try { await this.syncSettingsConfigToStates(); } catch (_e) {}
15881
- try { await this.ensureEvcsStates(); } catch (_e) {}
15882
- try { await this.ensureRfidStates(); } catch (_e) {}
15883
- try { await this.subscribeEvcsMappedStates(); } catch (_e) {}
15884
-
15885
- // Re-subscribe to mapped states so the VIS immediately sees fresh values
15886
- try {
15887
- if (typeof this.subscribeConfiguredStates === 'function') {
15888
- await this.subscribeConfiguredStates();
15889
- }
15890
- } catch (_e) {}
15891
-
15892
- // Historie/Influx: when optional Verbraucher/Erzeuger are added in the App-Center,
15893
- // create the canonical nexowatt-ui.0.historie.* states immediately. Previously this
15894
- // only happened on adapter startup, so newly connected producer slots appeared in
15895
- // the History UI but had no object/influx binding until a restart.
15896
- try {
15897
- if (this._nwHistoryApiCache instanceof Map) this._nwHistoryApiCache.clear();
15898
- if (this._nwHistoryApiInflight instanceof Map) this._nwHistoryApiInflight.clear();
15899
- await this.ensureHistorieExportStates();
15900
- await this.updateHistorieExportStates('config-save');
15901
- this.startHistorieExportTimer();
15902
- } catch (e) {
15903
- try { this.log.debug('Historie refresh after config save failed: ' + (e && e.message ? e.message : e)); } catch (_e2) {}
15904
- }
15905
-
15906
- // StorageFarm: derived status + scheduler in sync after installer save
15907
- try { await this.ensureStorageFarmStates(); } catch (_e) {}
15908
- try { await this.syncStorageFarmDefaultsToStates(); } catch (_e) {}
15909
- try { await this.syncStorageFarmConfigFromAdmin(); } catch (_e) {}
15910
- try {
15911
- if (this._nwStorageFarmTimer) {
15912
- this._nwClearInterval(this._nwStorageFarmTimer);
15913
- this._nwStorageFarmTimer = null;
15914
- }
15915
-
15916
- const enabledSf = !!this._nwGetStorageFarmRuntimeInfo().active;
15917
- const sfCfg = (this.config && this.config.storageFarm && typeof this.config.storageFarm === 'object') ? this.config.storageFarm : {};
15918
- const interval = (sfCfg.schedulerIntervalMs !== undefined && sfCfg.schedulerIntervalMs !== null && Number.isFinite(Number(sfCfg.schedulerIntervalMs)))
15919
- ? Math.max(250, Math.min(1000, Math.round(Number(sfCfg.schedulerIntervalMs))))
15920
- : 1000;
15921
-
15922
- if (enabledSf) {
15923
- await this.updateStorageFarmDerived('config-save');
15924
- this._nwStorageFarmTimer = this._nwSetInterval(() => { this.updateStorageFarmDerived('timer').catch(() => {}); }, interval);
15925
- }
15926
- } catch (_e) {}
15927
-
15928
- if (restartEms) {
15929
- await _nwRestartEms();
15930
- }
16128
+ await this._nwApplyInstallerRuntime(restartEms, 'config-save');
15931
16129
 
15932
16130
  try { await this._nwInitLicense(); } catch (e) { try { this.log.warn('License refresh after installer config save failed: ' + (e && e.message ? e.message : e)); } catch (_eLog) {} }
15933
16131
  let cfgOut = await _nwHydrateStorageFarmConfigFromRuntimeStates(_nwPickPersistedInstallerConfig());
@@ -15943,7 +16141,8 @@ app.get('/api/smarthome/type-detect', requireDpDiscovery, async (req, res) => {
15943
16141
  cfgOut.license = this._nwBuildLicenseFeatureInfo();
15944
16142
  cfgOut.locale = this._nwBuildLocaleInfo();
15945
16143
  cfgOut.countryProfile = Object.assign({}, cfgOut.countryProfile || {}, this._nwBuildCountryProfileInfo());
15946
- res.json({ ok: true, license: cfgOut.license, config: cfgOut, restarted: !!restartEms });
16144
+ res.json({ ok: true, license: cfgOut.license, config: cfgOut, restarted: !!restartEms, configurationRevision: this._nwInstallerConfigRevision() });
16145
+ this._bridge.deviceEmsConfigChanged?.();
15947
16146
  } catch (e) {
15948
16147
  this.log.warn('Installer config save API error: ' + safeConfigurationFailure(e).body.error);
15949
16148
  // Send a concise message to the frontend to avoid "Speichern fehlgeschlagen" without context.
@@ -15966,7 +16165,7 @@ app.get('/api/smarthome/type-detect', requireDpDiscovery, async (req, res) => {
15966
16165
  adapter: 'nexowatt-ui',
15967
16166
  adapterVersion: (pkg && pkg.version) ? String(pkg.version) : '',
15968
16167
  instance: this.instance,
15969
- configPatch: patch,
16168
+ configPatch: stripRetainedTariffCredentials(patch),
15970
16169
  };
15971
16170
  res.json({ ok: true, backup });
15972
16171
  } catch (e) {
@@ -15998,7 +16197,7 @@ app.get('/api/smarthome/type-detect', requireDpDiscovery, async (req, res) => {
15998
16197
  reason: backup.reason || '',
15999
16198
  bytes,
16000
16199
  },
16001
- backup,
16200
+ backup: { ...backup, configPatch: stripRetainedTariffCredentials(backup.configPatch) },
16002
16201
  });
16003
16202
  } catch (e) {
16004
16203
  const msg = (e && e.message) ? String(e.message) : 'internal error';
@@ -16012,6 +16211,7 @@ app.get('/api/smarthome/type-detect', requireDpDiscovery, async (req, res) => {
16012
16211
  if (!meshSaveToken) return res.status(409).json({ error: 'Konfiguration wird bereits gespeichert.' });
16013
16212
  try {
16014
16213
  const body = req.body || {};
16214
+ this._nwAssertInstallerConfigRevision(body.expectedConfigurationRevision);
16015
16215
  const restartEms = body.restartEms !== false; // default true
16016
16216
  const mode = String(body.mode || 'replace').toLowerCase(); // replace | merge
16017
16217
 
@@ -16115,52 +16315,19 @@ app.get('/api/smarthome/type-detect', requireDpDiscovery, async (req, res) => {
16115
16315
  if (!storageLicenseValidation.ok) return res.status(400).json(storageLicenseValidation);
16116
16316
  try { this._meshCoordinator?.assertAppChange(this.nwApplyInstallerPatchToRuntimeConfig(baseNative, finalPatch)); }
16117
16317
  catch (error) { const failure = safeConfigurationFailure(error); return res.status(failure.status).json(failure.body); }
16318
+ await this._nwProvisionInstallerObjects(this.nwApplyInstallerPatchToRuntimeConfig(baseNative, finalPatch));
16118
16319
  if (await this.persistInstallerConfigToState(finalPatch) === false) throw new Error('Installer-Import konnte nicht gespeichert werden.');
16119
16320
  this._nwInstallerConfigPatch = finalPatch;
16120
16321
 
16322
+ // Pause old writers before exposing the imported mappings.
16323
+ if (restartEms && this.emsEngine?.stopForReconfigure) await this.emsEngine.stopForReconfigure();
16121
16324
  // Apply patch as SoT (replace installer-managed sections)
16122
16325
  this.config = this.nwApplyInstallerPatchToRuntimeConfig(baseNative, finalPatch);
16123
- await this._meshCoordinator?.syncAppLifecycle();
16124
-
16125
- // Apply updated config to runtime (best-effort)
16126
- try { await this.syncInstallerConfigToStates(); } catch (_e) {}
16127
- try { await this.syncSettingsToStates(); } catch (_e) {}
16128
- try { await this.syncSettingsConfigToStates(); } catch (_e) {}
16129
- try { await this.ensureEvcsStates(); } catch (_e) {}
16130
- try { await this.ensureRfidStates(); } catch (_e) {}
16131
- try { await this.subscribeEvcsMappedStates(); } catch (_e) {}
16132
-
16133
- // Re-subscribe to mapped states so the VIS immediately sees fresh values
16134
- try {
16135
- if (typeof this.subscribeConfiguredStates === 'function') {
16136
- await this.subscribeConfiguredStates();
16137
- }
16138
- } catch (_e) {}
16139
-
16140
- // Historie/Influx: provision canonical optional series immediately after import.
16141
- try {
16142
- if (this._nwHistoryApiCache instanceof Map) this._nwHistoryApiCache.clear();
16143
- if (this._nwHistoryApiInflight instanceof Map) this._nwHistoryApiInflight.clear();
16144
- await this.ensureHistorieExportStates();
16145
- await this.updateHistorieExportStates('import');
16146
- this.startHistorieExportTimer();
16147
- } catch (e) {
16148
- try { this.log.debug('Historie refresh after import failed: ' + (e && e.message ? e.message : e)); } catch (_e2) {}
16149
- }
16150
-
16151
- // StorageFarm: derived status + scheduler in sync after import
16152
- try { await this.ensureStorageFarmStates(); } catch (_e) {}
16153
- try { await this.syncStorageFarmDefaultsToStates(); } catch (_e) {}
16154
- try { await this.syncStorageFarmConfigFromAdmin(); } catch (_e) {}
16155
-
16156
- // Persist uninstall-proof backup
16326
+ await this._nwApplyInstallerRuntime(restartEms, 'import');
16157
16327
  try { await this.nwWriteUserdataBackup(finalPatch, 'import'); } catch (_e) {}
16158
16328
 
16159
- if (restartEms) {
16160
- await _nwRestartEms();
16161
- }
16162
-
16163
- res.json({ ok: true, imported: true, restarted: !!restartEms, config: _nwPickPersistedInstallerConfig() });
16329
+ res.json({ ok: true, imported: true, restarted: !!restartEms, config: _nwPickPersistedInstallerConfig(), configurationRevision: this._nwInstallerConfigRevision() });
16330
+ this._bridge.deviceEmsConfigChanged?.();
16164
16331
  } catch (e) {
16165
16332
  const failure = safeConfigurationFailure(e);
16166
16333
  res.status(failure.status).json(failure.body);
@@ -16867,6 +17034,64 @@ app.get('/api/smarthome/type-detect', requireDpDiscovery, async (req, res) => {
16867
17034
  // auto-fill App-Center mappings (EVCS / PV‑Regelung / Thermik / §14a).
16868
17035
  //
16869
17036
  // IMPORTANT: This endpoint only discovers; it never writes config.
17037
+ // Der Kundentarif gilt für die gesamte Anlage. Der Kunde kann ausschließlich
17038
+ // Anbieter/Vertragswerte wählen; Anlagenfreigaben und freie DP-Pfade bleiben geschützt.
17039
+ const requireCustomerTariff = async (req, res, next) => {
17040
+ if (!['customer', 'installer', 'admin'].includes(req.nwSession?.role)) return res.status(403).json({ ok: false, error: 'forbidden' });
17041
+ if (!this._nwIsFeatureLicensed('dynamicTariffs')) return res.status(403).json({ ok: false, error: 'EOS_TARIFF_LICENSE_REQUIRED' });
17042
+ return next();
17043
+ };
17044
+ const customerTariffSnapshot = () => {
17045
+ const root = this.nwApplyInstallerPatchToRuntimeConfig(this.config || {}, this._nwInstallerConfigPatch || {});
17046
+ return { ok: true, revision: this._nwInstallerConfigRevision(),
17047
+ ...customerTariffView(root, this.namespace, tariffProviderRegistry.publicRegistry(), this._tariffProviderSnapshot) };
17048
+ };
17049
+ app.get('/api/customer/tariff-provider', requireCustomerWorkspace, requireCustomerTariff, (_req, res) => {
17050
+ try { sendNoStore(res); res.json(customerTariffSnapshot()); }
17051
+ catch (error) { const failure = safeConfigurationFailure(error); res.status(failure.status).json(failure.body); }
17052
+ });
17053
+ app.put('/api/customer/tariff-provider', requireCustomerWorkspace, requireCustomerTariff, async (req, res) => {
17054
+ const token = beginMeshAppSave();
17055
+ if (!token) return res.status(409).json({ ok: false, error: 'EOS_TARIFF_BUSY', message: 'Eine Einstellung wird gerade gespeichert. Bitte kurz warten.' });
17056
+ try {
17057
+ sendNoStore(res);
17058
+ const body = req.body;
17059
+ if (!body || typeof body !== 'object' || Array.isArray(body)
17060
+ || Object.keys(body).some(key => !['expectedRevision', 'config'].includes(key))) {
17061
+ throw createPublicHttpError(422, 'EOS_TARIFF_INVALID', 'Die Tarifanfrage enthält unzulässige Felder.');
17062
+ }
17063
+ // Unlike legacy installer clients, this new API always requires a freshly loaded revision.
17064
+ if (typeof body.expectedRevision !== 'string' || body.expectedRevision !== this._nwInstallerConfigRevision()) {
17065
+ throw createPublicHttpError(409, 'EOS_TARIFF_CONFIG_CHANGED', 'Die Anlageneinstellungen wurden inzwischen geändert. Bitte den Tarif neu laden und deine Eingaben vergleichen.');
17066
+ }
17067
+ if (this._nwShuttingDown || this._bridge.canWrite() !== true) throw createPublicHttpError(409, 'EOS_UI_OWNERSHIP_REQUIRED', 'Die Systemfreigabe ist nicht verfügbar.');
17068
+ const effective = this.nwApplyInstallerPatchToRuntimeConfig(this.config || {}, this._nwInstallerConfigPatch || {});
17069
+ const changed = prepareCustomerTariffChange(effective, body.config, this.namespace, tariffProviderRegistry.publicRegistry());
17070
+ const patch = this._nwDeepClone(this._nwInstallerConfigPatch || {});
17071
+ patch.tariffProvider = changed.tariffProvider;
17072
+ if (changed.datapoints) patch.datapoints = changed.datapoints;
17073
+ if (await this.persistInstallerConfigToState(patch) === false) throw createPublicHttpError(503, 'EOS_TARIFF_SAVE_FAILED', 'Der Tarif konnte nicht gespeichert werden. Bisherige Einstellungen bleiben bestehen.');
17074
+ this._nwInstallerConfigPatch = patch;
17075
+ this._nwInstallerConfigRawPatch = this._nwDeepClone(patch);
17076
+ this.config = this.nwApplyInstallerPatchToRuntimeConfig(this.config || {}, patch);
17077
+ try {
17078
+ const tariffModule = this.emsEngine?.mm?.modules?.find(entry => entry.key === 'tariffProvider')?.instance;
17079
+ if (tariffModule && typeof tariffModule.invalidateConfiguration === 'function') await tariffModule.invalidateConfiguration();
17080
+ if (changed.datapoints && tariffModule && typeof tariffModule.applyTariffMappings === 'function') await tariffModule.applyTariffMappings();
17081
+ // No EMS restart and no actuator activation. Changed read mappings use existing subscriptions.
17082
+ if (changed.datapoints) await this.subscribeConfiguredStates();
17083
+ } catch (_error) {
17084
+ throw createPublicHttpError(503, 'EOS_TARIFF_APPLY_PENDING', 'Der Tarif ist gespeichert. Die Übernahme der neuen Preisquelle ist noch nicht bestätigt; bitte Status neu laden.');
17085
+ }
17086
+ try { await this.nwWriteUserdataBackup(patch, 'customer-tariff'); }
17087
+ catch (_error) { this.log.warn('EOS_TARIFF_BACKUP_FAILED: Tarif gespeichert; zusätzliche Sicherung fehlgeschlagen.'); }
17088
+ res.json(customerTariffSnapshot());
17089
+ } catch (error) {
17090
+ const failure = safeConfigurationFailure(error);
17091
+ res.status(failure.status).json(failure.body);
17092
+ } finally { endMeshAppSave(token); }
17093
+ });
17094
+
16870
17095
  // Dynamische Tarife: Provider-Katalog und Verbindungstest. Die APIs sind
16871
17096
  // installergeschützt und geben niemals Token/Secrets zurück.
16872
17097
  app.get('/api/installer/tariff-provider/providers', requireInstaller, async (_req, res) => {
@@ -16925,16 +17150,20 @@ app.get('/api/smarthome/type-detect', requireDpDiscovery, async (req, res) => {
16925
17150
  app.get('/api/nwdevices/discover', requireInstaller, async (_req, res) => {
16926
17151
  try {
16927
17152
  const now = Date.now();
16928
- const devChannels = await this.getForeignObjectsAsync('nexowatt-devices.*.devices.*', 'channel').catch(() => ({}));
16929
- const stateObjects = await this.getForeignObjectsAsync('nexowatt-devices.*.devices.*', 'state').catch(() => ({}));
16930
- const manifestStates = (typeof this.getForeignStatesAsync === 'function')
16931
- ? await this.getForeignStatesAsync('nexowatt-devices.*.devices.*.aliases.meta.manifest').catch(() => ({}))
16932
- : {};
17153
+ const patterns = ['nexowatt-devices.*.devices.*', `${this._owner.namespace}.devices.*`];
17154
+ const devChannels = {}; const stateObjects = {}; const manifestStates = {};
17155
+ for (const pattern of patterns) {
17156
+ Object.assign(devChannels, await this.getForeignObjectsAsync(pattern, 'channel'));
17157
+ Object.assign(stateObjects, await this.getForeignObjectsAsync(pattern, 'state'));
17158
+ if (typeof this.getForeignStatesAsync === 'function') {
17159
+ Object.assign(manifestStates, await this.getForeignStatesAsync(`${pattern}.aliases.meta.manifest`));
17160
+ }
17161
+ }
16933
17162
 
16934
17163
  const statesByDev = new Map();
16935
17164
  for (const [stateId, obj] of Object.entries(stateObjects || {})) {
16936
17165
  const sid = String(stateId || '');
16937
- const match = sid.match(/^(nexowatt-devices\.\d+\.devices\.[^.]+)\./);
17166
+ const match = sid.match(/^((?:nexowatt-devices|eos-admin)\.\d+\.devices\..+)\.aliases\./);
16938
17167
  if (!match) continue;
16939
17168
  if (!statesByDev.has(match[1])) statesByDev.set(match[1], {});
16940
17169
  statesByDev.get(match[1])[sid] = obj;
@@ -16977,13 +17206,15 @@ app.get('/api/smarthome/type-detect', requireDpDiscovery, async (req, res) => {
16977
17206
 
16978
17207
  for (const [baseRaw, channelObj] of Object.entries(devChannels || {})) {
16979
17208
  const baseId = String(baseRaw || '');
16980
- const match = baseId.match(/^(nexowatt-devices\.\d+)\.devices\.([^.]+)$/);
17209
+ const match = baseId.match(/^((?:nexowatt-devices|eos-admin)\.\d+)\.devices\.(.+)$/);
16981
17210
  if (!match) continue;
16982
17211
  const instance = match[1];
16983
17212
  const devId = match[2];
16984
17213
  instances.add(instance);
16985
17214
  const common = channelObj && channelObj.common && typeof channelObj.common === 'object' ? channelObj.common : {};
16986
17215
  const native = channelObj && channelObj.native && typeof channelObj.native === 'object' ? channelObj.native : {};
17216
+ // Alias/group channels are not devices; dotted device IDs retain their full identity.
17217
+ if (!native.category && !Object.hasOwn(manifestStates, `${baseId}.aliases.meta.manifest`)) continue;
16987
17218
  const devStates = statesByDev.get(baseId) || {};
16988
17219
  const manifest = parseManifest(baseId) || {};
16989
17220
  const category = String(native.category || manifest.category || '').trim();
@@ -22728,10 +22959,10 @@ app.get('/config', async (req, res) => {
22728
22959
  : false;
22729
22960
  // Stale Runtime-States und Legacy-enableStorageFarm dürfen die Kundenansicht
22730
22961
  // nicht öffnen. Sichtbar ist die Farm nur bei AppCenter installed+enabled und
22731
- // mindestens zwei echten Speicherzeilen; dieselbe Zeilenerkennung nutzt auch
22962
+ // mindestens einer echten Speicherzeile; dieselbe Zeilenerkennung nutzt auch
22732
22963
  // Aggregation und Scheduler.
22733
22964
  const storageFarmConfiguredCount = storageRowsFromConfig.filter(storageFarmRowHasRealDatapoint).length;
22734
- const storageFarmConfigured = storageFarmConfiguredCount >= 2;
22965
+ const storageFarmConfigured = storageFarmConfiguredCount >= 1;
22735
22966
  const storageFarmAvailable = !!(storageFarmAppActive && storageFarmConfigured);
22736
22967
 
22737
22968
  const smartHomeCustomerEnabled = smartHomeEnabled(cfg, this._nwNativeConfigBase);
@@ -22898,6 +23129,7 @@ app.get('/config', async (req, res) => {
22898
23129
  const sess = authEnabled ? await resolveAccess(req) : null;
22899
23130
 
22900
23131
  const nwConfigPayload = {
23132
+ tariffDisplay: tariffDisplayConfig(cfg, this.namespace),
22901
23133
  locale: this._nwBuildLocaleInfo(),
22902
23134
  countryProfile: this._nwBuildCountryProfileInfo(),
22903
23135
  units: cfg.units || { power: 'W', energy: 'kWh' },
@@ -26865,6 +27097,7 @@ return res.json(out);
26865
27097
  'totalSoc', 'medianSoc', 'totalSocOnline', 'capacityWeightedSoc', 'capacityWeightedSocOnline',
26866
27098
  'socSourcesTotal', 'socSourcesOnline', 'socDegraded',
26867
27099
  'totalPowerW', 'powerSourcesTotal', 'powerSourcesOnline', 'totalChargePowerW', 'totalDischargePowerW',
27100
+ 'totalBatteryPowerW', 'totalBatteryChargePowerW', 'totalBatteryDischargePowerW', 'displayMeanSoc', 'totalCapacityKWh', 'overviewJson',
26868
27101
  'totalPvPowerW', 'totalPvAcPowerW', 'totalPvDcPowerW', 'totalPvUnknownPowerW',
26869
27102
  'pvSourcesTotal', 'pvSourcesOnline', 'pvSourcesJson',
26870
27103
  'storagesOnline', 'storagesDegraded', 'storagesDispatchAvailable',
@@ -27984,8 +28217,7 @@ return res.json(out);
27984
28217
  try {
27985
28218
  const rec = this.stateCache && this.stateCache[key];
27986
28219
  if (!rec) return null;
27987
- const n = Number(rec.value);
27988
- return Number.isFinite(n) ? n : null;
28220
+ return numericMeasurement(rec.value);
27989
28221
  } catch (_e) {
27990
28222
  return null;
27991
28223
  }
@@ -28019,8 +28251,8 @@ return res.json(out);
28019
28251
  try {
28020
28252
  const rec = this.stateCache && this.stateCache[key];
28021
28253
  if (!rec) return fallback;
28022
- const n = Number(rec.value);
28023
- if (!Number.isFinite(n)) return fallback;
28254
+ const n = numericMeasurement(rec.value);
28255
+ if (n === null) return fallback;
28024
28256
  const maxAge = Number(maxAgeMs);
28025
28257
  if (Number.isFinite(maxAge) && maxAge > 0) {
28026
28258
  const age = this._nwGetCacheAgeMs(key, now);
@@ -28042,8 +28274,8 @@ return res.json(out);
28042
28274
  try {
28043
28275
  const rec = (this._nwRawValueCache && this._nwRawValueCache[key]) || (this.stateCache && this.stateCache[key]);
28044
28276
  if (!rec) return fallback;
28045
- const n = Number(rec.value);
28046
- if (!Number.isFinite(n)) return fallback;
28277
+ const n = numericMeasurement(rec.value);
28278
+ if (n === null) return fallback;
28047
28279
  const maxAge = Number(maxAgeMs);
28048
28280
  if (Number.isFinite(maxAge) && maxAge > 0) {
28049
28281
  const ts = Number(rec.ts);
@@ -28100,7 +28332,7 @@ return res.json(out);
28100
28332
  // Runtime-States sind Ergebnisse dieser Konfiguration und dürfen sie nicht
28101
28333
  // rückwärts durch einen alten false-/0-Wert überschreiben.
28102
28334
  const runtimeInfo = this._nwGetStorageFarmRuntimeInfo();
28103
- return !!(runtimeInfo.active && Number(runtimeInfo.configuredCount || 0) >= 2);
28335
+ return !!(runtimeInfo.active && Number(runtimeInfo.configuredCount || 0) >= 1);
28104
28336
  } catch (_e) {
28105
28337
  return false;
28106
28338
  }
@@ -28116,23 +28348,24 @@ return res.json(out);
28116
28348
  const now = Number.isFinite(Number(opts.now)) ? Number(opts.now) : Date.now();
28117
28349
  const active = this._nwStorageFarmIsActiveFromCache();
28118
28350
  const read = (key) => {
28119
- const value = this._nwGetNumberFromCache(key);
28120
- return Number.isFinite(Number(value)) ? Number(value) : null;
28351
+ return this._nwGetNumberFromCache(key);
28121
28352
  };
28122
28353
 
28123
28354
  const grossChargeW = Math.max(0, Math.abs(read('storageFarm.totalChargePowerW') || 0));
28124
28355
  const grossDischargeW = Math.max(0, Math.abs(read('storageFarm.totalDischargePowerW') || 0));
28125
28356
  const powerSourcesTotal = Math.max(0, Math.round(read('storageFarm.powerSourcesTotal') || 0));
28357
+ const hasBatteryFlow = Object.prototype.hasOwnProperty.call(this.stateCache || {}, 'storageFarm.totalBatteryPowerW');
28358
+ const batteryFlowState = read('storageFarm.totalBatteryPowerW');
28126
28359
  const signedState = read('storageFarm.totalPowerW');
28127
28360
 
28128
28361
  // Nach einem Update kann der neu angelegte totalPowerW-State kurz 0 W enthalten,
28129
28362
  // während die bereits vorhandenen Brutto-States noch den echten Farmfluss zeigen.
28130
28363
  // Erst nach mindestens einer ausgewerteten Leistungsquelle ist totalPowerW führend.
28131
- const signedW = (signedState !== null && (powerSourcesTotal > 0 || (grossChargeW <= 0 && grossDischargeW <= 0)))
28132
- ? signedState
28133
- : (grossDischargeW - grossChargeW);
28134
- const chargeW = signedW < 0 ? Math.abs(signedW) : 0;
28135
- const dischargeW = signedW > 0 ? signedW : 0;
28364
+ const signedW = hasBatteryFlow ? batteryFlowState
28365
+ : (signedState !== null && (powerSourcesTotal > 0 || (grossChargeW <= 0 && grossDischargeW <= 0)))
28366
+ ? signedState : (grossDischargeW - grossChargeW);
28367
+ const chargeW = signedW === null ? null : signedW < 0 ? Math.abs(signedW) : 0;
28368
+ const dischargeW = signedW === null ? null : signedW > 0 ? signedW : 0;
28136
28369
 
28137
28370
  const pvTotalState = Math.max(0, Math.abs(read('storageFarm.totalPvPowerW') || 0));
28138
28371
  let pvAcW = Math.max(0, Math.abs(read('storageFarm.totalPvAcPowerW') || 0));
@@ -28158,9 +28391,9 @@ return res.json(out);
28158
28391
  return {
28159
28392
  active,
28160
28393
  soc: read('storageFarm.totalSoc'),
28161
- totalPowerW: Math.round(signedW),
28162
- chargeW: Math.round(chargeW),
28163
- dischargeW: Math.round(dischargeW),
28394
+ totalPowerW: signedW === null ? null : Math.round(signedW),
28395
+ chargeW: chargeW === null ? null : Math.round(chargeW),
28396
+ dischargeW: dischargeW === null ? null : Math.round(dischargeW),
28164
28397
  grossChargeW: Math.round(grossChargeW),
28165
28398
  grossDischargeW: Math.round(grossDischargeW),
28166
28399
  pvTotalW: Math.round(pvTotalW),
@@ -28169,7 +28402,7 @@ return res.json(out);
28169
28402
  pvUnknownW: Math.round(pvUnknownW),
28170
28403
  pvSources,
28171
28404
  ageMs: {
28172
- totalPowerW: this._nwGetCacheAgeMs('storageFarm.totalPowerW', now),
28405
+ totalPowerW: this._nwGetCacheAgeMs(hasBatteryFlow ? 'storageFarm.totalBatteryPowerW' : 'storageFarm.totalPowerW', now),
28173
28406
  totalSoc: this._nwGetCacheAgeMs('storageFarm.totalSoc', now),
28174
28407
  totalPvPowerW: this._nwGetCacheAgeMs('storageFarm.totalPvPowerW', now),
28175
28408
  },
@@ -28443,8 +28676,8 @@ return res.json(out);
28443
28676
  : null;
28444
28677
  const sfEnabled = !!(farmMetrics && farmMetrics.active);
28445
28678
  if (farmSelectedForControl) {
28446
- let signed = farmMetrics ? Number(farmMetrics.totalPowerW) : NaN;
28447
- if (Number.isFinite(signed)) {
28679
+ let signed = farmMetrics ? numericMeasurement(farmMetrics.totalPowerW) : null;
28680
+ if (signed !== null && Number.isFinite(signed)) {
28448
28681
  // storageFarm.totalPowerW ist bereits pro Speicher normalisiert und besitzt
28449
28682
  // eine feste Konvention (+ Entladen / - Laden). Das globale Einzel-Speicher-
28450
28683
  // Anzeige-Invert darf diesen kanonischen Farmwert nicht ein zweites Mal drehen.
@@ -28886,8 +29119,6 @@ return res.json(out);
28886
29119
  available: false,
28887
29120
  source: 'js-mode',
28888
29121
  mode,
28889
- userMode,
28890
- userEnabled,
28891
29122
  ok: true,
28892
29123
  mismatches: [],
28893
29124
  runtime: runtimeValues,
@@ -28932,8 +29163,6 @@ return res.json(out);
28932
29163
  available: true,
28933
29164
  source: mode === 'ts' ? 'ts-mirror-switch-candidate' : 'ts-mirror-shadow',
28934
29165
  mode,
28935
- userMode,
28936
- userEnabled,
28937
29166
  ok: mismatches.length === 0,
28938
29167
  mismatches,
28939
29168
  runtime: runtimeValues,
@@ -33936,6 +34165,14 @@ function createHostedRuntime(owner, bridge) {
33936
34165
  }
33937
34166
  await startPromise;
33938
34167
  },
34168
+ reserveDeviceProfileChange(input) {
34169
+ if (stopRequested) return Promise.reject(Object.assign(new Error('EOS_DEVICES_PROFILE_CHECK_UNAVAILABLE'), { code: 'EOS_DEVICES_PROFILE_CHECK_UNAVAILABLE' }));
34170
+ return runtime.reserveDeviceProfileChange(input);
34171
+ },
34172
+ reconcileDeviceEms(devices) {
34173
+ if (stopRequested) return Promise.reject(new Error('EOS_UI_STOPPING'));
34174
+ return runtime.reconcileDeviceEms(devices);
34175
+ },
33939
34176
  startOperational() { if (!stopRequested) operationalArmed = true; return startOperational(); },
33940
34177
  handle(req, res, next) {
33941
34178
  if (!started || stopRequested || !runtime._hostedApp) return res.status(503).json({ error: 'EOS_UI_UNAVAILABLE' });