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.
- package/NEXOWATT_EOS_BUILD_INFO.json +10 -11
- package/README.md +7 -9
- 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-5L75o18m.js} +5 -5
- package/adminWww/assets/{Adapters-dDEp7o5h.js → Adapters-FcghjF7E.js} +5 -5
- package/adminWww/assets/ConfigManager-BnHarBfH.js +1 -0
- package/adminWww/assets/Enums-BjLbLLQL.js +92 -0
- package/adminWww/assets/Fields-DDE1hVOa.js +1 -0
- package/adminWww/assets/Files-CDjnR4q6.js +1 -0
- package/adminWww/assets/{Hosts-CwU1LujG.js → Hosts-CJKQaNrD.js} +6 -6
- package/adminWww/assets/Instances-DZNl369k.js +4 -0
- package/adminWww/assets/Intro-CjAmMGDB.js +2 -0
- package/adminWww/assets/KeyboardArrowRight-ifvmV1ZL.js +1 -0
- package/adminWww/assets/{Logs-B5SpNqHq.js → Logs-rUAV7SwM.js} +2 -2
- package/adminWww/assets/MoreHoriz-CS7nODK8.js +1 -0
- package/adminWww/assets/{Objects-COg_cFkz.js → Objects-CqOH6rT_.js} +4 -4
- package/adminWww/assets/Overview-BOtXqsMy.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-C8ncThop.js +1 -0
- package/adminWww/assets/UsedResources-lUYJqy4F.js +2 -0
- package/adminWww/assets/Users-CK1Cax82.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-CC0Qr-kr.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-DqGL6nY8.js} +1 -1
- package/adminWww/assets/icons-material-07rWS63O.js +1 -0
- package/adminWww/assets/{index-nddph2Sl.js → index-BhhkToP2.js} +2 -2
- package/adminWww/assets/{installSVGRenderer-CPDIwFAL.js → installSVGRenderer-B4-7lSQZ.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-1afd2287.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.34.js +12 -0
- package/adminWww/remoteEntry.js +1 -1
- 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/docs/README.md +2 -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/start/START_HIER_9.0.34.md +25 -0
- package/io-package.json +8 -8
- 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/index.js +5 -1
- package/modules/devices/lib/alias-contract-v1.json +22 -0
- package/modules/devices/lib/deviceRuntime.js +17 -7
- package/modules/devices/lib/drivers/modbus.js +1 -1
- package/modules/devices/lib/drivers/modbusRtuBus.js +7 -1
- package/modules/devices/lib/drivers/ovumMira.js +148 -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 +162 -0
- package/package.json +6 -4
- package/release-manifests/unified/build-environment.cdx.json +6 -6
- package/release-manifests/unified/files.json +155 -112
- 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 +83 -0
- package/release-manifests/unified/runtime.cdx.json +27 -27
- 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 +5 -1
- package/ui/lib/installer-lifecycle.js +11 -2
- package/ui/main.js +37 -7
- package/ui/package.json +1 -1
- package/ui/www/app.js +32 -14
- package/ui/www/ems-apps.js +28 -9
- package/ui/www/licenses/smarthome-markdown-components.json +156 -156
- package/ui/www/manifest.webmanifest +2 -2
- 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
- package/adminWww/remoteEntry-eos-9.0.33.js +0 -12
|
@@ -76,7 +76,11 @@ test('Devices EMS form: wallbox default, meter/PV targets, storage choice, durab
|
|
|
76
76
|
}, id);
|
|
77
77
|
await page.waitForSelector('#dev_ems_mode', { visible: true });
|
|
78
78
|
}
|
|
79
|
-
async function keepDraft() {
|
|
79
|
+
async function keepDraft() {
|
|
80
|
+
await page.click('#btnSaveDevice');
|
|
81
|
+
await page.waitForSelector('#modalDevice', { hidden: true });
|
|
82
|
+
await page.waitForSelector('.modal-overlay', { hidden: true });
|
|
83
|
+
}
|
|
80
84
|
await edit('evcs1');
|
|
81
85
|
assert.equal(await page.$eval('#dev_ems_mode', e => e.value), 'auto');
|
|
82
86
|
assert.match(await page.$eval('#dev_ems_help', e => e.textContent), /automatisch unter Ladepunkte/);
|
|
@@ -95,7 +99,9 @@ test('Devices EMS form: wallbox default, meter/PV targets, storage choice, durab
|
|
|
95
99
|
if (screenshots) { await fs.mkdir(screenshots, { recursive: true }); await page.screenshot({ path: path.join(screenshots, 'devices-ems-desktop.png') }); }
|
|
96
100
|
await keepDraft();
|
|
97
101
|
await page.click('#eosModuleSave');
|
|
98
|
-
await page.waitForFunction(() => document.getElementById('eosEmsStatus').textContent.includes('4 Gerät(e) zugeordnet') && !document.getElementById('eosDeviceEditor').inert)
|
|
102
|
+
await page.waitForFunction(() => document.getElementById('eosEmsStatus').textContent.includes('4 Gerät(e) zugeordnet') && !document.getElementById('eosDeviceEditor').inert)
|
|
103
|
+
.catch(async error => { throw new Error(await page.$eval('#eosModuleStatus', e => e.textContent) + ' / ' +
|
|
104
|
+
await page.$eval('#eosEmsStatus', e => e.textContent) + ' / ' + errors.join(' '), { cause: error }); });
|
|
99
105
|
assert.equal(received.filter(r => r.method === 'PUT').length, 1);
|
|
100
106
|
const byId = Object.fromEntries(config.devices.map(d => [d.id, d]));
|
|
101
107
|
assert.equal(byId.evcs1.ems.mode, 'auto'); assert.equal(byId.evcs1.ems.activation.limits.maxCurrentA, 16);
|
|
@@ -122,11 +128,55 @@ test('Devices EMS form: wallbox default, meter/PV targets, storage choice, durab
|
|
|
122
128
|
await page.$eval('.modal-content', e => { e.scrollTop = 0; });
|
|
123
129
|
if (screenshots) await page.screenshot({ path: path.join(screenshots, 'devices-ems-mobile.png') });
|
|
124
130
|
await page.click('#btnCancelDevice');
|
|
131
|
+
await page.setViewport({ width: 1440, height: 1050 });
|
|
125
132
|
await page.reload();
|
|
126
133
|
await page.waitForFunction(() => !document.getElementById('eosDeviceEditor').inert);
|
|
127
134
|
await page.click('a[href="#tabDevices"]'); await edit('meter1');
|
|
128
135
|
assert.equal(await page.$eval('#dev_ems_mode', e => e.value), 'generationMeter');
|
|
129
136
|
assert.equal(await page.$eval('#dev_ems_slot', e => e.value), '1');
|
|
130
137
|
assert.equal(await page.$eval('#dev_name', e => e.value), 'meter1');
|
|
138
|
+
await page.click('#btnCancelDevice');
|
|
139
|
+
await page.waitForSelector('.modal-overlay', { hidden: true });
|
|
140
|
+
await page.click('#btnAddDevice');
|
|
141
|
+
await page.select('#dev_category', 'HEAT');
|
|
142
|
+
await page.select('#dev_manufacturer', 'OVUM');
|
|
143
|
+
await page.select('#dev_template', 'heat.ovum.mira.hsm');
|
|
144
|
+
await page.select('#dev_protocol', 'modbusTcp');
|
|
145
|
+
await page.waitForSelector('#mira_pair_settings', { visible: true });
|
|
146
|
+
assert.equal(await page.$eval('#mira_wpm_choice', e => e.value), 'same');
|
|
147
|
+
assert.equal(await page.$eval('#mira_wpm_unit', e => e.value), '111');
|
|
148
|
+
assert.equal(await page.$eval('#mb_unitId', e => e.value), '110');
|
|
149
|
+
assert.equal(await page.$eval('#dev_ems_requested', e => e.checked), false);
|
|
150
|
+
assert.equal(await page.$eval('#dev_ems_miraSources', e => e.checked), false);
|
|
151
|
+
const hsmId = await page.$eval('#dev_id', e => e.value);
|
|
152
|
+
await page.type('#mb_host', '192.0.2.77');
|
|
153
|
+
await keepDraft();
|
|
154
|
+
await page.click('#eosModuleSave');
|
|
155
|
+
await page.waitForFunction(() => !document.getElementById('eosDeviceEditor').inert &&
|
|
156
|
+
document.querySelectorAll('#devicesTable tbody tr').length === 6);
|
|
157
|
+
await page.waitForFunction(() => document.getElementById('eosModuleStatus').textContent.includes('Gerätekonfiguration geladen'));
|
|
158
|
+
const hsm = config.devices.find(d => d.id === hsmId);
|
|
159
|
+
const wpm = config.devices.find(d => d.id === hsm.connection.miraWpmDeviceId);
|
|
160
|
+
assert.equal(wpm.templateId, 'heat.ovum.mira.wpm');
|
|
161
|
+
assert.equal(wpm.connection.unitId, 111);
|
|
162
|
+
assert.equal(wpm.connection.host, hsm.connection.host);
|
|
163
|
+
await page.reload();
|
|
164
|
+
await page.waitForFunction(() => !document.getElementById('eosDeviceEditor').inert);
|
|
165
|
+
await page.click('a[href="#tabDevices"]'); await edit(hsmId);
|
|
166
|
+
assert.equal(await page.$eval('#mira_wpm_choice', e => e.value), 'id:' + wpm.id);
|
|
167
|
+
assert.equal(await page.$eval('#mira_wpm_unit_field', e => e.hidden), true);
|
|
168
|
+
assert.equal(hsm.ems.activation.requested, false);
|
|
169
|
+
await page.$eval('#dev_ems_requested', e => e.click());
|
|
170
|
+
await page.waitForSelector('#dev_ems_miraMaxW', { visible: true });
|
|
171
|
+
await page.$eval('#dev_ems_miraSources', e => e.click());
|
|
172
|
+
await page.type('#dev_ems_miraMaxW', '4500');
|
|
173
|
+
await keepDraft();
|
|
174
|
+
await page.click('#eosModuleSave');
|
|
175
|
+
await page.waitForFunction(() => document.getElementById('eosModuleStatus').textContent.includes('Gerätekonfiguration geladen'));
|
|
176
|
+
const consent = config.devices.find(d => d.id === hsmId).ems.activation;
|
|
177
|
+
assert.equal(consent.requested, true);
|
|
178
|
+
assert.equal(consent.limits.miraSources, 'confirmed');
|
|
179
|
+
assert.equal(consent.limits.maxPowerW, 4500);
|
|
180
|
+
assert.equal(config.devices.filter(d => d.id === wpm.id).length, 1);
|
|
131
181
|
assert.deepEqual(errors, []);
|
|
132
182
|
});
|
package/modules/devices/index.js
CHANGED
|
@@ -96,7 +96,7 @@ function validateConfig(input = {}) {
|
|
|
96
96
|
if (activation.limits !== undefined) {
|
|
97
97
|
const limits = activation.limits;
|
|
98
98
|
const numbers = ['maxChargeW', 'maxDischargeW', 'capacityKWh', 'minCurrentA', 'maxCurrentA', 'minPowerW', 'maxPowerW'];
|
|
99
|
-
if (!record(limits) || Object.keys(limits).some(key => ![...numbers, 'coupling', 'chargerType', 'phases'].includes(key))) throw failure('EOS_DEVICES_EMS_LIMITS');
|
|
99
|
+
if (!record(limits) || Object.keys(limits).some(key => ![...numbers, 'coupling', 'chargerType', 'phases', 'miraSources'].includes(key))) throw failure('EOS_DEVICES_EMS_LIMITS');
|
|
100
100
|
for (const key of numbers) {
|
|
101
101
|
const value = Reflect.get(limits, key);
|
|
102
102
|
if (value !== undefined && (typeof value !== 'number' || !Number.isFinite(value) || value <= 0 || value > 10000000)) throw failure('EOS_DEVICES_EMS_LIMITS');
|
|
@@ -105,6 +105,7 @@ function validateConfig(input = {}) {
|
|
|
105
105
|
const value = Reflect.get(limits, key);
|
|
106
106
|
if (value !== undefined && (typeof value !== 'string' || !['ac', 'dc'].includes(value))) throw failure('EOS_DEVICES_EMS_LIMITS');
|
|
107
107
|
}
|
|
108
|
+
if (limits.miraSources !== undefined && (device.templateId !== 'heat.ovum.mira.hsm' || limits.miraSources !== 'confirmed')) throw failure('EOS_DEVICES_EMS_LIMITS');
|
|
108
109
|
if (limits.phases !== undefined && (typeof limits.phases !== 'number' || ![1, 3].includes(limits.phases))) throw failure('EOS_DEVICES_EMS_LIMITS');
|
|
109
110
|
if (typeof limits.minCurrentA === 'number' && typeof limits.maxCurrentA === 'number' && limits.minCurrentA > limits.maxCurrentA
|
|
110
111
|
|| typeof limits.minPowerW === 'number' && typeof limits.maxPowerW === 'number' && limits.minPowerW > limits.maxPowerW) throw failure('EOS_DEVICES_EMS_LIMITS');
|
|
@@ -113,6 +114,9 @@ function validateConfig(input = {}) {
|
|
|
113
114
|
}
|
|
114
115
|
if (device.connection !== undefined && !record(device.connection)) throw failure('EOS_DEVICES_CONFIG_CONNECTION');
|
|
115
116
|
const connection = device.connection || {};
|
|
117
|
+
if (device.templateId === 'heat.ovum.mira.hsm' || device.templateId === 'heat.ovum.mira.wpm') {
|
|
118
|
+
require('./lib/ovumMiraConnection').miraConnection(device.templateId.endsWith('.hsm') ? 'hsm' : 'wpm', device.protocol, connection);
|
|
119
|
+
}
|
|
116
120
|
if (connection.insecureTls === true || connection.insecureTLS === true || connection.allowInsecureTls === true || connection.rejectUnauthorized === false) throw failure('EOS_DEVICES_TLS_VERIFICATION_REQUIRED');
|
|
117
121
|
if (device.pollIntervalMs !== undefined && device.pollIntervalMs !== 0) device.pollIntervalMs = integer(device.pollIntervalMs, 5000, 250, 600000);
|
|
118
122
|
for (const field of ['port', 'tcpPort', 'mqttPort']) {
|
|
@@ -1304,6 +1304,28 @@
|
|
|
1304
1304
|
"role": "level.power",
|
|
1305
1305
|
"unit": "W",
|
|
1306
1306
|
"capability": "write.externalPower"
|
|
1307
|
+
},
|
|
1308
|
+
"r.pvStatus": {
|
|
1309
|
+
"type": "number",
|
|
1310
|
+
"role": "value",
|
|
1311
|
+
"capability": "read.pvStatus"
|
|
1312
|
+
},
|
|
1313
|
+
"ctrl.pvStatus": {
|
|
1314
|
+
"type": "number",
|
|
1315
|
+
"role": "level",
|
|
1316
|
+
"capability": "write.pvStatus"
|
|
1317
|
+
},
|
|
1318
|
+
"r.pvPowerTargetW": {
|
|
1319
|
+
"type": "number",
|
|
1320
|
+
"role": "value.power",
|
|
1321
|
+
"unit": "W",
|
|
1322
|
+
"capability": "read.pvPowerTargetW"
|
|
1323
|
+
},
|
|
1324
|
+
"ctrl.pvPowerTargetW": {
|
|
1325
|
+
"type": "number",
|
|
1326
|
+
"role": "level.power",
|
|
1327
|
+
"unit": "W",
|
|
1328
|
+
"capability": "write.pvPowerTargetW"
|
|
1307
1329
|
}
|
|
1308
1330
|
}
|
|
1309
1331
|
},
|
|
@@ -13,6 +13,7 @@ const {
|
|
|
13
13
|
buildManifest: buildAliasManifest,
|
|
14
14
|
mergeStandardDefinition,
|
|
15
15
|
} = require('./aliasContract');
|
|
16
|
+
const { miraUnit, buildMiraAliases, freshPaths: miraFreshnessPaths } = require('./ovumMiraAliases');
|
|
16
17
|
const { getDeyeProfile, buildDeyeAliases } = require('./deyeProtocol');
|
|
17
18
|
const { getVartaProfile, registersForProfile, buildVartaAliases } = require('./vartaProtocol');
|
|
18
19
|
const { extendedRegistersForProfile, buildVartaExtendedAliases } = require('./vartaExtendedProtocol');
|
|
@@ -696,7 +697,7 @@ class DeviceRuntime {
|
|
|
696
697
|
}
|
|
697
698
|
|
|
698
699
|
_computeLiveAliasRefreshMs({ fastIntervalMs, isEventDriven } = {}) {
|
|
699
|
-
if (this.aliasDeviceClass !== 'evCharger' && !isEnergyFreshnessClass(this.aliasDeviceClass)) return 0;
|
|
700
|
+
if (this.aliasDeviceClass !== 'evCharger' && !isEnergyFreshnessClass(this.aliasDeviceClass) && !miraUnit(this.template)) return 0;
|
|
700
701
|
|
|
701
702
|
const candidates = [
|
|
702
703
|
this.cfg && this.cfg.liveStatusRefreshMs,
|
|
@@ -739,12 +740,13 @@ class DeviceRuntime {
|
|
|
739
740
|
|
|
740
741
|
_liveAliasRefreshOptions(relId, values, ctx, sourceIds = []) {
|
|
741
742
|
if (!(this._liveAliasRefreshMs > 0)) return undefined;
|
|
742
|
-
const
|
|
743
|
+
const path = legacyAliasPath(relId);
|
|
744
|
+
const energyAlias = isEnergyFreshnessAlias(this.aliasDeviceClass, path) ||
|
|
745
|
+
(miraUnit(this.template) && miraFreshnessPaths.has(path));
|
|
743
746
|
if (!this._isEvChargerFreshnessAlias(relId) && !energyAlias) return undefined;
|
|
744
747
|
if (ctx && (ctx.connected === false || ctx.diagnosticsOnly === true)) return undefined;
|
|
745
748
|
if (!values || typeof values !== 'object' || Object.keys(values).length === 0) return undefined;
|
|
746
749
|
if (energyAlias) {
|
|
747
|
-
const path = legacyAliasPath(relId);
|
|
748
750
|
const connectionAlias = path === 'comm.connected' || path === 'alarm.offline';
|
|
749
751
|
if (!hasNewAliasSample({
|
|
750
752
|
protocol: String(this.cfg.protocol || '').toLowerCase(),
|
|
@@ -1164,7 +1166,8 @@ class DeviceRuntime {
|
|
|
1164
1166
|
// --- Generic role-based aliases (best-effort) ---
|
|
1165
1167
|
// Only use these for categories where roles are typically reliable and where "first match wins" is acceptable.
|
|
1166
1168
|
// For meters, chargers, batteries and ESS we create dedicated alias mapping further below.
|
|
1167
|
-
const
|
|
1169
|
+
const mira = miraUnit(this.template);
|
|
1170
|
+
const allowGenericRoleAliases = !mira && !chargerCats.has(cat) && !['METER', 'BATTERY', 'ESS', 'BATTERY_INVERTER'].includes(cat);
|
|
1168
1171
|
|
|
1169
1172
|
if (allowGenericRoleAliases) {
|
|
1170
1173
|
const powerDp = getAnyById('W') || this._findFirstDatapoint(dp => dp.role === 'value.power' && dp.rw !== 'wo');
|
|
@@ -1214,7 +1217,9 @@ class DeviceRuntime {
|
|
|
1214
1217
|
// --- HEAT aliases (heat pumps / heating systems) ---
|
|
1215
1218
|
// Provide a stable API for heat pumps so that higher-level control adapters can link
|
|
1216
1219
|
// against consistent alias names even if manufacturers label datapoints differently.
|
|
1217
|
-
if (
|
|
1220
|
+
if (mira) {
|
|
1221
|
+
for (const def of buildMiraAliases(this, mira)) addStandardSource(def);
|
|
1222
|
+
} else if (cat === 'HEAT') {
|
|
1218
1223
|
const asNumber = (v) => {
|
|
1219
1224
|
if (typeof v === 'number' && Number.isFinite(v)) return v;
|
|
1220
1225
|
if (typeof v === 'string') {
|
|
@@ -6664,6 +6669,10 @@ class DeviceRuntime {
|
|
|
6664
6669
|
const proto = this.cfg.protocol;
|
|
6665
6670
|
// Load a transport only when a configured device selects it. CommonJS reuses
|
|
6666
6671
|
// its module on later starts, while every device still gets its own driver.
|
|
6672
|
+
if (this.template?.driverHints?.ovumMira) {
|
|
6673
|
+
const { OvumMiraDriver } = require('./drivers/ovumMira');
|
|
6674
|
+
return new OvumMiraDriver(this.adapter, this.cfg, this.template, this.global);
|
|
6675
|
+
}
|
|
6667
6676
|
if (getDeyeProfile(this.template)) {
|
|
6668
6677
|
const { DeyeModbusDriver } = require('./drivers/deyeModbus');
|
|
6669
6678
|
return new DeyeModbusDriver(this.adapter, this.cfg, this.template, this.global);
|
|
@@ -7989,6 +7998,7 @@ class DeviceRuntime {
|
|
|
7989
7998
|
// to appear dead for the cooldown window.
|
|
7990
7999
|
const toDev = (typeof aliasDef.toDevice === 'function') ? aliasDef.toDevice(state.val) : state.val;
|
|
7991
8000
|
if (toDev === undefined || toDev === null) {
|
|
8001
|
+
if (miraUnit(this.template)) throw new Error('MIRA: Ungültiger EMS-Stellwert.');
|
|
7992
8002
|
// Command-button aliases can intentionally ignore the inactive/false edge
|
|
7993
8003
|
// (e.g. KEBA P40 fast charging can only be activated, not deactivated, via Modbus).
|
|
7994
8004
|
await this._setStateCached(relId, state.val, true);
|
|
@@ -8020,7 +8030,7 @@ class DeviceRuntime {
|
|
|
8020
8030
|
// For sensitive devices (e.g. SolaX), coalesce/throttle writes instead of sending them immediately.
|
|
8021
8031
|
// VARTA and FENECON Home have no keepalive requiring an optimistic
|
|
8022
8032
|
// command. Rejected writes must not later be acknowledged from polling.
|
|
8023
|
-
if (!getVartaProfile(this.template) && !this._isFeneconHomeEssTemplate()) this._rememberCommandedValue(aliasTargetDp.id, toDev);
|
|
8033
|
+
if (!miraUnit(this.template) && !getVartaProfile(this.template) && !this._isFeneconHomeEssTemplate()) this._rememberCommandedValue(aliasTargetDp.id, toDev);
|
|
8024
8034
|
|
|
8025
8035
|
if (this._isWriteQueueEnabled()) {
|
|
8026
8036
|
this._enqueueWrite(relId, aliasTargetDp, toDev, state.val, { bypassUnsupportedCooldown: true, isUserCommand: true });
|
|
@@ -8092,7 +8102,7 @@ class DeviceRuntime {
|
|
|
8092
8102
|
if (getVartaProfile(this.template) && await this._rejectUnavailableVartaWrite()) return;
|
|
8093
8103
|
// Direct user/script writes must not be suppressed by a previous automatic
|
|
8094
8104
|
// keepalive rejection. Let the actual device response decide.
|
|
8095
|
-
if (!getVartaProfile(this.template) && !this._isFeneconHomeEssTemplate()) this._rememberCommandedValue(dp.id, state.val);
|
|
8105
|
+
if (!miraUnit(this.template) && !getVartaProfile(this.template) && !this._isFeneconHomeEssTemplate()) this._rememberCommandedValue(dp.id, state.val);
|
|
8096
8106
|
|
|
8097
8107
|
// For sensitive devices (e.g. SolaX), coalesce/throttle writes instead of sending them immediately.
|
|
8098
8108
|
if (this._isWriteQueueEnabled()) {
|
|
@@ -33,7 +33,7 @@ function _errMsg(err) {
|
|
|
33
33
|
// They must abort the whole snapshot without marking valid optional registers
|
|
34
34
|
// unsupported for the subsequent permitted poll.
|
|
35
35
|
function isReadOperationBoundaryError(err) {
|
|
36
|
-
return ['EOS_DEVICES_NOT_AUTHORIZED', 'EOS_DEVICES_STOPPED', 'EOS_MODULE_STOPPED', 'EOS_OWNERSHIP_REQUIRED', 'E_MODBUS_CONNECT_CANCELLED']
|
|
36
|
+
return ['EOS_DEVICES_NOT_AUTHORIZED', 'EOS_DEVICES_STOPPED', 'EOS_MODULE_STOPPED', 'EOS_OWNERSHIP_REQUIRED', 'E_MODBUS_CONNECT_CANCELLED', 'EOS_MIRA_LOGIN']
|
|
37
37
|
.includes(_errCode(err) || _errMsg(err));
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -125,12 +125,18 @@ class ModbusRtuBus {
|
|
|
125
125
|
return await fn(this.client);
|
|
126
126
|
} catch (e) {
|
|
127
127
|
// Mark as disconnected so next operation tries to reconnect
|
|
128
|
-
this.connected = false;
|
|
128
|
+
if (!['EOS_MIRA_LOGIN', 'EOS_MIRA_READBACK', 'EOS_DEVICES_NOT_AUTHORIZED', 'E_MODBUS_CONNECT_CANCELLED'].includes(e?.code)) this.connected = false;
|
|
129
129
|
throw e;
|
|
130
130
|
}
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
// Keep dependent requests (login, command and readback) on the same Unit-ID
|
|
135
|
+
// and physical port reservation even when other units share this bus.
|
|
136
|
+
withUnitClient(unitId, timeoutMs, operation) {
|
|
137
|
+
return this._exec(unitId, timeoutMs, operation);
|
|
138
|
+
}
|
|
139
|
+
|
|
134
140
|
// Read helpers
|
|
135
141
|
readCoils(unitId, timeoutMs, addr, len) {
|
|
136
142
|
return this._exec(unitId, timeoutMs, (c) => c.readCoils(addr, len));
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { ModbusDriver } = require('./modbus');
|
|
4
|
+
const { assertOperationAllowed } = require('../operationContext');
|
|
5
|
+
|
|
6
|
+
// OVUM MIRA 1.1.3 START, physical 0-based holding-register addresses.
|
|
7
|
+
// Only volatile EMS inputs are writable. P_ configuration words persist to flash.
|
|
8
|
+
const { miraConnection, rejectLogin, S32_MIN, S32_MAX } = require('../ovumMiraConnection');
|
|
9
|
+
const INPUTS = Object.freeze({
|
|
10
|
+
'control.pvStatus': [55070, 1, 0, 2],
|
|
11
|
+
'control.batterySocPct': [55071, 1, 0, 100],
|
|
12
|
+
'control.gridPowerW': [55072, 2, S32_MIN, S32_MAX],
|
|
13
|
+
'control.inverterPowerW': [55074, 2, S32_MIN, S32_MAX],
|
|
14
|
+
'control.pvPowerTargetW': [55076, 2, 0, S32_MAX],
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
function exactWords(response, length) {
|
|
18
|
+
const words = response?.data;
|
|
19
|
+
if (!Array.isArray(words) || words.length !== length ||
|
|
20
|
+
!words.every(w => Number.isInteger(w) && w >= 0 && w <= 0xffff)) {
|
|
21
|
+
throw new Error('MIRA: Unvollständige Modbus-Rückmeldung.');
|
|
22
|
+
}
|
|
23
|
+
return words;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
class OvumMiraDriver extends ModbusDriver {
|
|
27
|
+
constructor(adapter, cfg, template, global) {
|
|
28
|
+
super(adapter, cfg, template, global);
|
|
29
|
+
const role = template.driverHints.ovumMira.module;
|
|
30
|
+
const { unitId, code } = miraConnection(role, cfg.protocol, cfg.connection);
|
|
31
|
+
this.unitId = this.manualUnitId = unitId;
|
|
32
|
+
this.manualAddressOffset = this.autoAddressOffset = 0;
|
|
33
|
+
this._disableAddressFallbackOffsets = true;
|
|
34
|
+
this.wordOrder = this.byteOrder = 'be';
|
|
35
|
+
this.strictContiguousReads = true;
|
|
36
|
+
this.loginCode = code;
|
|
37
|
+
this.needStatus = true;
|
|
38
|
+
this.sessionClient = null;
|
|
39
|
+
this.loginRetryAt = 0;
|
|
40
|
+
this.epoch = 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
_markDisconnected(error) {
|
|
44
|
+
this.epoch++;
|
|
45
|
+
this.sessionClient = null;
|
|
46
|
+
super._markDisconnected(error);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async disconnect() {
|
|
50
|
+
this.epoch++;
|
|
51
|
+
this.sessionClient = null;
|
|
52
|
+
return super.disconnect();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async readDatapoints(points) {
|
|
56
|
+
if (!this._busy) this.needStatus = true;
|
|
57
|
+
const values = await super.readDatapoints(points);
|
|
58
|
+
for (const key of Object.keys(values)) {
|
|
59
|
+
if (typeof values[key] === 'number' && !Number.isFinite(values[key])) values[key] = null;
|
|
60
|
+
}
|
|
61
|
+
return values;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async _checkLogin(client, current, firstAccess) {
|
|
65
|
+
const status = async () => {
|
|
66
|
+
current();
|
|
67
|
+
const words = (await client.readHoldingRegisters(100, 1))?.data;
|
|
68
|
+
if (!Array.isArray(words) || words.length !== 1 || ![0, 1].includes(words[0])) {
|
|
69
|
+
throw rejectLogin('MIRA: Ungültige Login-Status-Antwort.');
|
|
70
|
+
}
|
|
71
|
+
return words[0];
|
|
72
|
+
};
|
|
73
|
+
if (!(firstAccess && this.loginCode) && await status() === 1) return;
|
|
74
|
+
if (!this.loginCode) throw rejectLogin('MIRA: Anmeldung erforderlich. Modbus-Login-Code in der Geräteverbindung prüfen.');
|
|
75
|
+
if (Date.now() < this.loginRetryAt) throw rejectLogin('MIRA: Letzte Anmeldung abgewiesen. Modbus-Login-Code prüfen.');
|
|
76
|
+
current();
|
|
77
|
+
try {
|
|
78
|
+
await client.writeRegisters(101, this.loginCode.slice());
|
|
79
|
+
} catch (error) {
|
|
80
|
+
// Never propagate a library exception that may contain a request dump.
|
|
81
|
+
const safe = new Error('MIRA: Übertragung der Anmeldung fehlgeschlagen.');
|
|
82
|
+
if (['ETIMEDOUT', 'ECONNRESET', 'EPIPE', 'ERR_SOCKET_CLOSED'].includes(error?.code)) safe.code = error.code;
|
|
83
|
+
throw safe;
|
|
84
|
+
}
|
|
85
|
+
if (await status() !== 1) {
|
|
86
|
+
this.loginRetryAt = Date.now() + 60000;
|
|
87
|
+
throw rejectLogin('MIRA: Anmeldung nicht bestätigt. Modbus-Login-Code in der Geräteverbindung prüfen.');
|
|
88
|
+
}
|
|
89
|
+
this.loginRetryAt = 0;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async _transaction(verify, action) {
|
|
93
|
+
const epoch = this.epoch;
|
|
94
|
+
const current = () => {
|
|
95
|
+
assertOperationAllowed();
|
|
96
|
+
if (this.epoch !== epoch || !this.connected) {
|
|
97
|
+
throw Object.assign(new Error('MIRA: Verbindung wurde beendet.'), { code: 'E_MODBUS_CONNECT_CANCELLED' });
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
return this._withIoLock(async () => {
|
|
101
|
+
current();
|
|
102
|
+
const run = async client => {
|
|
103
|
+
current();
|
|
104
|
+
const firstAccess = this.sessionClient !== client;
|
|
105
|
+
if (firstAccess || verify || this.needStatus) {
|
|
106
|
+
await this._checkLogin(client, current, firstAccess);
|
|
107
|
+
current();
|
|
108
|
+
this.sessionClient = client;
|
|
109
|
+
this.needStatus = false;
|
|
110
|
+
}
|
|
111
|
+
return action(client, current);
|
|
112
|
+
};
|
|
113
|
+
if (this.protocol === 'modbusRtu') return this.rtuBus.withUnitClient(this.unitId, this.timeoutMs, run);
|
|
114
|
+
this._setTcpRequestUnitId(this.unitId);
|
|
115
|
+
return run(this.client);
|
|
116
|
+
}, 'MIRA Modbus');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
_mbReadHoldingRegisters(address, length, unitId) {
|
|
120
|
+
if (this._operationUnitId(unitId) !== this.unitId) throw new Error('MIRA: Fremde Unit-ID.');
|
|
121
|
+
// Addresses 101/102 hold the login code and are never measurement words.
|
|
122
|
+
if (address < 103 && address + length > 101) throw new Error('MIRA: Anmelderegister ist kein Messpunkt.');
|
|
123
|
+
return this._transaction(false, client => client.readHoldingRegisters(address, length));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async writeDatapoint(dp, value) {
|
|
127
|
+
const spec = Object.hasOwn(INPUTS, dp?.id) ? INPUTS[dp.id] : null;
|
|
128
|
+
if (this.unitId !== 110 || !spec || dp.rw !== 'rw') throw new Error('MIRA: Schreibzugriff für diesen Datenpunkt gesperrt.');
|
|
129
|
+
const [address, length, min, max] = spec;
|
|
130
|
+
const n = typeof value === 'string' && /^-?\d+$/.test(value.trim()) ? Number(value) : value;
|
|
131
|
+
if (!Number.isInteger(n) || n < min || n > max) throw new Error('MIRA: Ungültiger EMS-Stellwert.');
|
|
132
|
+
const words = length === 1 ? [n] : [n >>> 16, n & 0xffff];
|
|
133
|
+
await this.ensureConnected();
|
|
134
|
+
await this._transaction(true, async (client, current) => {
|
|
135
|
+
current();
|
|
136
|
+
if (length === 1) await client.writeRegister(address, words[0]);
|
|
137
|
+
else await client.writeRegisters(address, words);
|
|
138
|
+
current();
|
|
139
|
+
const actual = exactWords(await client.readHoldingRegisters(address, length), length);
|
|
140
|
+
current();
|
|
141
|
+
if (!actual.every((word, i) => word === words[i])) {
|
|
142
|
+
throw Object.assign(new Error('MIRA: Sollwert vom Gerät nicht bestätigt.'), { code: 'EOS_MIRA_READBACK' });
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
return { effectiveValue: n };
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
module.exports = { OvumMiraDriver };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// These are different physical units. A hydraulic EMS target or thermal output
|
|
4
|
+
// cannot substitute for the WPM's electrical consumption in the energy flow.
|
|
5
|
+
const units = {
|
|
6
|
+
'heat.ovum.mira.hsm': 'hsm',
|
|
7
|
+
'heat.ovum.mira.wpm': 'wpm',
|
|
8
|
+
};
|
|
9
|
+
const hsmBindings = [
|
|
10
|
+
['r.pvStatus', 'control.pvStatus', 55070, 'int16'],
|
|
11
|
+
['ctrl.pvStatus', 'control.pvStatus', 55070, 'int16'],
|
|
12
|
+
['r.pvPowerTargetW', 'control.pvPowerTargetW', 55076, 'int32', 'W'],
|
|
13
|
+
['ctrl.pvPowerTargetW', 'control.pvPowerTargetW', 55076, 'int32', 'W'],
|
|
14
|
+
['r.ambientTemp', 'ambient.actualAmbientTemp', 56048, 'float32', '°C'],
|
|
15
|
+
['r.roomTemp', 'hc.roomTemp', 56152, 'float32', '°C'],
|
|
16
|
+
['r.bufferTemp', 'buffer.lowerTemperature', 55028, 'float32', '°C'],
|
|
17
|
+
];
|
|
18
|
+
const wpmBindings = [
|
|
19
|
+
['r.power', 'measurement.electricalPowerW', 56021, 'float32', 'W'],
|
|
20
|
+
['r.statusCode', 'status.operatingState', 56025, 'int16'],
|
|
21
|
+
['r.returnTemp', 'measurement.waterInletTemperature', 56026, 'float32', '°C'],
|
|
22
|
+
['r.flowTemp', 'measurement.waterOutletTemperature', 56028, 'float32', '°C'],
|
|
23
|
+
];
|
|
24
|
+
const freshPaths = new Set(['r.power', 'r.pvStatus', 'r.pvPowerTargetW', 'comm.connected', 'alarm.offline']);
|
|
25
|
+
|
|
26
|
+
function miraUnit(template) {
|
|
27
|
+
const unit = units[template?.id];
|
|
28
|
+
return unit && unit === template.driverHints?.ovumMira?.module ? unit : undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function buildMiraAliases(runtime, unit) {
|
|
32
|
+
const definitions = [];
|
|
33
|
+
for (const [path, dpId, address, dataType, unitName] of unit === 'hsm' ? hsmBindings : wpmBindings) {
|
|
34
|
+
const dp = runtime._getDpById(dpId);
|
|
35
|
+
const src = dp?.source;
|
|
36
|
+
const read = src?.read;
|
|
37
|
+
const write = path.startsWith('ctrl.');
|
|
38
|
+
const words = dataType === 'int16' ? 1 : 2;
|
|
39
|
+
if (dp?.type !== 'number' || dp.unit !== unitName || dp.rw === 'wo' || src?.kind !== 'modbus' ||
|
|
40
|
+
read?.fc !== 3 || read.address !== address || read.dataType !== dataType || read.length !== words ||
|
|
41
|
+
read.wordOrder !== 'be' || read.byteOrder !== 'be' || (src.scaleFactor ?? 0) !== (path === 'r.power' ? 3 : 0)) continue;
|
|
42
|
+
const target = src.write;
|
|
43
|
+
if (write && (dp.rw !== 'rw' || target?.address !== address || target.fc !== (words === 1 ? 6 : 16) ||
|
|
44
|
+
target.length !== words || target.dataType !== dataType || target.wordOrder !== 'be' || target.byteOrder !== 'be')) continue;
|
|
45
|
+
|
|
46
|
+
const definition = {
|
|
47
|
+
relId: runtime._aliasRelId(path), name: dp.name, type: 'number',
|
|
48
|
+
role: dp.role, rw: write ? 'rw' : 'ro', kind: 'dp', dpId,
|
|
49
|
+
};
|
|
50
|
+
if (unitName) definition.unit = unitName;
|
|
51
|
+
if (write) definition.writeDpId = dpId;
|
|
52
|
+
else {
|
|
53
|
+
definition.deviceReadOnly = true;
|
|
54
|
+
definition.fromDevice = value => typeof value === 'number' && Number.isFinite(value) ? value : null;
|
|
55
|
+
}
|
|
56
|
+
definitions.push(definition);
|
|
57
|
+
}
|
|
58
|
+
return definitions;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = { miraUnit, buildMiraAliases, freshPaths };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const S32_MIN = -0x80000000;
|
|
4
|
+
const S32_MAX = 0x7fffffff;
|
|
5
|
+
function rejectLogin(reason) {
|
|
6
|
+
return Object.assign(new Error(reason), { code: 'EOS_MIRA_LOGIN' });
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function loginWords(value) {
|
|
10
|
+
if (value === undefined || value === null || value === '') return null;
|
|
11
|
+
if (typeof value !== 'number' && typeof value !== 'string') throw rejectLogin('MIRA: Ungültiger Login-Code.');
|
|
12
|
+
const text = String(value).trim();
|
|
13
|
+
const hex = /^0x[0-9a-f]{1,8}$/i.test(text);
|
|
14
|
+
if (!hex && !/^-?\d+$/.test(text)) throw rejectLogin('MIRA: Login-Code ist keine 32-Bit-Ganzzahl.');
|
|
15
|
+
const n = Number(text);
|
|
16
|
+
if (!Number.isInteger(n) || n < S32_MIN || n > (hex ? 0xffffffff : S32_MAX)) {
|
|
17
|
+
throw rejectLogin('MIRA: Login-Code ist außerhalb des 32-Bit-Bereichs.');
|
|
18
|
+
}
|
|
19
|
+
return [n >>> 16, n & 0xffff];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function miraConnection(role, protocol, connection) {
|
|
23
|
+
const raw = connection?.unitId;
|
|
24
|
+
const unitId = raw === undefined || raw === null || raw === '' ? (role === 'hsm' ? 110 : 111) :
|
|
25
|
+
typeof raw === 'number' || (typeof raw === 'string' && /^\d+$/.test(raw)) ? Number(raw) : NaN;
|
|
26
|
+
if (!['modbusTcp', 'modbusRtu'].includes(protocol) ||
|
|
27
|
+
!(role === 'hsm' && unitId === 110 || role === 'wpm' && Number.isInteger(unitId) && unitId >= 111 && unitId <= 118)) {
|
|
28
|
+
throw Object.assign(new Error('MIRA: Protokoll oder Unit-ID passt nicht zum Modul (HSM 110, WPM 111–118).'), { code: 'EOS_MIRA_CONNECTION' });
|
|
29
|
+
}
|
|
30
|
+
return { unitId, code: loginWords(connection?.writePassword) };
|
|
31
|
+
}
|
|
32
|
+
module.exports = { miraConnection, rejectLogin, S32_MIN, S32_MAX };
|