iobroker.eos-admin 9.0.33 → 9.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/NEXOWATT_EOS_BUILD_INFO.json +10 -11
  2. package/README.md +7 -9
  3. package/adminWww/.vite/manifest.json +233 -224
  4. package/adminWww/NEXOWATT_EOS_FRONTEND_MANIFEST.json +13897 -13887
  5. package/adminWww/assets/AccessTime-CuR73YC3.js +1 -0
  6. package/adminWww/assets/{AdapterUpdateDialog-DBUqmmyD.js → AdapterUpdateDialog-5L75o18m.js} +5 -5
  7. package/adminWww/assets/{Adapters-dDEp7o5h.js → Adapters-FcghjF7E.js} +5 -5
  8. package/adminWww/assets/ConfigManager-BnHarBfH.js +1 -0
  9. package/adminWww/assets/Enums-BjLbLLQL.js +92 -0
  10. package/adminWww/assets/Fields-DDE1hVOa.js +1 -0
  11. package/adminWww/assets/Files-CDjnR4q6.js +1 -0
  12. package/adminWww/assets/{Hosts-CwU1LujG.js → Hosts-CJKQaNrD.js} +6 -6
  13. package/adminWww/assets/Instances-DZNl369k.js +4 -0
  14. package/adminWww/assets/Intro-CjAmMGDB.js +2 -0
  15. package/adminWww/assets/KeyboardArrowRight-ifvmV1ZL.js +1 -0
  16. package/adminWww/assets/{Logs-B5SpNqHq.js → Logs-rUAV7SwM.js} +2 -2
  17. package/adminWww/assets/MoreHoriz-CS7nODK8.js +1 -0
  18. package/adminWww/assets/{Objects-COg_cFkz.js → Objects-CqOH6rT_.js} +4 -4
  19. package/adminWww/assets/Overview-BOtXqsMy.js +3 -0
  20. package/adminWww/assets/Pageview-wzrLQZ-j.js +1 -0
  21. package/adminWww/assets/PersonOff-YtHcY0sV.js +1 -0
  22. package/adminWww/assets/Star-D8VNXawT.js +1 -0
  23. package/adminWww/assets/State-C8ncThop.js +1 -0
  24. package/adminWww/assets/UsedResources-lUYJqy4F.js +2 -0
  25. package/adminWww/assets/Users-CK1Cax82.js +1 -0
  26. package/adminWww/assets/ViewCompact-D7bHgn99.js +1 -0
  27. package/adminWww/assets/ViewSidebar-CjClbCI5.js +1 -0
  28. package/adminWww/assets/WifiTethering-DJ9VO12W.js +1 -0
  29. package/adminWww/assets/{bootstrap-Dwfxhm2V.js → bootstrap-CC0Qr-kr.js} +25 -25
  30. package/adminWww/assets/date-fns-BtR4dG_j.js +1 -0
  31. package/adminWww/assets/en-US-BjjaEI6N.js +1 -0
  32. package/adminWww/assets/{hostInit-3BbTwhaZ.js → hostInit-DqGL6nY8.js} +1 -1
  33. package/adminWww/assets/icons-material-07rWS63O.js +1 -0
  34. package/adminWww/assets/{index-nddph2Sl.js → index-BhhkToP2.js} +2 -2
  35. package/adminWww/assets/{installSVGRenderer-CPDIwFAL.js → installSVGRenderer-B4-7lSQZ.js} +1 -1
  36. package/adminWww/assets/isSameWeek-WMSJR5Qs.js +1 -0
  37. package/adminWww/assets/locale-DN6Bdkdt.js +1 -0
  38. package/adminWww/assets/{mf-entry-bootstrap-0-d1f0f40f.js → mf-entry-bootstrap-0-1afd2287.js} +2 -2
  39. package/adminWww/assets/sentry-CPzCHrwe.js +1 -0
  40. package/adminWww/assets/setYear-DDSuW45e.js +1 -0
  41. package/adminWww/index.html +23 -23
  42. package/adminWww/mf-manifest.json +1 -1
  43. package/adminWww/mf-stats.json +1 -1
  44. package/adminWww/remoteEntry-eos-9.0.34.js +12 -0
  45. package/adminWww/remoteEntry.js +1 -1
  46. package/build/lib/eosDeviceEmsPlan.js +285 -9
  47. package/build/lib/eosDeviceEmsPlan.js.map +1 -1
  48. package/build/lib/eosDeviceEmsService.js +29 -2
  49. package/build/lib/eosDeviceEmsService.js.map +1 -1
  50. package/docs/README.md +2 -2
  51. package/docs/reports/unified-9.0.34/PRUEFBERICHT.md +40 -0
  52. package/docs/reports/unified-9.0.34/PRUEFERGEBNISSE.json +112 -0
  53. package/docs/reports/unified-9.0.34/raw/INDEX.json +137 -0
  54. package/docs/reports/unified-9.0.34/raw/backend.log +5 -0
  55. package/docs/reports/unified-9.0.34/raw/dashboard-interval.json +108 -0
  56. package/docs/reports/unified-9.0.34/raw/fixtures-verification.log +44 -0
  57. package/docs/reports/unified-9.0.34/raw/frontend.log +152 -0
  58. package/docs/reports/unified-9.0.34/raw/installer.log +26 -0
  59. package/docs/reports/unified-9.0.34/raw/lint.log +45 -0
  60. package/docs/reports/unified-9.0.34/raw/mira-dashboard-browser.json +1 -0
  61. package/docs/reports/unified-9.0.34/raw/mira-devices-browser.log +9 -0
  62. package/docs/reports/unified-9.0.34/raw/mira-memory-process.json +379 -0
  63. package/docs/reports/unified-9.0.34/raw/modules.log +5 -0
  64. package/docs/reports/unified-9.0.34/raw/node22-mira.log +216 -0
  65. package/docs/reports/unified-9.0.34/raw/node22-protocol-to-ems.log +8 -0
  66. package/docs/reports/unified-9.0.34/raw/node22-tests-final.log +17850 -0
  67. package/docs/reports/unified-9.0.34/raw/node22-version.log +1 -0
  68. package/docs/reports/unified-9.0.34/raw/node24-mira.log +40 -0
  69. package/docs/reports/unified-9.0.34/raw/node24-protocol-to-ems.log +6 -0
  70. package/docs/reports/unified-9.0.34/raw/node24-tests-final.log +2973 -0
  71. package/docs/reports/unified-9.0.34/raw/node24-version.log +1 -0
  72. package/docs/reports/unified-9.0.34/raw/protocol-to-ems.cjs +364 -0
  73. package/docs/reports/unified-9.0.34/raw/release-metadata.log +13 -0
  74. package/docs/reports/unified-9.0.34/raw/sbom.log +8 -0
  75. package/docs/reports/unified-9.0.34/raw/typecheck.log +5 -0
  76. package/docs/reports/unified-9.0.34/raw/ui-runtime.log +8 -0
  77. package/docs/start/START_HIER_9.0.34.md +25 -0
  78. package/io-package.json +8 -8
  79. package/modules/devices/admin/alias-contract-v1.json +22 -0
  80. package/modules/devices/admin/ems-assignment.js +6 -1
  81. package/modules/devices/admin/host-bridge.js +2 -0
  82. package/modules/devices/admin/index.html +16 -0
  83. package/modules/devices/admin/index_m.js +168 -9
  84. package/modules/devices/admin/templates.json +976 -0
  85. package/modules/devices/checks/emsAssignment.check.js +52 -2
  86. package/modules/devices/index.js +5 -1
  87. package/modules/devices/lib/alias-contract-v1.json +22 -0
  88. package/modules/devices/lib/deviceRuntime.js +17 -7
  89. package/modules/devices/lib/drivers/modbus.js +1 -1
  90. package/modules/devices/lib/drivers/modbusRtuBus.js +7 -1
  91. package/modules/devices/lib/drivers/ovumMira.js +148 -0
  92. package/modules/devices/lib/ovumMiraAliases.js +61 -0
  93. package/modules/devices/lib/ovumMiraConnection.js +32 -0
  94. package/modules/devices/lib/templates.json +976 -0
  95. package/modules/devices/test/aliasContractV1.test.js +4 -4
  96. package/modules/devices/test/deviceAliasSemantics.test.js +2 -2
  97. package/modules/devices/test/fixtures/approved-additive-templates.json +3 -1
  98. package/modules/devices/test/ovumMiraPairing.test.js +76 -0
  99. package/modules/devices/test/ovumMiraTemplates.test.js +110 -0
  100. package/modules/devices/test/ovumMiraTransport.test.js +162 -0
  101. package/package.json +6 -4
  102. package/release-manifests/unified/build-environment.cdx.json +6 -6
  103. package/release-manifests/unified/files.json +155 -112
  104. package/release-manifests/unified/frontend.cdx.json +6 -6
  105. package/release-manifests/unified/installer.cdx.json +6 -6
  106. package/release-manifests/unified/obsolete-admin-assets.json +83 -0
  107. package/release-manifests/unified/runtime.cdx.json +27 -27
  108. package/release-manifests/unified/validation.json +15 -15
  109. package/tools/eos-release-manifest.cjs +1 -1
  110. package/ui/ems/consumers/ovum-mira.js +164 -0
  111. package/ui/ems/modules/para14a.js +3 -2
  112. package/ui/ems/modules/stage-a-diagnostics.js +4 -2
  113. package/ui/ems/modules/thermal-control.js +91 -10
  114. package/ui/io-package.json +5 -1
  115. package/ui/lib/installer-lifecycle.js +11 -2
  116. package/ui/main.js +37 -7
  117. package/ui/package.json +1 -1
  118. package/ui/www/app.js +32 -14
  119. package/ui/www/ems-apps.js +28 -9
  120. package/ui/www/licenses/smarthome-markdown-components.json +156 -156
  121. package/ui/www/manifest.webmanifest +2 -2
  122. package/adminWww/assets/AddLink-0L0E-LsA.js +0 -1
  123. package/adminWww/assets/ColorLens-DA51K29x.js +0 -1
  124. package/adminWww/assets/ConfigManager-DbqTWi2N.js +0 -1
  125. package/adminWww/assets/Enums-DjldGElU.js +0 -92
  126. package/adminWww/assets/Fields-0GsPCJeU.js +0 -1
  127. package/adminWww/assets/FileCopy-B16lEuur.js +0 -1
  128. package/adminWww/assets/Files-COnUtEbg.js +0 -1
  129. package/adminWww/assets/Instances-CUX5mxMQ.js +0 -4
  130. package/adminWww/assets/Intro-BhQmHn3A.js +0 -2
  131. package/adminWww/assets/Lens-9lkeoWGk.js +0 -1
  132. package/adminWww/assets/LinearScale-Be5h2beh.js +0 -1
  133. package/adminWww/assets/North-C2whbHM-.js +0 -1
  134. package/adminWww/assets/Overview-CitzUjBF.js +0 -3
  135. package/adminWww/assets/PersonOff-DqBq0Fho.js +0 -1
  136. package/adminWww/assets/PlaylistAdd-O8k92YBd.js +0 -1
  137. package/adminWww/assets/State-D5ljzf-T.js +0 -1
  138. package/adminWww/assets/UsedResources-BY_NF2wB.js +0 -2
  139. package/adminWww/assets/Users-Cu93_-VF.js +0 -1
  140. package/adminWww/assets/date-fns-C1dqkno9.js +0 -1
  141. package/adminWww/assets/icons-material-DjqX0l_7.js +0 -1
  142. package/adminWww/assets/isSameWeek-Crh37s7U.js +0 -1
  143. package/adminWww/assets/isWithinInterval-Bo1WiDfq.js +0 -1
  144. package/adminWww/assets/locale-hLcz_Xh2.js +0 -1
  145. package/adminWww/assets/sentry-DwQQLI7N.js +0 -1
  146. package/adminWww/assets/startOfWeek-DJph8SIW.js +0 -1
  147. package/adminWww/remoteEntry-eos-9.0.33.js +0 -12
@@ -16,7 +16,7 @@
16
16
  * @typedef {import('./eosDeviceEmsPlan').Json} Json
17
17
  * @typedef {{[key: string]: Json}} Dict
18
18
  * @typedef {{id: string, type: string, unit: string, read: boolean, write: boolean, targetId: string, powerCapabilityValidated: boolean}} Alias
19
- * @typedef {{baseId: string, devId: string, name: string, templateId: string, protocol: string, deviceClass: string, enabled: boolean, aliases: Map<string, Alias>, ems: Dict, discoveryCode: string}} Device
19
+ * @typedef {{baseId: string, devId: string, name: string, templateId: string, protocol: string, deviceClass: string, enabled: boolean, aliases: Map<string, Alias>, ems: Dict, discoveryCode: string, miraBus:string, miraFraming:string, miraUnit:number, miraWpmDeviceId?:string}} Device
20
20
  * @typedef {{baseId: string, devId: string, status: string, code: string, target: string, mappedFields: string[], missing: string[], optionalMissing: string[], activationRequestId: string, activationApplied: boolean, corrections:string[]}} Status
21
21
  */
22
22
  const MODES = new Set(['auto', 'monitor', 'manual', 'singleStorage', 'storageFarm', 'gridMeter', 'generationMeter', 'consumptionMeter', 'pvInverter']);
@@ -117,6 +117,10 @@ function device(raw) {
117
117
  if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0 || value > 1000000000)
118
118
  throw fail('EOS_EMS_PLAN_ACTIVATION_INVALID');
119
119
  }
120
+ else if (key === 'miraSources') {
121
+ if (value !== 'confirmed' || row.templateId !== 'heat.ovum.mira.hsm')
122
+ throw fail('EOS_EMS_PLAN_ACTIVATION_INVALID');
123
+ }
120
124
  else if (key === 'coupling' || key === 'chargerType') {
121
125
  if (value !== 'ac' && value !== 'dc')
122
126
  throw fail('EOS_EMS_PLAN_ACTIVATION_INVALID');
@@ -147,7 +151,11 @@ function device(raw) {
147
151
  write: meta.write === true, targetId: target || id, powerCapabilityValidated: meta.powerCapabilityValidated === true });
148
152
  }
149
153
  return { baseId, devId, name: text(row.name).slice(0, 128) || devId, templateId: text(row.templateId), protocol: text(row.protocol), deviceClass: text(row.deviceClass),
150
- enabled: row.enabled !== false, aliases, ems, discoveryCode: text(row.discoveryCode) };
154
+ enabled: row.enabled !== false, aliases, ems, discoveryCode: text(row.discoveryCode),
155
+ miraBus: /^[a-f0-9]{64}$/.test(text(row.miraBus)) ? text(row.miraBus) : '',
156
+ miraFraming: /^[a-f0-9]{64}$/.test(text(row.miraFraming)) ? text(row.miraFraming) : '',
157
+ miraUnit: Number.isInteger(row.miraUnit) ? Number(row.miraUnit) : 0,
158
+ ...(Object.prototype.hasOwnProperty.call(row, 'miraWpmDeviceId') ? { miraWpmDeviceId: text(row.miraWpmDeviceId) } : {}) };
151
159
  }
152
160
  /** @param {Device} dev @param {string[]} keys @param {boolean} [write] @param {string[]} [types] @param {string[]} [units] @returns {string} */
153
161
  function alias(dev, keys, write = false, types = ['number'], units = []) {
@@ -213,7 +221,7 @@ function getDeviceEmsReferences(value) {
213
221
  const config = copyConfig(value);
214
222
  const read = new Set();
215
223
  const write = new Set();
216
- const writeKey = /(?:write|^set|^target|^output(?:Object)?Id$|^(?:pv)?feedInLimit|^pvLimit|^runObjectId$|^maxChargeObjectId$|^maxDischargeObjectId$|^phaseSwitchId$|^chargeEnableObjectId$|^dischargeEnableObjectId$|^feneconGridSetpoint|^e3dcSetPower|^enableId$)/i;
224
+ const writeKey = /(?:^mira(?:PvStatus|PowerTarget)Id$|write|^set|^target|^output(?:Object)?Id$|^(?:pv)?feedInLimit|^pvLimit|^runObjectId$|^maxChargeObjectId$|^maxDischargeObjectId$|^phaseSwitchId$|^chargeEnableObjectId$|^dischargeEnableObjectId$|^feneconGridSetpoint|^e3dcSetPower|^enableId$)/i;
217
225
  /** @param {unknown} item @param {number} depth */
218
226
  const walk = (item, depth) => {
219
227
  if (!item || typeof item !== 'object' || depth > 12)
@@ -229,7 +237,7 @@ function getDeviceEmsReferences(value) {
229
237
  }
230
238
  };
231
239
  for (const item of [record(config.settingsConfig).evcsList, config.storage, config.storageFarm,
232
- config.gridConstraints, config.thermalControl, config.thermal, config.vis, config.heatingRod, config.threshold,
240
+ config.gridConstraints, config.thermalControl, config.thermal, config.vis, config.flowSlots, config.heatingRod, config.threshold,
233
241
  config.generator, config.bhkw, config.dynamicGridConnection])
234
242
  walk(item, 0);
235
243
  for (const [key, id] of Object.entries(record(config.datapoints))) {
@@ -385,7 +393,7 @@ function planDeviceEms(input) {
385
393
  fill(next, 'energyTotalInputIsWh', meta?.unit === 'Wh', result);
386
394
  }
387
395
  if (conflict(dev, next, [list.filter(item => item !== row), config.storage, config.storageFarm, config.gridConstraints,
388
- config.thermalControl, config.thermal, config.vis, config.heatingRod, config.threshold, config.generator, config.bhkw])) {
396
+ config.thermalControl, config.thermal, config.vis, config.flowSlots, config.heatingRod, config.threshold, config.generator, config.bhkw])) {
389
397
  result.status = 'conflict';
390
398
  result.code = 'CONTROL_TARGET_ALREADY_ASSIGNED';
391
399
  result.mappedFields = [];
@@ -667,8 +675,8 @@ function planDeviceEms(input) {
667
675
  result.status = 'mapped';
668
676
  result.code = result.missing.length ? 'MAPPING_INCOMPLETE' : row.enabled === false ? 'COMMISSIONING_REQUIRED' : 'MAPPED';
669
677
  };
670
- /** @param {Device} dev @param {Status} result @param {string} mode */
671
- const measurement = (dev, result, mode) => {
678
+ /** @param {Device} dev @param {Status} result @param {string} mode @param {number} [suggestedSlot] */
679
+ const measurement = (dev, result, mode, suggestedSlot) => {
672
680
  const power = alias(dev, mode === 'pvInverter' ? ['r.pvPower', 'r.power'] : ['r.power'], false, ['number'], ['W']);
673
681
  if (!power) {
674
682
  result.code = 'ALIASES_PENDING';
@@ -726,7 +734,7 @@ function planDeviceEms(input) {
726
734
  return;
727
735
  }
728
736
  let key = '';
729
- let slot = dev.ems.flowSlot;
737
+ let slot = suggestedSlot ?? dev.ems.flowSlot;
730
738
  let kind = '';
731
739
  if (mode === 'gridMeter') {
732
740
  if (dev.ems.scope !== 'M0') {
@@ -800,6 +808,114 @@ function planDeviceEms(input) {
800
808
  result.status = 'mapped';
801
809
  result.code = 'MEASUREMENT_MAPPED';
802
810
  };
811
+ const isWpm = (/** @type {Device} */ dev) => dev.templateId === 'heat.ovum.mira.wpm';
812
+ const isHsm = (/** @type {Device} */ dev) => dev.templateId === 'heat.ovum.mira.hsm';
813
+ const miraWpms = devices.filter(isWpm);
814
+ const miraHsms = devices.filter(isHsm);
815
+ const thermalRows = () => Array.isArray(record(config.thermal).devices) ? /** @type {Dict[]} */ (record(config.thermal).devices) : [];
816
+ const flowRows = () => {
817
+ const consumers = record(record(config.vis).flowSlots).consumers;
818
+ return Array.isArray(consumers) ? consumers.map(record) : [];
819
+ };
820
+ const usableWpm = (/** @type {Device} */ dev) => dev.enabled && ['auto', 'monitor'].includes(text(dev.ems.mode) || 'auto')
821
+ && !!dev.miraBus && dev.miraUnit >= 111 && dev.miraUnit <= 118;
822
+ /** Explicit pairing allows a dedicated RTU line. A cascade has no proven aggregate electrical meter. */
823
+ function meterFor(/** @type {Device} */ hsm) {
824
+ if (!hsm.miraBus || hsm.miraUnit !== 110 || miraHsms.filter(other => other.miraBus === hsm.miraBus).length !== 1)
825
+ return undefined;
826
+ const onBus = miraWpms.filter(wpm => wpm.miraBus === hsm.miraBus);
827
+ if (onBus.length > 1)
828
+ return undefined;
829
+ const wpm = hsm.miraWpmDeviceId === undefined ? onBus[0] : miraWpms.find(item => item.devId === hsm.miraWpmDeviceId);
830
+ if (!wpm || !usableWpm(wpm) || onBus.length && onBus[0] !== wpm)
831
+ return undefined;
832
+ if (wpm.miraBus === hsm.miraBus && wpm.miraFraming !== hsm.miraFraming)
833
+ return undefined;
834
+ if (wpm.miraBus !== hsm.miraBus && !(wpm.protocol === 'modbusRtu' && hsm.protocol === 'modbusRtu' && hsm.miraWpmDeviceId))
835
+ return undefined;
836
+ if (miraWpms.some(other => other !== wpm && other.miraBus === wpm.miraBus))
837
+ return undefined;
838
+ if (miraHsms.some(other => other !== hsm && (other.miraWpmDeviceId === wpm.devId ||
839
+ other.miraBus === wpm.miraBus && other.miraWpmDeviceId === undefined)))
840
+ return undefined;
841
+ return wpm;
842
+ }
843
+ const wiring = (/** @type {Device} */ hsm, /** @type {Device} */ wpm) => createHash('sha256').update(JSON.stringify([hsm.baseId, hsm.miraBus, hsm.miraFraming, hsm.miraUnit, wpm.baseId, wpm.miraBus, wpm.miraFraming, wpm.miraUnit])).digest('hex');
844
+ /** Read-only fields also used by older slot exports. */
845
+ const slotPowerIds = (/** @type {Dict} */ slot) => ['objectId', 'powerReadId', 'powerObjectId', 'powerId', 'powerWId', 'powerDpId', 'powerDp', 'datapointId', 'dataPointId', 'stateId', 'dpId', 'dp']
846
+ .map(key => text(slot[key])).filter(Boolean);
847
+ /** App-Center persists untouched rows for every slot. An installer-modified row remains reserved. */
848
+ function blankThermal(/** @type {Dict} */ row, /** @type {number} */ slot) {
849
+ /** @type {Dict} */
850
+ const defaults = { slot, enabled: false, mode: 'pvAuto', name: '', type: 'power', profile: 'heating', priority: 100 + slot,
851
+ maxPowerW: 2500, estimatedPowerW: 1500, startSurplusW: 800, stopSurplusW: 300, minOnSec: 300, minOffSec: 300,
852
+ autoOnSetpoint: 55, autoOffSetpoint: 45, boostSetpoint: 60, boostEnabled: true, boostDurationMin: 30, boostPowerW: 2500, maxSgStage: 4 };
853
+ return Object.entries(row).every(([key, value]) => Object.prototype.hasOwnProperty.call(defaults, key) && defaults[key] === value);
854
+ }
855
+ function miraMeter(/** @type {Device} */ dev, /** @type {Status} */ result) {
856
+ if (!usableWpm(dev) || miraWpms.some(other => other !== dev && other.miraBus === dev.miraBus && other.miraUnit === dev.miraUnit)) {
857
+ result.status = 'conflict';
858
+ result.code = 'MIRA_METER_ADDRESS';
859
+ return;
860
+ }
861
+ const power = alias(dev, ['r.power'], false, ['number'], ['W']);
862
+ if (!power) {
863
+ result.missing.push('r.power');
864
+ return;
865
+ }
866
+ const dp = record(config.datapoints);
867
+ const slots = flowRows();
868
+ const legacySlots = record(config.flowSlots).consumers;
869
+ const managed = slots.findIndex(slot => record(slot._eosDevice).baseId === dev.baseId);
870
+ const old = /^consumer([1-9]|10)Power$/.exec(text(binding(dev).target));
871
+ if (old && (managed !== Number(old[1]) - 1 || dp[old[0]] !== power && !(empty(dp[old[0]]) && binding(dev).miraDetached === true))) {
872
+ result.status = 'manual';
873
+ result.code = 'MIRA_MAPPING_REMOVED';
874
+ return;
875
+ }
876
+ // Limit selection to the ten consumers supported throughout the dashboard/API.
877
+ const keys = Array.from({ length: 10 }, (_, i) => `consumer${i + 1}Power`);
878
+ const explicitName = (/** @type {Dict} */ slot, /** @type {number} */ i) => {
879
+ const name = text(slot.name);
880
+ return !!name && name !== `Verbraucher ${i + 1}` && !(i === 0 && name === 'Heizung/Wärmepumpe');
881
+ };
882
+ const ownsSlot = (/** @type {Dict} */ slot, /** @type {number} */ i) => !!slot._eosDevice || explicitName(slot, i) || slotPowerIds(slot).length > 0 || mappedIds(slot.ctrl).length > 0
883
+ || record(slot.ctrl).enabled === true || !!text(slot.icon) || !['', 'generic', 'auto'].includes(text(slot.consumerType));
884
+ const slotIndex = managed >= 0 ? managed : keys.findIndex((key, i) => empty(dp[key]) && !ownsSlot(slots[i] || {}, i) && !(Array.isArray(legacySlots) && ownsSlot(record(legacySlots[i]), i))
885
+ && !thermalRows().some(row => Number(row.slot ?? row.consumerSlot) === i + 1 && !blankThermal(row, i + 1)));
886
+ if (slotIndex < 0 || slotIndex >= 10) {
887
+ result.status = 'conflict';
888
+ result.code = 'MIRA_FLOW_FULL';
889
+ return;
890
+ }
891
+ if (slots.some((row, i) => i !== slotIndex && slotPowerIds(row).some(id => readTargetOf(id) === readTargetOf(power)))
892
+ || Array.isArray(legacySlots) && legacySlots.some(row => slotPowerIds(record(row)).some(id => readTargetOf(id) === readTargetOf(power)))) {
893
+ result.status = 'conflict';
894
+ result.code = 'MEASUREMENT_ALREADY_ASSIGNED';
895
+ return;
896
+ }
897
+ measurement(dev, result, 'consumptionMeter', slotIndex + 1);
898
+ if (result.status === 'mapped') {
899
+ const slot = flowRows()[slotIndex];
900
+ if (managed < 0 || empty(slot.consumerType))
901
+ slot.consumerType = 'heatPump';
902
+ binding(dev).miraWpm = true;
903
+ delete binding(dev).miraDetached;
904
+ }
905
+ }
906
+ // Hold a managed writer inactive when its former physical pairing no longer exists.
907
+ // A normal restart with unchanged topology and an inventory still loading preserves its commissioning.
908
+ for (const row of thermalRows()) {
909
+ const owner = record(row._eosDevice);
910
+ if (owner.mode !== 'mira' || owner.v !== 1)
911
+ continue;
912
+ const hsm = miraHsms.find(dev => dev.baseId === owner.baseId);
913
+ const wpm = hsm && meterFor(hsm);
914
+ if (!hsm || !wpm || !hsm.enabled || (hsm.ems.mode || 'auto') !== 'auto' || wiring(hsm, wpm) !== row.miraTopologyId) {
915
+ row.enabled = false;
916
+ row.miraSourcesConfirmed = false;
917
+ }
918
+ }
803
919
  // Existing auto-created control rows survive missing/deactivated devices, but
804
920
  // are held inactive. Re-adding a device never grants activation by itself.
805
921
  const activeBases = new Set(devices.filter(dev => dev.enabled && dev.ems.mode !== 'monitor').map(dev => dev.baseId));
@@ -861,7 +977,7 @@ function planDeviceEms(input) {
861
977
  result.code = 'DEVICE_DISABLED';
862
978
  continue;
863
979
  }
864
- if (mode === 'manual' || mode === 'monitor') {
980
+ if (mode === 'manual' || mode === 'monitor' && !isWpm(dev)) {
865
981
  result.status = 'manual';
866
982
  result.code = mode === 'manual' ? 'MANUAL_MAPPING' : 'MONITOR_ONLY';
867
983
  continue;
@@ -878,6 +994,14 @@ function planDeviceEms(input) {
878
994
  }
879
995
  const checkpoint = copyConfig(config);
880
996
  try {
997
+ if (dev.deviceClass === 'heat' && isWpm(dev) && (mode === 'auto' || mode === 'monitor')) {
998
+ miraMeter(dev, result);
999
+ continue;
1000
+ }
1001
+ if (dev.deviceClass === 'heat' && isHsm(dev) && mode === 'auto') {
1002
+ result.code = 'MIRA_METER_PENDING';
1003
+ continue;
1004
+ }
881
1005
  if (dev.deviceClass === 'evCharger' && mode === 'auto') {
882
1006
  ev(dev, result);
883
1007
  continue;
@@ -1172,6 +1296,158 @@ function planDeviceEms(input) {
1172
1296
  result.missing.push('otherUncommissionedController');
1173
1297
  }
1174
1298
  }
1299
+ // Remove only our exact electrical meter when that module is deliberately removed or disabled.
1300
+ for (const [base, saved] of Object.entries(record(record(config.eosDeviceEms).bindings))) {
1301
+ const entry = record(saved);
1302
+ if (entry.miraWpm !== true || miraWpms.some(wpm => wpm.baseId === base && wpm.enabled && wpm.ems.mode !== 'manual'))
1303
+ continue;
1304
+ const slot = flowRows().findIndex(row => record(row._eosDevice).baseId === base) + 1;
1305
+ const key = `consumer${slot}Power`;
1306
+ const dp = record(config.datapoints);
1307
+ if (slot && entry.target === key && dp[key] === `${base}.aliases.v1.r.power`) {
1308
+ dp[key] = '';
1309
+ entry.miraDetached = true;
1310
+ }
1311
+ }
1312
+ // Each hydraulic manager owns at most one PV-control row. It never contributes another flow meter.
1313
+ for (const dev of miraHsms) {
1314
+ const result = statuses[devices.indexOf(dev)];
1315
+ if (!dev.enabled || (dev.ems.mode || 'auto') !== 'auto' || dev.discoveryCode || dev.deviceClass !== 'heat')
1316
+ continue;
1317
+ const oldBinding = binding(dev);
1318
+ const activation = record(dev.ems.activation);
1319
+ const requestId = text(activation.requestId);
1320
+ const previous = thermalRows().find(row => record(row._eosDevice).mode === 'mira' && record(row._eosDevice).baseId === dev.baseId);
1321
+ const hold = (/** @type {string} */ code) => {
1322
+ if (previous) {
1323
+ previous.enabled = false;
1324
+ previous.miraSourcesConfirmed = false;
1325
+ }
1326
+ result.code = code;
1327
+ };
1328
+ const wpm = meterFor(dev);
1329
+ if (!wpm) {
1330
+ hold('MIRA_METER_PENDING');
1331
+ continue;
1332
+ }
1333
+ const meterStatus = statuses[devices.indexOf(wpm)];
1334
+ if (wpm.discoveryCode || dev.discoveryCode)
1335
+ continue; // transient discovery is not new commissioning
1336
+ if (meterStatus.status !== 'mapped') {
1337
+ hold('MIRA_METER_PENDING');
1338
+ continue;
1339
+ }
1340
+ const slot = flowRows().findIndex(row => record(row._eosDevice).baseId === wpm.baseId) + 1;
1341
+ if (!slot || slot > 10) {
1342
+ hold('MIRA_METER_PENDING');
1343
+ continue;
1344
+ }
1345
+ const slotCfg = flowRows()[slot - 1];
1346
+ if (mappedIds(slotCfg.ctrl).length || record(slotCfg.ctrl).enabled === true ||
1347
+ text(slotCfg.consumerType) !== 'heatPump') {
1348
+ hold('MANUAL_MAPPING_PRESERVED');
1349
+ continue;
1350
+ }
1351
+ const slotRows = thermalRows().filter(row => Number(row.slot ?? row.consumerSlot) === slot);
1352
+ const occupant = slotRows[0];
1353
+ if (slotRows.length > 1 || occupant && occupant !== previous && !blankThermal(occupant, slot) || previous && previous !== occupant) {
1354
+ hold('MANUAL_MAPPING_PRESERVED');
1355
+ continue;
1356
+ }
1357
+ const isNew = !!requestId && requestId !== oldBinding.activationRequestId;
1358
+ const signature = wiring(dev, wpm);
1359
+ if (!previous && oldBinding.target === 'thermal' && !isNew) {
1360
+ result.status = 'manual';
1361
+ result.code = 'MIRA_MAPPING_REMOVED';
1362
+ continue;
1363
+ }
1364
+ if (previous && signature !== previous.miraTopologyId && !isNew) {
1365
+ hold('ACTIVATION_PROFILE_CHANGED');
1366
+ continue;
1367
+ }
1368
+ const fields = {
1369
+ miraPvStatusId: alias(dev, ['ctrl.pvStatus'], true),
1370
+ miraPvStatusReadId: alias(dev, ['r.pvStatus']),
1371
+ miraPowerTargetId: alias(dev, ['ctrl.pvPowerTargetW'], true, ['number'], ['W']),
1372
+ miraPowerTargetReadId: alias(dev, ['r.pvPowerTargetW'], false, ['number'], ['W']),
1373
+ };
1374
+ if (Object.values(fields).some(id => !id)) {
1375
+ hold('MISSING_ALIASES');
1376
+ continue;
1377
+ }
1378
+ if (previous && Object.entries(fields).some(([key, id]) => previous[key] !== id)) {
1379
+ hold('MANUAL_MAPPING_PRESERVED');
1380
+ continue;
1381
+ }
1382
+ if (conflict(dev, fields, [thermalRows().filter(row => row !== previous), config.thermalControl, config.vis,
1383
+ config.heatingRod, config.threshold, config.bhkw, config.generator, config.storage, config.storageFarm, config.settingsConfig, config.gridConstraints])) {
1384
+ hold('CONTROL_TARGET_ALREADY_ASSIGNED');
1385
+ continue;
1386
+ }
1387
+ const row = previous || { ...(occupant || {}), slot, name: dev.name, profile: 'heating', type: 'power', mode: 'pvAuto',
1388
+ ovumMira: true, enabled: false, miraSourcesConfirmed: false, maxPowerW: 0, ...fields };
1389
+ row.miraTopologyId = signature;
1390
+ if (!previous) {
1391
+ const list = rows(section(config, 'thermal'), 'devices');
1392
+ if (occupant)
1393
+ list[list.indexOf(occupant)] = row;
1394
+ else
1395
+ list.push(row);
1396
+ result.mappedFields.push(...Object.keys(fields));
1397
+ }
1398
+ remember(row, dev, 'mira', 'thermal');
1399
+ result.target = 'thermal.devices';
1400
+ result.status = 'mapped';
1401
+ result.code = row.enabled === true ? 'MAPPED' : 'COMMISSIONING_REQUIRED';
1402
+ if (!requestId)
1403
+ continue;
1404
+ if (!isNew) {
1405
+ if (oldBinding.activationFingerprint !== requestFingerprint(dev)) {
1406
+ result.status = 'conflict';
1407
+ hold('ACTIVATION_REQUEST_CHANGED');
1408
+ continue;
1409
+ }
1410
+ result.activationApplied = true;
1411
+ const app = record(record(record(config.emsApps).apps).thermal);
1412
+ result.code = activation.requested !== true ? 'ACTIVATION_DISABLED' :
1413
+ row.enabled === true && app.enabled === true && app.installed === true ? 'ACTIVATION_APPLIED' : 'APP_DISABLED';
1414
+ continue;
1415
+ }
1416
+ const limits = record(activation.limits);
1417
+ if (activation.requested === true) {
1418
+ if (!grantedApps.has('thermal'))
1419
+ result.missing.push('license:thermal');
1420
+ if (limits.miraSources !== 'confirmed')
1421
+ result.missing.push('miraSources');
1422
+ if (typeof limits.maxPowerW !== 'number' || !Number.isSafeInteger(limits.maxPowerW) || limits.maxPowerW <= 0 || limits.maxPowerW > 10000000)
1423
+ result.missing.push('limit:maxPowerW');
1424
+ const grid = record(config.datapoints).gridPointPower;
1425
+ const gridUnit = typeof grid === 'string' ? references.get(grid)?.unit : '';
1426
+ if (!validReference(grid, false, 'number', ['W', 'kW']) || (gridUnit === 'kW') !== (record(record(config.settings).flowPowerDpIsW).gridPointPower === false))
1427
+ result.missing.push('gridPointPower');
1428
+ const oldApp = record(record(record(config.emsApps).apps).thermal);
1429
+ const active = Object.keys(oldApp).length ? oldApp.installed === true && oldApp.enabled === true : config.enableThermalControl === true;
1430
+ if (!active && thermalRows().some(other => other !== row && other.enabled === true))
1431
+ result.missing.push('otherUncommissionedController');
1432
+ if (result.missing.length) {
1433
+ result.status = 'pending';
1434
+ result.code = 'ACTIVATION_PENDING';
1435
+ continue;
1436
+ }
1437
+ row.maxPowerW = limits.maxPowerW;
1438
+ const registry = section(config, 'emsApps');
1439
+ fill(registry, 'schemaVersion', 1, result);
1440
+ const app = section(section(registry, 'apps'), 'thermal');
1441
+ app.installed = true;
1442
+ app.enabled = true;
1443
+ }
1444
+ row.enabled = activation.requested === true;
1445
+ row.miraSourcesConfirmed = activation.requested === true;
1446
+ Object.assign(binding(dev), { activationRequestId: requestId, activationFingerprint: requestFingerprint(dev),
1447
+ activationRequested: row.enabled, miraCommissionedMaxW: row.enabled ? row.maxPowerW : 0, deviceTemplateId: dev.templateId, deviceProtocol: dev.protocol, deviceClass: dev.deviceClass });
1448
+ result.activationApplied = true;
1449
+ result.code = row.enabled ? 'ACTIVATION_APPLIED' : 'ACTIVATION_DISABLED';
1450
+ }
1175
1451
  /** @type {Dict} */
1176
1452
  const patch = {};
1177
1453
  for (const [key, value] of Object.entries(config))