iobroker.eos-admin 9.0.33 → 9.0.35
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.
- package/NEXOWATT_EOS_BUILD_INFO.json +13 -11
- package/README.md +12 -8
- package/adminWww/.vite/manifest.json +233 -224
- package/adminWww/NEXOWATT_EOS_FRONTEND_MANIFEST.json +13897 -13887
- package/adminWww/assets/AccessTime-CuR73YC3.js +1 -0
- package/adminWww/assets/{AdapterUpdateDialog-DBUqmmyD.js → AdapterUpdateDialog-DH6S-kWX.js} +5 -5
- package/adminWww/assets/{Adapters-dDEp7o5h.js → Adapters-CIlqSF5B.js} +5 -5
- package/adminWww/assets/ConfigManager-BhVBfM-q.js +1 -0
- package/adminWww/assets/Enums-3H97czGs.js +92 -0
- package/adminWww/assets/Fields-vWLKiuvO.js +1 -0
- package/adminWww/assets/Files-wmjjMXYM.js +1 -0
- package/adminWww/assets/{Hosts-CwU1LujG.js → Hosts-Bk-xmI98.js} +6 -6
- package/adminWww/assets/Instances-Db6Vgh62.js +4 -0
- package/adminWww/assets/Intro-Dc3wAG9V.js +2 -0
- package/adminWww/assets/KeyboardArrowRight-ifvmV1ZL.js +1 -0
- package/adminWww/assets/{Logs-B5SpNqHq.js → Logs-CPbEGWNq.js} +2 -2
- package/adminWww/assets/MoreHoriz-CS7nODK8.js +1 -0
- package/adminWww/assets/{Objects-COg_cFkz.js → Objects-DJB-2468.js} +4 -4
- package/adminWww/assets/Overview-DdvghCLQ.js +3 -0
- package/adminWww/assets/Pageview-wzrLQZ-j.js +1 -0
- package/adminWww/assets/PersonOff-YtHcY0sV.js +1 -0
- package/adminWww/assets/Star-D8VNXawT.js +1 -0
- package/adminWww/assets/State-0UzpgKYj.js +1 -0
- package/adminWww/assets/UsedResources-Bcmo58YD.js +2 -0
- package/adminWww/assets/Users-BGHf3Rox.js +1 -0
- package/adminWww/assets/ViewCompact-D7bHgn99.js +1 -0
- package/adminWww/assets/ViewSidebar-CjClbCI5.js +1 -0
- package/adminWww/assets/WifiTethering-DJ9VO12W.js +1 -0
- package/adminWww/assets/{bootstrap-Dwfxhm2V.js → bootstrap-qkrk_CAn.js} +25 -25
- package/adminWww/assets/date-fns-BtR4dG_j.js +1 -0
- package/adminWww/assets/en-US-BjjaEI6N.js +1 -0
- package/adminWww/assets/{hostInit-3BbTwhaZ.js → hostInit-DlGqatlv.js} +1 -1
- package/adminWww/assets/icons-material-CUNq6tdT.js +1 -0
- package/adminWww/assets/{index-nddph2Sl.js → index-BrtKq3UN.js} +2 -2
- package/adminWww/assets/{installSVGRenderer-CPDIwFAL.js → installSVGRenderer-DujLjpXt.js} +1 -1
- package/adminWww/assets/isSameWeek-WMSJR5Qs.js +1 -0
- package/adminWww/assets/locale-DN6Bdkdt.js +1 -0
- package/adminWww/assets/{mf-entry-bootstrap-0-d1f0f40f.js → mf-entry-bootstrap-0-3e1cd85c.js} +2 -2
- package/adminWww/assets/sentry-CPzCHrwe.js +1 -0
- package/adminWww/assets/setYear-DDSuW45e.js +1 -0
- package/adminWww/index.html +23 -23
- package/adminWww/mf-manifest.json +1 -1
- package/adminWww/mf-stats.json +1 -1
- package/adminWww/{remoteEntry-eos-9.0.33.js → remoteEntry-eos-9.0.35.js} +1 -1
- package/adminWww/remoteEntry.js +1 -1
- package/build/lib/eosDashboardProcessStatus.js +191 -0
- package/build/lib/eosDashboardProcessStatus.js.map +1 -0
- package/build/lib/eosDeviceEmsPlan.js +285 -9
- package/build/lib/eosDeviceEmsPlan.js.map +1 -1
- package/build/lib/eosDeviceEmsService.js +29 -2
- package/build/lib/eosDeviceEmsService.js.map +1 -1
- package/build/lib/eosKiosk.js +1 -0
- package/build/lib/eosKiosk.js.map +1 -1
- package/build/lib/eosModuleHost.js +17 -6
- package/build/lib/eosModuleHost.js.map +1 -1
- package/build/lib/eosModuleHttp.js +18 -3
- package/build/lib/eosModuleHttp.js.map +1 -1
- package/build/lib/eosModuleProcess.js +17 -0
- package/build/lib/eosModuleProcess.js.map +1 -1
- package/build/lib/eosModuleProcessWorker.js +22 -1
- package/build/lib/eosModuleProcessWorker.js.map +1 -1
- package/build/lib/eosRuntimeControl.js +6 -0
- package/build/lib/eosRuntimeControl.js.map +1 -1
- package/build/lib/eosRuntimeHealth.js +50 -1
- package/build/lib/eosRuntimeHealth.js.map +1 -1
- package/build/lib/eosSupervisorNotifications.js +169 -0
- package/build/lib/eosSupervisorNotifications.js.map +1 -0
- package/build/lib/eosUiProcess.js +1 -0
- package/build/lib/eosUiProcess.js.map +1 -1
- package/build/lib/web.js +5 -0
- package/build/lib/web.js.map +1 -1
- package/docs/README.md +3 -2
- package/docs/reports/unified-9.0.34/PRUEFBERICHT.md +40 -0
- package/docs/reports/unified-9.0.34/PRUEFERGEBNISSE.json +112 -0
- package/docs/reports/unified-9.0.34/raw/INDEX.json +137 -0
- package/docs/reports/unified-9.0.34/raw/backend.log +5 -0
- package/docs/reports/unified-9.0.34/raw/dashboard-interval.json +108 -0
- package/docs/reports/unified-9.0.34/raw/fixtures-verification.log +44 -0
- package/docs/reports/unified-9.0.34/raw/frontend.log +152 -0
- package/docs/reports/unified-9.0.34/raw/installer.log +26 -0
- package/docs/reports/unified-9.0.34/raw/lint.log +45 -0
- package/docs/reports/unified-9.0.34/raw/mira-dashboard-browser.json +1 -0
- package/docs/reports/unified-9.0.34/raw/mira-devices-browser.log +9 -0
- package/docs/reports/unified-9.0.34/raw/mira-memory-process.json +379 -0
- package/docs/reports/unified-9.0.34/raw/modules.log +5 -0
- package/docs/reports/unified-9.0.34/raw/node22-mira.log +216 -0
- package/docs/reports/unified-9.0.34/raw/node22-protocol-to-ems.log +8 -0
- package/docs/reports/unified-9.0.34/raw/node22-tests-final.log +17850 -0
- package/docs/reports/unified-9.0.34/raw/node22-version.log +1 -0
- package/docs/reports/unified-9.0.34/raw/node24-mira.log +40 -0
- package/docs/reports/unified-9.0.34/raw/node24-protocol-to-ems.log +6 -0
- package/docs/reports/unified-9.0.34/raw/node24-tests-final.log +2973 -0
- package/docs/reports/unified-9.0.34/raw/node24-version.log +1 -0
- package/docs/reports/unified-9.0.34/raw/protocol-to-ems.cjs +364 -0
- package/docs/reports/unified-9.0.34/raw/release-metadata.log +13 -0
- package/docs/reports/unified-9.0.34/raw/sbom.log +8 -0
- package/docs/reports/unified-9.0.34/raw/typecheck.log +5 -0
- package/docs/reports/unified-9.0.34/raw/ui-runtime.log +8 -0
- package/docs/reports/unified-9.0.35/PRUEFBERICHT.md +51 -0
- package/docs/reports/unified-9.0.35/PRUEFERGEBNISSE.json +112 -0
- package/docs/reports/unified-9.0.35/raw/INDEX.json +282 -0
- package/docs/reports/unified-9.0.35/raw/backend.log +5 -0
- package/docs/reports/unified-9.0.35/raw/browser-lp-detail.log +1 -0
- package/docs/reports/unified-9.0.35/raw/browser-lp-feedback.log +1 -0
- package/docs/reports/unified-9.0.35/raw/cold-ocpp-22.log +108 -0
- package/docs/reports/unified-9.0.35/raw/cold-ocpp-24.log +24 -0
- package/docs/reports/unified-9.0.35/raw/core-final-node22.log +1439 -0
- package/docs/reports/unified-9.0.35/raw/core-final-node24.log +1381 -0
- package/docs/reports/unified-9.0.35/raw/dashboard-de-en-nl.json +716 -0
- package/docs/reports/unified-9.0.35/raw/device-chain-closed-fixed.json +98 -0
- package/docs/reports/unified-9.0.35/raw/device-chain-rst-fixed.json +98 -0
- package/docs/reports/unified-9.0.35/raw/device-chain.json +93 -0
- package/docs/reports/unified-9.0.35/raw/ee-fusion-final.log +12 -0
- package/docs/reports/unified-9.0.35/raw/eebus-monitor-browser.json +1 -0
- package/docs/reports/unified-9.0.35/raw/eebus-monitor-node22.log +206 -0
- package/docs/reports/unified-9.0.35/raw/eebus-monitor-node24.log +39 -0
- package/docs/reports/unified-9.0.35/raw/fixtures-verification.log +44 -0
- package/docs/reports/unified-9.0.35/raw/frontend.log +152 -0
- package/docs/reports/unified-9.0.35/raw/installer.log +26 -0
- package/docs/reports/unified-9.0.35/raw/legacy-mail-setup-browser.log +1 -0
- package/docs/reports/unified-9.0.35/raw/lint.log +45 -0
- package/docs/reports/unified-9.0.35/raw/live-ems-loss.log +10 -0
- package/docs/reports/unified-9.0.35/raw/modules.log +5 -0
- package/docs/reports/unified-9.0.35/raw/node22-mira-reconnect-integrity.log +452 -0
- package/docs/reports/unified-9.0.35/raw/node22-mira.log +222 -0
- package/docs/reports/unified-9.0.35/raw/node22-system-status.log +213 -0
- package/docs/reports/unified-9.0.35/raw/node22-tests-final.log +18137 -0
- package/docs/reports/unified-9.0.35/raw/node22-version.log +1 -0
- package/docs/reports/unified-9.0.35/raw/node24-mira-reconnect-integrity.log +79 -0
- package/docs/reports/unified-9.0.35/raw/node24-mira.log +41 -0
- package/docs/reports/unified-9.0.35/raw/node24-system-status.log +40 -0
- package/docs/reports/unified-9.0.35/raw/node24-tests-final.log +3019 -0
- package/docs/reports/unified-9.0.35/raw/node24-version.log +1 -0
- package/docs/reports/unified-9.0.35/raw/notifications-legacy-node22.log +1 -0
- package/docs/reports/unified-9.0.35/raw/notifications-legacy-node24.log +1 -0
- package/docs/reports/unified-9.0.35/raw/notifications-node22.log +67 -0
- package/docs/reports/unified-9.0.35/raw/notifications-node24.log +17 -0
- package/docs/reports/unified-9.0.35/raw/npm-runtime-audit.json +77 -0
- package/docs/reports/unified-9.0.35/raw/ocpp-dashboard-stations-node22.log +110 -0
- package/docs/reports/unified-9.0.35/raw/ocpp-dashboard-stations-node24.log +106 -0
- package/docs/reports/unified-9.0.35/raw/ocpp-history-node22.log +561 -0
- package/docs/reports/unified-9.0.35/raw/ocpp-history-node24.log +98 -0
- package/docs/reports/unified-9.0.35/raw/poll-life-node22.log +38 -0
- package/docs/reports/unified-9.0.35/raw/poll-life-node24.log +12 -0
- package/docs/reports/unified-9.0.35/raw/qa-source-check.log +2 -0
- package/docs/reports/unified-9.0.35/raw/release-metadata.log +13 -0
- package/docs/reports/unified-9.0.35/raw/sbom.log +8 -0
- package/docs/reports/unified-9.0.35/raw/typecheck.log +5 -0
- package/docs/reports/unified-9.0.35/raw/ui-runtime.log +8 -0
- package/docs/reports/unified-9.0.35/raw/vergleich-9.0.33.json +29 -0
- package/docs/reports/unified-9.0.35/raw/vergleich-9.0.34.json +249 -0
- package/docs/reports/unified-9.0.35/raw/vorher-9.0.33-chromium.json +286 -0
- package/docs/reports/unified-9.0.35/raw/vorher-9.0.34-chromium.json +291 -0
- package/docs/start/START_HIER_9.0.34.md +25 -0
- package/docs/start/START_HIER_9.0.35.md +27 -0
- package/io-package.json +12 -12
- package/modules/devices/admin/alias-contract-v1.json +22 -0
- package/modules/devices/admin/ems-assignment.js +6 -1
- package/modules/devices/admin/host-bridge.js +2 -0
- package/modules/devices/admin/index.html +16 -0
- package/modules/devices/admin/index_m.js +168 -9
- package/modules/devices/admin/templates.json +976 -0
- package/modules/devices/checks/emsAssignment.check.js +52 -2
- package/modules/devices/contracts.d.ts +1 -0
- package/modules/devices/index.js +25 -2
- package/modules/devices/lib/alias-contract-v1.json +22 -0
- package/modules/devices/lib/deviceRuntime.js +36 -7
- package/modules/devices/lib/drivers/modbus.js +12 -7
- package/modules/devices/lib/drivers/modbusRtuBus.js +7 -1
- package/modules/devices/lib/drivers/ovumMira.js +152 -0
- package/modules/devices/lib/ovumMiraAliases.js +61 -0
- package/modules/devices/lib/ovumMiraConnection.js +32 -0
- package/modules/devices/lib/templates.json +976 -0
- package/modules/devices/test/aliasContractV1.test.js +4 -4
- package/modules/devices/test/deviceAliasSemantics.test.js +2 -2
- package/modules/devices/test/fixtures/approved-additive-templates.json +3 -1
- package/modules/devices/test/ovumMiraPairing.test.js +76 -0
- package/modules/devices/test/ovumMiraTemplates.test.js +110 -0
- package/modules/devices/test/ovumMiraTransport.test.js +201 -0
- package/modules/eebus/README.md +8 -0
- package/modules/eebus/admin/index.js +29 -2
- package/modules/eebus/build/index.js +28 -3
- package/modules/eebus/build/lib/eebusRuntime.js +17 -2
- package/modules/eebus/build/lib/partnerMonitor.js +160 -0
- package/modules/eebus/build/lib/shipEndpoint.js +4 -0
- package/modules/eebus/build/lib/stateDefinitions.js +1 -0
- package/modules/eebus/src/index.ts +23 -3
- package/modules/eebus/src/lib/eebusRuntime.ts +20 -2
- package/modules/eebus/src/lib/partnerMonitor.ts +127 -0
- package/modules/eebus/src/lib/shipEndpoint.ts +5 -0
- package/modules/eebus/src/lib/stateDefinitions.ts +1 -0
- package/modules/eebus/test/partner-monitor.test.js +82 -0
- package/modules/eebus/test/security.test.js +17 -0
- package/modules/ocpp/README.md +9 -1
- package/modules/ocpp/build/index.js +137 -10
- package/modules/ocpp/build/stationHistory.js +113 -0
- package/modules/ocpp/ocpp/freshness.d.ts +3 -0
- package/modules/ocpp/ocpp/freshness.js +6 -0
- package/modules/ocpp/provenance.json +3 -2
- package/modules/ocpp/runtime.d.ts +1 -0
- package/modules/ocpp/runtime.js +23 -1
- package/modules/ocpp/src/index.ts +163 -12
- package/modules/ocpp/src/stationHistory.ts +119 -0
- package/modules/ocpp/test/hosted.test.cjs +161 -0
- package/package.json +9 -5
- package/release-manifests/unified/build-environment.cdx.json +6 -6
- package/release-manifests/unified/files.json +313 -190
- package/release-manifests/unified/frontend.cdx.json +6 -6
- package/release-manifests/unified/installer.cdx.json +6 -6
- package/release-manifests/unified/obsolete-admin-assets.json +166 -0
- package/release-manifests/unified/runtime.cdx.json +30 -30
- package/release-manifests/unified/validation.json +15 -15
- package/tools/eos-release-manifest.cjs +1 -1
- package/ui/ems/consumers/ovum-mira.js +164 -0
- package/ui/ems/modules/para14a.js +3 -2
- package/ui/ems/modules/stage-a-diagnostics.js +4 -2
- package/ui/ems/modules/thermal-control.js +91 -10
- package/ui/io-package.json +9 -1
- package/ui/lib/installer-lifecycle.js +11 -2
- package/ui/lib/notification-mail.js +235 -40
- package/ui/lib/notification-policy.js +41 -14
- package/ui/main.js +37 -7
- package/ui/package.json +2 -1
- package/ui/www/app.js +122 -24
- package/ui/www/dashboard-lp-status.js +4 -11
- package/ui/www/dashboard-process-status.js +202 -0
- package/ui/www/ems-apps.js +28 -9
- package/ui/www/i18n/en.json +23 -0
- package/ui/www/i18n/nl.json +20 -0
- package/ui/www/index.html +10 -5
- package/ui/www/licenses/smarthome-markdown-components.json +156 -156
- package/ui/www/live-display.js +101 -9
- package/ui/www/manifest.webmanifest +2 -2
- package/ui/www/settings.html +2 -2
- package/ui/www/styles.css +4 -0
- package/adminWww/assets/AddLink-0L0E-LsA.js +0 -1
- package/adminWww/assets/ColorLens-DA51K29x.js +0 -1
- package/adminWww/assets/ConfigManager-DbqTWi2N.js +0 -1
- package/adminWww/assets/Enums-DjldGElU.js +0 -92
- package/adminWww/assets/Fields-0GsPCJeU.js +0 -1
- package/adminWww/assets/FileCopy-B16lEuur.js +0 -1
- package/adminWww/assets/Files-COnUtEbg.js +0 -1
- package/adminWww/assets/Instances-CUX5mxMQ.js +0 -4
- package/adminWww/assets/Intro-BhQmHn3A.js +0 -2
- package/adminWww/assets/Lens-9lkeoWGk.js +0 -1
- package/adminWww/assets/LinearScale-Be5h2beh.js +0 -1
- package/adminWww/assets/North-C2whbHM-.js +0 -1
- package/adminWww/assets/Overview-CitzUjBF.js +0 -3
- package/adminWww/assets/PersonOff-DqBq0Fho.js +0 -1
- package/adminWww/assets/PlaylistAdd-O8k92YBd.js +0 -1
- package/adminWww/assets/State-D5ljzf-T.js +0 -1
- package/adminWww/assets/UsedResources-BY_NF2wB.js +0 -2
- package/adminWww/assets/Users-Cu93_-VF.js +0 -1
- package/adminWww/assets/date-fns-C1dqkno9.js +0 -1
- package/adminWww/assets/icons-material-DjqX0l_7.js +0 -1
- package/adminWww/assets/isSameWeek-Crh37s7U.js +0 -1
- package/adminWww/assets/isWithinInterval-Bo1WiDfq.js +0 -1
- package/adminWww/assets/locale-hLcz_Xh2.js +0 -1
- package/adminWww/assets/sentry-DwQQLI7N.js +0 -1
- package/adminWww/assets/startOfWeek-DJph8SIW.js +0 -1
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/* Copyright (c) 2026 NexoWatt. Confidential and proprietary. */
|
|
2
|
+
// @ts-check
|
|
3
|
+
'use strict';
|
|
4
|
+
/** @typedef {import('./eosDashboardProcessStatus').DashboardProcessId} ProcessId */
|
|
5
|
+
/** @typedef {import('./eosDashboardProcessStatus').DashboardProcessStatus} DashboardStatus */
|
|
6
|
+
/** @type {readonly ProcessId[]} */
|
|
7
|
+
const PROCESS_IDS = ['ui', 'ems', 'devices', 'eebus', 'backup', 'ocpp'];
|
|
8
|
+
const PROCESS_FAILURES = new Set(['failed', 'error', 'backoff']);
|
|
9
|
+
const STOP_FAILURES = new Set(['STOP_FAILED_RESTART_REQUIRED', 'EOS_RUNTIME_STOP_UNCONFIRMED', 'EOS_MODULE_STOP_UNCONFIRMED',
|
|
10
|
+
'EOS_MODULE_PROCESS_STOP_UNCONFIRMED', 'EOS_UI_PROCESS_STOP_UNCONFIRMED']);
|
|
11
|
+
const HOST_FAILURES = new Set(['START_FAILED', 'START_FAILED_RESTART_REQUIRED', 'PROCESS_BACKOFF', 'MODULE_CALLBACK_FAILED',
|
|
12
|
+
'CONFIG_INVALID', 'LEGACY_CONFLICT', 'OWNERSHIP_UNAVAILABLE', 'EOS_OWNERSHIP_REQUIRED', 'STOPPED']);
|
|
13
|
+
/** @param {unknown} value @returns {Record<string, unknown>} */
|
|
14
|
+
function record(value) {
|
|
15
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? /** @type {Record<string, unknown>} */ (value) : {};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Classify one local supervisor observation. Generation zero is valid for a hosted
|
|
19
|
+
* module. Its first confirmed heartbeat may arrive after start() has completed.
|
|
20
|
+
* @param {ProcessId} id @param {unknown} input @param {number} now
|
|
21
|
+
* @returns {'ok'|'fault'|'unknown'|'paused'}
|
|
22
|
+
*/
|
|
23
|
+
function processStatus(id, input, now) {
|
|
24
|
+
const source = record(input);
|
|
25
|
+
const child = record(source.process);
|
|
26
|
+
const reason = typeof source.reason === 'string' ? source.reason : '';
|
|
27
|
+
const state = typeof child.state === 'string' ? child.state : '';
|
|
28
|
+
if (STOP_FAILURES.has(reason) || (typeof child.lastError === 'string' && STOP_FAILURES.has(child.lastError)))
|
|
29
|
+
return 'fault';
|
|
30
|
+
if (source.enabled === false || source.configured === false)
|
|
31
|
+
return 'paused';
|
|
32
|
+
if (source.enabled !== true)
|
|
33
|
+
return 'unknown';
|
|
34
|
+
if (reason === 'CONFIG_INVALID')
|
|
35
|
+
return 'fault';
|
|
36
|
+
if (source.configured !== true)
|
|
37
|
+
return 'unknown';
|
|
38
|
+
const splitWorker = id === 'ui' || id === 'ems';
|
|
39
|
+
if (!splitWorker && reason === 'LICENSE_REQUIRED')
|
|
40
|
+
return 'paused';
|
|
41
|
+
if (HOST_FAILURES.has(reason) || PROCESS_FAILURES.has(state))
|
|
42
|
+
return 'fault';
|
|
43
|
+
if (state === 'stopped') {
|
|
44
|
+
// Before the very first acquisition, the supervisors can report a
|
|
45
|
+
// stopped placeholder while preparing to schedule the initial start.
|
|
46
|
+
if (reason === 'READY' || reason === 'STARTING' || reason === 'CONFIG_CHANGED' ||
|
|
47
|
+
(splitWorker && child.generation === 0 && !child.lastError))
|
|
48
|
+
return 'unknown';
|
|
49
|
+
return 'fault';
|
|
50
|
+
}
|
|
51
|
+
if (state !== 'running')
|
|
52
|
+
return 'unknown';
|
|
53
|
+
// Only a fresh acknowledgement from the current supervised process counts.
|
|
54
|
+
const heartbeat = child.lastHeartbeatAt;
|
|
55
|
+
if (typeof heartbeat !== 'number' || !Number.isSafeInteger(heartbeat) || heartbeat <= 0 || heartbeat > now)
|
|
56
|
+
return 'unknown';
|
|
57
|
+
if (now - heartbeat > (splitWorker ? 5000 : 4000))
|
|
58
|
+
return 'fault';
|
|
59
|
+
if (typeof child.pid !== 'number' || !Number.isSafeInteger(child.pid) || child.pid < 1 ||
|
|
60
|
+
typeof child.generation !== 'number' || !Number.isSafeInteger(child.generation) || child.generation < 0)
|
|
61
|
+
return 'unknown';
|
|
62
|
+
if (source.active !== true)
|
|
63
|
+
return source.active === false ? 'fault' : 'unknown';
|
|
64
|
+
if (id === 'ems' && source.emsReady !== true) {
|
|
65
|
+
if (source.emsReady !== false || ['starting', 'idle'].includes(reason))
|
|
66
|
+
return 'unknown';
|
|
67
|
+
return 'fault';
|
|
68
|
+
}
|
|
69
|
+
return 'ok';
|
|
70
|
+
}
|
|
71
|
+
/** @param {unknown} name @returns {boolean} */
|
|
72
|
+
function safeName(name) {
|
|
73
|
+
return typeof name === 'string' && name.length > 0 && name.length <= 64 && name.trim() === name
|
|
74
|
+
&& /^[\p{L}\p{M}\p{N} ()_–·-]+$/u.test(name) && !/\d{6,}|[a-f\d]{16,}|(?:[a-f\d]{2}-){5}[a-f\d]{2}/i.test(name);
|
|
75
|
+
}
|
|
76
|
+
/** The child is an IPC boundary. Accept only bounded, allowlisted values and
|
|
77
|
+
* select individual fields before retaining a snapshot in the parent.
|
|
78
|
+
* @param {unknown} raw @returns {import('./eosDashboardProcessStatus').InternalDeviceHealth|null}
|
|
79
|
+
*/
|
|
80
|
+
function normalizedDeviceHealth(raw) {
|
|
81
|
+
const value = record(raw);
|
|
82
|
+
const state = value.state;
|
|
83
|
+
if (state !== 'ok' && state !== 'fault' && state !== 'unknown')
|
|
84
|
+
return null;
|
|
85
|
+
const count = value.totalOffline;
|
|
86
|
+
if (typeof count !== 'number' || !Number.isSafeInteger(count) || count < 0 || count > 10000 ||
|
|
87
|
+
(state === 'fault') !== (count > 0) || !Array.isArray(value.offline) ||
|
|
88
|
+
value.offline.length !== Math.min(count, 12) || !Array.isArray(value.tracked) || value.tracked.length > 256)
|
|
89
|
+
return null;
|
|
90
|
+
const offline = [];
|
|
91
|
+
for (const item of value.offline) {
|
|
92
|
+
const name = record(item).name;
|
|
93
|
+
if (typeof name !== 'string' || !safeName(name))
|
|
94
|
+
return null;
|
|
95
|
+
offline.push({ name });
|
|
96
|
+
}
|
|
97
|
+
/** @type {import('./eosDashboardProcessStatus').InternalDeviceHealth['tracked']} */
|
|
98
|
+
const tracked = [];
|
|
99
|
+
const keys = new Set();
|
|
100
|
+
for (const item of value.tracked) {
|
|
101
|
+
const { key, name, state: status } = record(item);
|
|
102
|
+
if (typeof key !== 'string' || !/^[a-f0-9]{64}$/.test(key) || keys.has(key) ||
|
|
103
|
+
typeof name !== 'string' || !safeName(name) ||
|
|
104
|
+
(status !== 'online' && status !== 'offline' && status !== 'unknown' && status !== 'disabled'))
|
|
105
|
+
return null;
|
|
106
|
+
keys.add(key);
|
|
107
|
+
tracked.push({ key, name, state: status });
|
|
108
|
+
}
|
|
109
|
+
const confirmed = tracked.filter(item => item.state === 'offline').length;
|
|
110
|
+
if (confirmed > count || (value.complete === true && confirmed !== count) ||
|
|
111
|
+
(state === 'ok' && tracked.some(item => item.state === 'unknown')))
|
|
112
|
+
return null;
|
|
113
|
+
return { state, totalOffline: count, offline, tracked, complete: value.complete === true };
|
|
114
|
+
}
|
|
115
|
+
/** @param {Record<string, unknown>} own @param {number} now */
|
|
116
|
+
function freshDeviceReport(own, now) {
|
|
117
|
+
const stamp = own.observedAt;
|
|
118
|
+
return typeof stamp === 'number' && Number.isSafeInteger(stamp) && stamp > 0 && stamp <= now && now - stamp <= 6000;
|
|
119
|
+
}
|
|
120
|
+
/** Internal automation observes the same bounded supervisor snapshot; the public
|
|
121
|
+
* HTTP API never returns these opaque keys. A missing source cannot clear incidents.
|
|
122
|
+
* @param {unknown} sources @param {number} [now]
|
|
123
|
+
* @returns {ReturnType<typeof import('./eosDashboardProcessStatus').notificationProcessStatus>}
|
|
124
|
+
*/
|
|
125
|
+
function notificationProcessStatus(sources, now = Date.now()) {
|
|
126
|
+
/** @type {ReturnType<typeof import('./eosDashboardProcessStatus').notificationProcessStatus>} */
|
|
127
|
+
const result = { processes: { ui: 'unknown', ems: 'unknown', devices: 'unknown', eebus: 'unknown', backup: 'unknown', ocpp: 'unknown' },
|
|
128
|
+
devices: { devices: { complete: false, tracked: [] }, eebus: { complete: false, tracked: [] }, ocpp: { complete: false, tracked: [] } } };
|
|
129
|
+
if (!Number.isSafeInteger(now) || now <= 0)
|
|
130
|
+
return result;
|
|
131
|
+
const snapshot = record(sources);
|
|
132
|
+
for (const id of PROCESS_IDS) {
|
|
133
|
+
const item = record(snapshot[id]);
|
|
134
|
+
const status = processStatus(id, item, now);
|
|
135
|
+
result.processes[id] = status === 'ok' ? 'online' : status === 'fault' ? 'offline' : status === 'paused' ? 'disabled' : 'unknown';
|
|
136
|
+
if ((id === 'devices' || id === 'eebus' || id === 'ocpp') && status === 'ok') {
|
|
137
|
+
const own = record(item.deviceHealth);
|
|
138
|
+
const data = freshDeviceReport(own, now) ? normalizedDeviceHealth(own) : null;
|
|
139
|
+
if (data)
|
|
140
|
+
result.devices[id] = { complete: data.complete, tracked: data.tracked };
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Fixed, customer-visible projection. It reads only a synchronous in-memory
|
|
147
|
+
* snapshot. No inventory, raw reason, address, configuration or PID leaves it.
|
|
148
|
+
* @param {unknown} sources @param {number} [now] @returns {DashboardStatus}
|
|
149
|
+
*/
|
|
150
|
+
function dashboardProcessStatus(sources, now = Date.now()) {
|
|
151
|
+
const result = /** @type {DashboardStatus} */ ({ observedAt: now, state: 'ok', failed: [], paused: [],
|
|
152
|
+
deviceHealth: { state: 'ok', offline: [], totalOffline: 0 } });
|
|
153
|
+
if (!Number.isSafeInteger(now) || now <= 0)
|
|
154
|
+
return { ...result, observedAt: 0, state: 'unknown', deviceHealth: { state: 'unknown', offline: [], totalOffline: 0 } };
|
|
155
|
+
const snapshot = record(sources);
|
|
156
|
+
for (const id of PROCESS_IDS) {
|
|
157
|
+
const input = record(snapshot[id]);
|
|
158
|
+
const state = processStatus(id, input, now);
|
|
159
|
+
if ((id === 'devices' || id === 'eebus' || id === 'ocpp') && state !== 'paused') {
|
|
160
|
+
// Parent getter has already validated and bounded the IPC report once.
|
|
161
|
+
// Never echo tracked keys. A stopped owner cannot attest to physical reachability.
|
|
162
|
+
const own = state === 'ok' ? record(input.deviceHealth) : {};
|
|
163
|
+
const current = freshDeviceReport(own, now);
|
|
164
|
+
const count = own.totalOffline;
|
|
165
|
+
if (current && own.state === 'fault' && typeof count === 'number' && Number.isSafeInteger(count) &&
|
|
166
|
+
count > 0 && count <= 10000 && Array.isArray(own.offline) && own.offline.length === Math.min(12, count)
|
|
167
|
+
&& own.offline.every(item => safeName(record(item).name))) {
|
|
168
|
+
result.deviceHealth.totalOffline = Math.min(10000, result.deviceHealth.totalOffline + count);
|
|
169
|
+
for (const item of own.offline.slice(0, 12 - result.deviceHealth.offline.length)) {
|
|
170
|
+
result.deviceHealth.offline.push({ name: String(record(item).name) });
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
else if (!current || own.state !== 'ok' || count !== 0 || !Array.isArray(own.offline) || own.offline.length) {
|
|
174
|
+
result.deviceHealth.state = 'unknown';
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (state === 'paused')
|
|
178
|
+
result.paused.push(id);
|
|
179
|
+
else if (state === 'fault')
|
|
180
|
+
result.failed.push(id);
|
|
181
|
+
else if (state === 'unknown')
|
|
182
|
+
result.state = 'unknown';
|
|
183
|
+
}
|
|
184
|
+
if (result.deviceHealth.totalOffline)
|
|
185
|
+
result.deviceHealth.state = 'fault';
|
|
186
|
+
if (result.failed.length)
|
|
187
|
+
result.state = 'fault';
|
|
188
|
+
return result;
|
|
189
|
+
}
|
|
190
|
+
module.exports = { dashboardProcessStatus, notificationProcessStatus, normalizedDeviceHealth };
|
|
191
|
+
//# sourceMappingURL=eosDashboardProcessStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eosDashboardProcessStatus.js","sourceRoot":"./src/","sources":["lib/eosDashboardProcessStatus.js"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,YAAY;AACZ,YAAY,CAAC;AAEb,oFAAoF;AACpF,8FAA8F;AAC9F,mCAAmC;AACnC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AAsB,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -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))
|