iobroker.eos-admin 9.0.34 → 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 -10
- package/README.md +10 -4
- package/adminWww/.vite/manifest.json +39 -39
- package/adminWww/NEXOWATT_EOS_FRONTEND_MANIFEST.json +107 -107
- package/adminWww/assets/{AdapterUpdateDialog-5L75o18m.js → AdapterUpdateDialog-DH6S-kWX.js} +1 -1
- package/adminWww/assets/{Adapters-FcghjF7E.js → Adapters-CIlqSF5B.js} +1 -1
- package/adminWww/assets/{ConfigManager-BnHarBfH.js → ConfigManager-BhVBfM-q.js} +1 -1
- package/adminWww/assets/{Enums-BjLbLLQL.js → Enums-3H97czGs.js} +1 -1
- package/adminWww/assets/{Fields-DDE1hVOa.js → Fields-vWLKiuvO.js} +1 -1
- package/adminWww/assets/{Files-CDjnR4q6.js → Files-wmjjMXYM.js} +1 -1
- package/adminWww/assets/{Hosts-CJKQaNrD.js → Hosts-Bk-xmI98.js} +1 -1
- package/adminWww/assets/{Instances-DZNl369k.js → Instances-Db6Vgh62.js} +1 -1
- package/adminWww/assets/{Intro-CjAmMGDB.js → Intro-Dc3wAG9V.js} +1 -1
- package/adminWww/assets/{Logs-rUAV7SwM.js → Logs-CPbEGWNq.js} +1 -1
- package/adminWww/assets/{Objects-CqOH6rT_.js → Objects-DJB-2468.js} +1 -1
- package/adminWww/assets/{Overview-BOtXqsMy.js → Overview-DdvghCLQ.js} +1 -1
- package/adminWww/assets/{State-C8ncThop.js → State-0UzpgKYj.js} +1 -1
- package/adminWww/assets/{UsedResources-lUYJqy4F.js → UsedResources-Bcmo58YD.js} +1 -1
- package/adminWww/assets/{Users-CK1Cax82.js → Users-BGHf3Rox.js} +1 -1
- package/adminWww/assets/{bootstrap-CC0Qr-kr.js → bootstrap-qkrk_CAn.js} +3 -3
- package/adminWww/assets/{hostInit-DqGL6nY8.js → hostInit-DlGqatlv.js} +1 -1
- package/adminWww/assets/{icons-material-07rWS63O.js → icons-material-CUNq6tdT.js} +1 -1
- package/adminWww/assets/{index-BhhkToP2.js → index-BrtKq3UN.js} +2 -2
- package/adminWww/assets/{installSVGRenderer-B4-7lSQZ.js → installSVGRenderer-DujLjpXt.js} +1 -1
- package/adminWww/assets/{mf-entry-bootstrap-0-1afd2287.js → mf-entry-bootstrap-0-3e1cd85c.js} +2 -2
- 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.35.js +12 -0
- package/adminWww/remoteEntry.js +1 -1
- package/build/lib/eosDashboardProcessStatus.js +191 -0
- package/build/lib/eosDashboardProcessStatus.js.map +1 -0
- 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 +1 -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.35.md +27 -0
- package/io-package.json +8 -8
- package/modules/devices/contracts.d.ts +1 -0
- package/modules/devices/index.js +20 -1
- package/modules/devices/lib/deviceRuntime.js +19 -0
- package/modules/devices/lib/drivers/modbus.js +11 -6
- package/modules/devices/lib/drivers/ovumMira.js +7 -3
- package/modules/devices/test/ovumMiraTransport.test.js +40 -1
- 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 +7 -5
- package/release-manifests/unified/build-environment.cdx.json +6 -6
- package/release-manifests/unified/files.json +220 -140
- 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 +30 -30
- package/release-manifests/unified/validation.json +15 -15
- package/tools/eos-release-manifest.cjs +1 -1
- package/ui/io-package.json +5 -1
- package/ui/lib/notification-mail.js +235 -40
- package/ui/lib/notification-policy.js +41 -14
- package/ui/package.json +2 -1
- package/ui/www/app.js +91 -11
- package/ui/www/dashboard-lp-status.js +4 -11
- package/ui/www/dashboard-process-status.js +202 -0
- 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/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/remoteEntry-eos-9.0.34.js +0 -12
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* AUTO-GENERATED RUNTIME FILE - NICHT MANUELL BEARBEITEN.
|
|
8
8
|
*
|
|
9
9
|
* Quelle: src-ts/runtime-executables/lib/notification-mail.ts
|
|
10
|
-
* Quell-Hash: sha256:
|
|
10
|
+
* Quell-Hash: sha256:289e8a310154f01dcdada49e2e11b9a9ddfb27b89c9240af64afcb2eece56795
|
|
11
11
|
* Erzeugung: npm run sync:ts-runtime-executables
|
|
12
12
|
*
|
|
13
13
|
* Zweck:
|
|
@@ -35,10 +35,67 @@ const crypto = require('node:crypto');
|
|
|
35
35
|
const { NotificationPolicy } = require('./notification-policy');
|
|
36
36
|
const FROM = 'info@nexowatt.com';
|
|
37
37
|
const ADDRESS = /^[^\s<>@,;\r\n]+@[^\s<>@,;\r\n]+\.[^\s<>@,;\r\n]+$/;
|
|
38
|
+
const CATEGORY_FLAGS = {system:'notifySystem', inverters:'notifyInverters', charging:'notifyCharging', communications:'notifyCommunication', grid:'notifyHardCurtailment'};
|
|
38
39
|
const validAddress = v => typeof v === 'string' && v.length <= 254 && ADDRESS.test(v);
|
|
39
40
|
const safeId = v => String(v || '').toLowerCase().replace(/[^a-z0-9_]+/g, '_').replace(/^_+|_+$/g, '').slice(0, 64);
|
|
40
41
|
const MODULES = new Set(['coreLimits', 'peakShaving', 'chargingManagement', 'storage', 'storageControl', 'storageFarm', 'gridConstraints', 'para14a', 'netOperatorInterface', 'heatingRod', 'heatingRodControl', 'consumerManagement', 'speicherMapping', 'speicherRegelung', 'multiUse', 'thermalControl', 'meshMicrogrid', 'nvpCoordinator', 'bhkwControl', 'generatorControl', 'thresholdControl', 'nexoLogicBudget']);
|
|
41
42
|
|
|
43
|
+
// Match native datapoint roots (including migrated namespaces) to the same hash used by
|
|
44
|
+
// the worker's confirmed reachability. Never merge records on a human-readable name.
|
|
45
|
+
function supervisedId(namespaces, refs) {
|
|
46
|
+
const found = new Set();
|
|
47
|
+
for (const value of refs) {
|
|
48
|
+
const ref = typeof value === 'string' ? value : value?.root;
|
|
49
|
+
if (typeof ref !== 'string') continue;
|
|
50
|
+
for (const kind of ['devices','ocpp']) {
|
|
51
|
+
if (!namespaces?.[kind]) continue;
|
|
52
|
+
const prefix = namespaces[kind] + (kind === 'devices' ? '.devices.' : '.');
|
|
53
|
+
if (!ref.startsWith(prefix)) continue;
|
|
54
|
+
const suffix = ref.slice(prefix.length);
|
|
55
|
+
let unit;
|
|
56
|
+
if (kind === 'devices') {
|
|
57
|
+
// Device IDs may contain periods. An explicit root is exact. Only a known
|
|
58
|
+
// producer channel can delimit a device in a telemetry datapoint reference.
|
|
59
|
+
unit = typeof value === 'object' ? suffix : /^(.*?)\.(?:aliases|info|measurement)\./.exec(suffix)?.[1];
|
|
60
|
+
} else if (typeof value === 'object' && value.raw && /^[A-Za-z0-9_-]+$/.test(suffix)) {
|
|
61
|
+
// Raw OCPP identities can be sanitized or suffixed differently in the object tree.
|
|
62
|
+
unit = value.raw;
|
|
63
|
+
}
|
|
64
|
+
if (!unit || unit.length > 256) continue;
|
|
65
|
+
found.add('supervisor:device:' + kind + ':' + crypto.createHash('sha256').update(unit).digest('hex'));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return found.size === 1 ? [...found][0] : '';
|
|
69
|
+
}
|
|
70
|
+
function wallboxRefs(row) {
|
|
71
|
+
return [{root:row._eosDevice?.baseId},row.onlineId,row.statusId,row.powerId];
|
|
72
|
+
}
|
|
73
|
+
async function ocppRootRef(row, namespace, reader) {
|
|
74
|
+
const prefix = namespace ? namespace + '.' : '';
|
|
75
|
+
if (!prefix || !reader) return null;
|
|
76
|
+
const root = [row.ocppDiscovery?.stationRoot,row.onlineId,row.statusId,row.powerId].find(value =>
|
|
77
|
+
typeof value === 'string' && value.startsWith(prefix));
|
|
78
|
+
if (!root) return null;
|
|
79
|
+
const unit = root.slice(prefix.length).split('.')[0];
|
|
80
|
+
if (!/^[A-Za-z0-9_-]+$/.test(unit)) return null;
|
|
81
|
+
const station = prefix + unit;
|
|
82
|
+
const identity = await reader(station + '.info.identity');
|
|
83
|
+
return typeof identity?.val === 'string' && identity.ack !== false && (!identity.q || identity.q === 0)
|
|
84
|
+
? {root:station,raw:identity.val} : null;
|
|
85
|
+
}
|
|
86
|
+
function migrateIncident(records, oldId, newId) {
|
|
87
|
+
const previous = records.get(oldId);
|
|
88
|
+
if (!previous || oldId === newId) return;
|
|
89
|
+
const existing = records.get(newId);
|
|
90
|
+
if (existing) {
|
|
91
|
+
existing.lastSent = Math.max(existing.lastSent || 0, previous.lastSent || 0);
|
|
92
|
+
existing.alertSent ||= previous.alertSent;
|
|
93
|
+
existing.criticalSent ||= previous.criticalSent || Boolean(previous.active && previous.alertSent);
|
|
94
|
+
} else {
|
|
95
|
+
records.set(newId, {...previous, criticalSent:previous.criticalSent || Boolean(previous.active && previous.alertSent), suppressed:true, meta:{...previous.meta, id:newId}});
|
|
96
|
+
}
|
|
97
|
+
records.delete(oldId);
|
|
98
|
+
}
|
|
42
99
|
/**
|
|
43
100
|
* Ablauf und Zusammenhang: Prüft Server, Port, Benutzer und Passwort vor dem Speichern. Ein leeres Passwortfeld übernimmt das bisherige Passwort; nur clearPassword löscht es ausdrücklich. Aktivierung ohne vollständige Zugangsdaten wird abgewiesen.
|
|
44
101
|
*/
|
|
@@ -98,17 +155,61 @@ class NotificationMail {
|
|
|
98
155
|
const secret = system?.native?.secret;
|
|
99
156
|
if (!secret || typeof secret !== 'string') throw new Error('Systemschlüssel für geschützten Mailversand fehlt.');
|
|
100
157
|
this.key = crypto.createHash('sha256').update(`${secret}:nexowatt-mail:${this.adapter.namespace}`).digest();
|
|
101
|
-
|
|
102
|
-
|
|
158
|
+
await this.reloadSmtp();
|
|
159
|
+
await this.reloadLedger();
|
|
160
|
+
}
|
|
161
|
+
async reloadSmtp() {
|
|
162
|
+
let encrypted;
|
|
163
|
+
try { encrypted = await fs.readFile(path.join(this.directory, 'notification-mail.json'), 'utf8'); }
|
|
164
|
+
catch (error) { if (error.code !== 'ENOENT') throw error; encrypted = ''; }
|
|
165
|
+
if (encrypted === this.lastEncrypted) return;
|
|
166
|
+
this.transport?.close(); this.transport = null;
|
|
167
|
+
this.config = normalizeConfig();
|
|
168
|
+
this.lastEncrypted = undefined;
|
|
169
|
+
if (encrypted) {
|
|
170
|
+
const stored = JSON.parse(encrypted);
|
|
103
171
|
const decipher = crypto.createDecipheriv('aes-256-gcm', this.key, Buffer.from(stored.iv, 'hex'));
|
|
104
172
|
decipher.setAuthTag(Buffer.from(stored.tag, 'hex'));
|
|
105
173
|
const plain = Buffer.concat([decipher.update(Buffer.from(stored.data, 'hex')), decipher.final()]);
|
|
106
174
|
this.config = normalizeConfig(JSON.parse(plain.toString('utf8')));
|
|
107
|
-
} catch (error) {
|
|
108
|
-
if (error.code !== 'ENOENT') throw new Error('Gespeicherte SMTP-Konfiguration ist nicht lesbar. Systemschlüssel oder Sicherung prüfen.');
|
|
109
175
|
}
|
|
110
|
-
|
|
111
|
-
|
|
176
|
+
this.lastEncrypted = encrypted;
|
|
177
|
+
}
|
|
178
|
+
async reloadLedger() {
|
|
179
|
+
let saved = '';
|
|
180
|
+
try { saved = await fs.readFile(path.join(this.directory, 'notification-ledger.json'), 'utf8'); }
|
|
181
|
+
catch (error) { if (error.code !== 'ENOENT') throw error; }
|
|
182
|
+
if (saved === this.loadedLedger && this.loadedLedger !== undefined) return;
|
|
183
|
+
try { this.policy = new NotificationPolicy(saved ? JSON.parse(saved) : {}); }
|
|
184
|
+
catch { this.policy = new NotificationPolicy(); this.policy.nextAttempt = this.now() + 3600000; }
|
|
185
|
+
this.loadedLedger = saved; this.lastSnapshot = saved;
|
|
186
|
+
}
|
|
187
|
+
// SQLite provides only the kernel-managed, crash-released process lock. All persisted delivery
|
|
188
|
+
// history stays in the existing JSON ledger. Zero busy timeout keeps both event loops responsive.
|
|
189
|
+
async withDeliveryLock(operation) {
|
|
190
|
+
const { DatabaseSync } = require('node:sqlite');
|
|
191
|
+
const db = new DatabaseSync(path.join(this.directory, 'notification-gate.sqlite'));
|
|
192
|
+
try {
|
|
193
|
+
db.exec('PRAGMA busy_timeout=0');
|
|
194
|
+
try { db.exec('BEGIN IMMEDIATE'); }
|
|
195
|
+
catch (error) { if (error.errcode === 5 || error.errcode === 6) return { ok: false, error: 'Ein Mailversand läuft bereits.' }; throw error; }
|
|
196
|
+
await this.reloadLedger();
|
|
197
|
+
await this.reloadSmtp();
|
|
198
|
+
if (this.closed) return { ok: false, error: 'Adapter wird beendet.' };
|
|
199
|
+
this.deliveryReports = new Map();
|
|
200
|
+
return await operation();
|
|
201
|
+
} finally {
|
|
202
|
+
db.close();
|
|
203
|
+
const reports = this.deliveryReports;
|
|
204
|
+
this.deliveryReports = null;
|
|
205
|
+
if (reports && this.options.authorized?.() !== false) await Promise.all([...reports].map(([key,value]) =>
|
|
206
|
+
Promise.resolve().then(() => this.adapter._notifySetDebugState(key,value)).catch(() => {})));
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
async report(key, value) {
|
|
210
|
+
if (this.options.authorized?.() === false) return;
|
|
211
|
+
if (this.deliveryReports) { this.deliveryReports.set(key,value); return; }
|
|
212
|
+
try { await this.adapter._notifySetDebugState(key,value); } catch { /* Diagnostics are best effort. */ }
|
|
112
213
|
}
|
|
113
214
|
/**
|
|
114
215
|
* Ablauf und Zusammenhang: Schreibt JSON in eine zufällige, exklusiv neu erstellte
|
|
@@ -125,6 +226,7 @@ class NotificationMail {
|
|
|
125
226
|
const handle = await fs.open(temporary, 'wx', 0o600); created = true;
|
|
126
227
|
try { await handle.writeFile(JSON.stringify(value)); await handle.sync(); }
|
|
127
228
|
finally { await handle.close(); }
|
|
229
|
+
if (this.options.authorized?.() === false) throw new Error('Berechtigung für diesen Instanzdatenbestand wurde zurückgegeben.');
|
|
128
230
|
await fs.rename(temporary, target); created = false;
|
|
129
231
|
if (process.platform !== 'win32') {
|
|
130
232
|
const directory = await fs.open(this.directory, 'r');
|
|
@@ -138,7 +240,7 @@ class NotificationMail {
|
|
|
138
240
|
async saveLedger() {
|
|
139
241
|
const data = this.policy.snapshot();
|
|
140
242
|
const json = JSON.stringify(data);
|
|
141
|
-
if (json !== this.lastSnapshot) { await this.atomic('notification-ledger.json', data); this.lastSnapshot = json; }
|
|
243
|
+
if (json !== this.lastSnapshot) { await this.atomic('notification-ledger.json', data); this.lastSnapshot = this.loadedLedger = json; }
|
|
142
244
|
}
|
|
143
245
|
/**
|
|
144
246
|
* Ablauf und Zusammenhang: Entfernt das Passwort aus der Konfigurationsantwort. Die Oberfläche bekommt nur passwordSet als Hinweis, ob ein Passwort vorhanden ist; der Passwortwert wird nicht zurückgegeben.
|
|
@@ -155,14 +257,20 @@ class NotificationMail {
|
|
|
155
257
|
if (this.busy) throw new Error('Mailversand läuft. Bitte kurz warten.');
|
|
156
258
|
this.busy = true;
|
|
157
259
|
try {
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
260
|
+
const result = await this.withDeliveryLock(async () => {
|
|
261
|
+
const config = normalizeConfig(input, this.config);
|
|
262
|
+
const iv = crypto.randomBytes(12);
|
|
263
|
+
const cipher = crypto.createCipheriv('aes-256-gcm', this.key, iv);
|
|
264
|
+
const data = Buffer.concat([cipher.update(JSON.stringify(config), 'utf8'), cipher.final()]);
|
|
265
|
+
const envelope = { iv: iv.toString('hex'), tag: cipher.getAuthTag().toString('hex'), data: data.toString('hex') };
|
|
266
|
+
await this.atomic('notification-mail.json', envelope);
|
|
267
|
+
this.lastEncrypted = JSON.stringify(envelope);
|
|
268
|
+
this.transport?.close(); this.transport = null;
|
|
269
|
+
this.config = config;
|
|
270
|
+
return this.publicConfig();
|
|
271
|
+
});
|
|
272
|
+
if (result?.ok === false) throw new Error(result.error);
|
|
273
|
+
return result;
|
|
166
274
|
} finally { this.busy = false; }
|
|
167
275
|
}
|
|
168
276
|
/**
|
|
@@ -171,7 +279,7 @@ class NotificationMail {
|
|
|
171
279
|
async status(message) {
|
|
172
280
|
if (this.lastStatus === message) return;
|
|
173
281
|
this.lastStatus = message;
|
|
174
|
-
await this.
|
|
282
|
+
await this.report('lastMailResult', message);
|
|
175
283
|
}
|
|
176
284
|
/**
|
|
177
285
|
* Ablauf und Zusammenhang: Sendet genau eine Nachricht mit verpflichtendem TLS und Zertifikatsprüfung. Erfolg bedeutet Annahme durch den SMTP-Server, nicht nachgewiesene Zustellung im Kundenpostfach; ungültige Empfänger und ausgeschalteter Versand werden abgewiesen.
|
|
@@ -204,13 +312,17 @@ class NotificationMail {
|
|
|
204
312
|
const now = this.now();
|
|
205
313
|
this.policy.reserve(now, test);
|
|
206
314
|
await this.saveLedger(); // A restart cannot turn repeated timeouts into an unbounded send loop.
|
|
315
|
+
if (this.options.authorized?.() === false || this.closed) return {ok:false,error:'Adapter wird beendet.'};
|
|
207
316
|
const result = await this.send(to, subject, text);
|
|
317
|
+
// An old standalone adapter may already own the legacy namespace by the time
|
|
318
|
+
// SMTP returns. It does not participate in this version's SQLite delivery lock.
|
|
319
|
+
if (this.options.authorized?.() === false) return result;
|
|
208
320
|
this.policy.complete(batch, this.now(), result.ok);
|
|
209
321
|
await this.saveLedger();
|
|
210
322
|
await this.status(result.ok ? 'smtp-accepted' : result.error);
|
|
211
323
|
if (result.ok) {
|
|
212
|
-
await this.
|
|
213
|
-
await this.
|
|
324
|
+
await this.report('lastMailTs', this.now());
|
|
325
|
+
await this.report('lastMailSubject', subject);
|
|
214
326
|
}
|
|
215
327
|
return result;
|
|
216
328
|
}
|
|
@@ -223,9 +335,11 @@ class NotificationMail {
|
|
|
223
335
|
try {
|
|
224
336
|
await this.init();
|
|
225
337
|
if (!validAddress(to)) return { ok: false, error: 'Bitte eine gültige Empfängeradresse speichern.' };
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
338
|
+
return await this.withDeliveryLock(async () => {
|
|
339
|
+
if (!this.config.enabled) return { ok: false, error: 'Mailversand im Installerbereich einrichten und aktivieren.' };
|
|
340
|
+
if (!this.policy.quota(this.now(), true)) return { ok: false, error: 'Versandpause aktiv. Testmails frühestens nach fünf Minuten wiederholen.' };
|
|
341
|
+
return await this.deliver(to, 'NexoWatt EOS: Test-Benachrichtigung', `${this.config.siteName || 'NexoWatt EOS'}\nDer direkte E-Mail-Versand wurde getestet.\nAbsender: ${FROM}`, [], true);
|
|
342
|
+
});
|
|
229
343
|
} catch (_error) { return { ok: false, error: 'Geschützte Versandkonfiguration oder Versandprotokoll nicht verfügbar.' }; }
|
|
230
344
|
finally { this.busy = false; }
|
|
231
345
|
}
|
|
@@ -240,26 +354,101 @@ class NotificationMail {
|
|
|
240
354
|
const a = this.adapter;
|
|
241
355
|
const enabled = a._notifyGetSettingBool('notifyEnabled', false);
|
|
242
356
|
const to = a._notifyGetSettingString('email', '');
|
|
243
|
-
|
|
357
|
+
const owns = id => this.options.supervision === true ? id.startsWith('supervisor:') : !id.startsWith('supervisor:');
|
|
358
|
+
if (!enabled) {
|
|
359
|
+
if (!this.disabledCleared) await this.withDeliveryLock(async () => {
|
|
360
|
+
for (const id of this.policy.records.keys()) if (owns(id)) this.policy.records.delete(id);
|
|
361
|
+
await this.saveLedger(); this.disabledCleared = true;
|
|
362
|
+
});
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
this.disabledCleared = false;
|
|
244
366
|
if (!validAddress(to)) { await this.status('Gültige Kunden-E-Mail-Adresse fehlt.'); return; }
|
|
367
|
+
await this.reloadSmtp();
|
|
245
368
|
if (!this.config.enabled) { await this.status('Mailversand im Installerbereich einrichten und aktivieren.'); return; }
|
|
246
369
|
if (this.now() - this.startedAt < 30000) return;
|
|
247
|
-
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
await this.
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
370
|
+
const categories = new Set(Object.keys(CATEGORY_FLAGS).filter(c => a._notifyGetSettingBool(CATEGORY_FLAGS[c], true)));
|
|
371
|
+
const recoveries = a._notifyGetSettingBool('notifyRecovery', true);
|
|
372
|
+
// No device reads while holding the delivery lock; a stopped collector cannot monopolize delivery.
|
|
373
|
+
await this.reloadLedger();
|
|
374
|
+
const observed = this.options.supervision ? await this.options.observations() : await this.collect(categories);
|
|
375
|
+
const legacyRefs = new Map();
|
|
376
|
+
if (this.options.supervision) {
|
|
377
|
+
const rows = observed?.chargingManagement?.wallboxes;
|
|
378
|
+
for (const row of (Array.isArray(rows) ? rows : []).slice(0,128)) {
|
|
379
|
+
const id = 'lp:' + row?.key + ':offline';
|
|
380
|
+
if (!row?.key || !this.policy.records.has(id)) continue;
|
|
381
|
+
legacyRefs.set(id,[...wallboxRefs(row),await ocppRootRef(row, observed.namespaces?.ocpp, a.getForeignStateAsync?.bind(a))]);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
const permission = () => !this.closed && this.options.authorized?.() !== false
|
|
385
|
+
&& a._notifyGetSettingBool('notifyEnabled', false) && a._notifyGetSettingString('email', '') === to;
|
|
386
|
+
// Re-read actual consent after potentially slow polling. A stale worker must never
|
|
387
|
+
// roll back a recipient change or clear another sender's ledger under the old address.
|
|
388
|
+
if (!permission()) return;
|
|
389
|
+
if (typeof a.getForeignStatesAsync === 'function') {
|
|
390
|
+
const prefix = a.namespace + '.settings.';
|
|
391
|
+
const keys = ['notifyEnabled','email','notifyRecovery',...Object.values(CATEGORY_FLAGS)];
|
|
392
|
+
const states = await a.getForeignStatesAsync(keys.map(key => prefix + key));
|
|
393
|
+
const current = (key, fallback) => {
|
|
394
|
+
const state = states?.[prefix+key];
|
|
395
|
+
if (!state) return fallback;
|
|
396
|
+
if (state.ack === false || (state.q !== undefined && state.q !== 0)) return undefined;
|
|
397
|
+
return state.val;
|
|
398
|
+
};
|
|
399
|
+
if (current('notifyEnabled') !== true || String(current('email') || '').trim() !== to
|
|
400
|
+
|| current('notifyRecovery',true) !== recoveries
|
|
401
|
+
|| Object.entries(CATEGORY_FLAGS).some(([key,flag]) => current(flag,true) !== categories.has(key))) return;
|
|
402
|
+
}
|
|
403
|
+
await this.withDeliveryLock(async () => {
|
|
404
|
+
if (!permission()) return;
|
|
405
|
+
this.policy.setRecipient(crypto.createHash('sha256').update(to.toLowerCase()).digest('hex'));
|
|
406
|
+
let events;
|
|
407
|
+
if (this.options.supervision) {
|
|
408
|
+
if (observed?.namespaces) this.policy.supervisedNamespaces = observed.namespaces;
|
|
409
|
+
events = this.options.events(observed, categories, this.policy.records);
|
|
410
|
+
const confirmed = new Set(events.filter(event => !event.hold).map(event => event.id));
|
|
411
|
+
for (const [id,rec] of this.policy.records) {
|
|
412
|
+
if (owns(id) || !categories.has(rec.meta?.category)) continue;
|
|
413
|
+
const refs = legacyRefs.get(id) || (id.startsWith('inverter:') ? [{root:id.slice(9)}] : []);
|
|
414
|
+
const canonical = rec.meta?.physicalId || supervisedId(this.policy.supervisedNamespaces, refs);
|
|
415
|
+
if (confirmed.has(canonical)) migrateIncident(this.policy.records, id, canonical);
|
|
416
|
+
}
|
|
417
|
+
} else {
|
|
418
|
+
events = [];
|
|
419
|
+
for (const event of observed) {
|
|
420
|
+
const refs = this.overlapRefs?.get(event.id) || [];
|
|
421
|
+
const canonical = supervisedId(this.policy.supervisedNamespaces, refs);
|
|
422
|
+
const primary = this.policy.records.get(canonical);
|
|
423
|
+
if (categories.has('communications') && canonical && primary?.active && !primary.suppressed) {
|
|
424
|
+
migrateIncident(this.policy.records, event.id, canonical);
|
|
425
|
+
} else {
|
|
426
|
+
events.push(canonical ? {...event,physicalId:canonical} : event);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
if (this.options.supervision && !this.hasObservation) {
|
|
431
|
+
for (const [id,record] of this.policy.records) if (owns(id) && !record.active) record.clearSince = 0;
|
|
432
|
+
this.hasObservation = true;
|
|
433
|
+
}
|
|
434
|
+
this.policy.observe(events, this.now(), categories, owns);
|
|
435
|
+
await this.saveLedger();
|
|
436
|
+
const active = [...this.policy.records.values()].filter(r => r.active && !r.suppressed);
|
|
437
|
+
await this.report('activeCount', active.length);
|
|
438
|
+
await this.report('activeJson', JSON.stringify(active.map(r => {
|
|
439
|
+
const id = r.meta.id.startsWith('supervisor:device:') ? r.meta.id.slice(0, r.meta.id.lastIndexOf(':')) : r.meta.id;
|
|
440
|
+
return {id,title:r.meta.title,severity:r.meta.severity};
|
|
441
|
+
})));
|
|
442
|
+
const batch = this.policy.batch(this.now(), recoveries, item => owns(item.id) && categories.has(item.category));
|
|
443
|
+
if (!batch.length) { await this.saveLedger(); return; }
|
|
444
|
+
const alarms = batch.filter(e => e.kind === 'alarm').length;
|
|
445
|
+
const subject = `NexoWatt EOS${this.config.siteName ? ' – ' + this.config.siteName : ''}: ${alarms} Störung(en), ${batch.length - alarms} Entwarnung(en)`;
|
|
446
|
+
const body = [`Anlage: ${this.config.siteName || a.namespace}`, `Zeit: ${new Date(this.now()).toISOString()}`, '',
|
|
447
|
+
...batch.flatMap(e => [`${e.kind === 'recovery' ? 'WIEDER OK' : (e.severity === 'critical' ? 'STÖRUNG' : (e.severity === 'info' ? 'HINWEIS' : 'WARNUNG'))}: ${e.title}`, e.kind === 'recovery' ? 'Die Störung besteht seit mindestens fünf Minuten nicht mehr.' : (e.resolved ? `${e.message} (Zwischenzeitlich nicht mehr aktiv; Meldung nachgeholt.)` : e.message), '']),
|
|
448
|
+
'Normale Fehler werden alle 30 Minuten gebündelt, solange sie bestehen. Hinweise und Entwarnungen sowie Erinnerungen an harte Fehler werden täglich zusammengefasst.',
|
|
449
|
+
'Details finden Sie in Ihrem NexoWatt EOS.'];
|
|
450
|
+
await this.deliver(to, subject, body.join('\n'), batch);
|
|
451
|
+
});
|
|
263
452
|
} catch (_error) { await this.status('Benachrichtigungsprüfung oder geschütztes Versandprotokoll nicht verfügbar.'); }
|
|
264
453
|
finally { this.busy = false; }
|
|
265
454
|
}
|
|
@@ -268,6 +457,7 @@ class NotificationMail {
|
|
|
268
457
|
*/
|
|
269
458
|
async collect(categories) {
|
|
270
459
|
const a = this.adapter, now = this.now(), events = [];
|
|
460
|
+
this.overlapRefs = new Map();
|
|
271
461
|
const read = async id => { const s = await a.getStateAsync(id); return s?.val; };
|
|
272
462
|
const add = (id, category, title, message, persistMs = 60000, severity = 'warning') => events.push({ id, category, title, message, persistMs, severity });
|
|
273
463
|
const retain = prefix => { for (const [id, record] of this.policy.records) if (id.startsWith(prefix) && record.active) events.push({ ...record.meta, suppressed: true }); };
|
|
@@ -316,6 +506,7 @@ class NotificationMail {
|
|
|
316
506
|
await a._notifyRefreshNwDevicesCache(false);
|
|
317
507
|
for (const d of (a._notify.nwDevices?.pvInverters || []).slice(0, 128)) {
|
|
318
508
|
if (!d.dp?.connected) continue;
|
|
509
|
+
this.overlapRefs.set('inverter:' + d.id, [{root:d.id},d.dp.connected]);
|
|
319
510
|
if (sourceDown(d.dp.connected)) { retain(`inverter:${d.id}`); continue; }
|
|
320
511
|
const state = await a.getForeignStateAsync(d.dp.connected);
|
|
321
512
|
if (!state) { retain(`inverter:${d.id}`); continue; }
|
|
@@ -342,6 +533,7 @@ class NotificationMail {
|
|
|
342
533
|
if (categories.has('system') && row.dispatchBlockedReasons?.includes('fault_active')) {
|
|
343
534
|
add(id, 'system', `Speicher meldet eine Störung: ${row.name}`, 'Der konfigurierte Speicher meldet einen aktiven Gerätefehler.', 0, 'critical');
|
|
344
535
|
} else if (categories.has('communications') && (row.state === 'offline' || row.degradedReason === 'stale')) {
|
|
536
|
+
this.overlapRefs.set(id, [row.signedPowerId, row.chargePowerId, row.socId]);
|
|
345
537
|
add(id, 'communications', `Speicher nicht erreichbar: ${row.name}`, 'Der konfigurierte Speicher meldet einen Verbindungsverlust oder veraltete Betriebsdaten.');
|
|
346
538
|
}
|
|
347
539
|
}
|
|
@@ -351,6 +543,7 @@ class NotificationMail {
|
|
|
351
543
|
if (!engineStalled && cm?.enabled !== false && (categories.has('charging') || categories.has('communications'))) {
|
|
352
544
|
for (const w of (cm?.wallboxes || []).slice(0, 128)) {
|
|
353
545
|
if (w.enabled === false || !w.key) continue;
|
|
546
|
+
this.overlapRefs.set('lp:' + w.key + ':offline', wallboxRefs(w));
|
|
354
547
|
const base = `chargingManagement.wallboxes.${safeId(w.key)}`;
|
|
355
548
|
const fields = ['online', 'faultActive', 'faultReason', 'userEnabled', 'userStationEnabled', 'vehiclePlugged', 'vehicleDemandConfirmed', 'targetPowerW', 'actualPowerW', 'meterStale', 'statusClass', 'reason', 'hardwareCommandState', 'applyStatus'];
|
|
356
549
|
const values = await Promise.all(fields.map(f => read(`${base}.${f}`)));
|
|
@@ -358,6 +551,8 @@ class NotificationMail {
|
|
|
358
551
|
const label = String(w.name || w.key);
|
|
359
552
|
if ([w.onlineId, w.powerId, w.statusId].some(sourceDown) || s.online == null) { retain(`lp:${w.key}:`); continue; }
|
|
360
553
|
if (categories.has('communications') && s.online === false) {
|
|
554
|
+
const station = await ocppRootRef(w,this.policy.supervisedNamespaces?.ocpp,a.getForeignStateAsync?.bind(a));
|
|
555
|
+
if (station) this.overlapRefs.get('lp:' + w.key + ':offline').push(station);
|
|
361
556
|
add(`lp:${w.key}:offline`, 'communications', `Ladepunkt nicht erreichbar: ${label}`, 'Die Verbindung zur Ladestation ist unterbrochen.'); retain(`lp:${w.key}:fault`); retain(`lp:${w.key}:interrupted`); continue;
|
|
362
557
|
}
|
|
363
558
|
if (categories.has('charging') && s.online === true && s.faultActive === true) {
|
|
@@ -393,4 +588,4 @@ class NotificationMail {
|
|
|
393
588
|
*/
|
|
394
589
|
close() { this.closed = true; this.transport?.close(); this.transport = null; }
|
|
395
590
|
}
|
|
396
|
-
module.exports = { NotificationMail, normalizeConfig, validAddress, smtpError, FROM };
|
|
591
|
+
module.exports = { NotificationMail, normalizeConfig, validAddress, smtpError, FROM, supervisedId, migrateIncident };
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* AUTO-GENERATED RUNTIME FILE - NICHT MANUELL BEARBEITEN.
|
|
8
8
|
*
|
|
9
9
|
* Quelle: src-ts/runtime-executables/lib/notification-policy.ts
|
|
10
|
-
* Quell-Hash: sha256:
|
|
10
|
+
* Quell-Hash: sha256:634f02161a4fe1bb8b9a01e4a31c0ea552f9e52a56b0c13348b63e033e5d09c9
|
|
11
11
|
* Erzeugung: npm run sync:ts-runtime-executables
|
|
12
12
|
*
|
|
13
13
|
* Zweck:
|
|
@@ -32,6 +32,8 @@
|
|
|
32
32
|
const HOUR = 3600000;
|
|
33
33
|
const DAY = 24 * HOUR;
|
|
34
34
|
const NORMAL_INTERVAL = 30 * 60000;
|
|
35
|
+
const LEGACY_CAP = 256;
|
|
36
|
+
const SUPERVISOR_CAP = 3 * 256 + 6;
|
|
35
37
|
const clean = value => String(value || '').replace(/[\r\n]+/g, ' ').slice(0, 400);
|
|
36
38
|
|
|
37
39
|
/** Bounded, durable incident transitions. Delivery is committed only after SMTP acceptance. */
|
|
@@ -40,7 +42,7 @@ class NotificationPolicy {
|
|
|
40
42
|
* Ablauf und Zusammenhang: Stellt den persistenten Meldungszustand mit begrenzten Listen wieder her. Zeitangaben sind Millisekunden; die Instanz selbst stellt keine Netzwerkverbindung her.
|
|
41
43
|
*/
|
|
42
44
|
constructor(saved = {}) {
|
|
43
|
-
this.records = new Map(Array.isArray(saved.records) ? saved.records.slice(0,
|
|
45
|
+
this.records = new Map(Array.isArray(saved.records) ? saved.records.slice(0, LEGACY_CAP + SUPERVISOR_CAP) : []);
|
|
44
46
|
this.sent = Array.isArray(saved.sent) ? saved.sent.filter(Number.isFinite).slice(-24) : [];
|
|
45
47
|
this.nextAttempt = Number(saved.nextAttempt) || 0;
|
|
46
48
|
this.failures = Number(saved.failures) || 0;
|
|
@@ -48,6 +50,7 @@ class NotificationPolicy {
|
|
|
48
50
|
this.lastDigest = Number(saved.lastDigest) || 0;
|
|
49
51
|
this.lastNormal = Number(saved.lastNormal) || 0;
|
|
50
52
|
this.recipientHash = String(saved.recipientHash || '');
|
|
53
|
+
this.supervisedNamespaces = saved.supervisedNamespaces || {};
|
|
51
54
|
}
|
|
52
55
|
/**
|
|
53
56
|
* Ablauf und Zusammenhang: Vergleicht den Hash der Kundenadresse. Bei Empfängerwechsel wird die bisherige Ereigniszuordnung gelöscht, damit der neue Empfänger keinen fremden Störungsverlauf erbt.
|
|
@@ -58,15 +61,30 @@ class NotificationPolicy {
|
|
|
58
61
|
/**
|
|
59
62
|
* Ablauf und Zusammenhang: Gleicht aktuelle Ereignisse mit bereits bekannten Störungen ab. Kurzes Flattern behält den Wiederholschutz; eine Eskalation auf kritisch und eine nach stabiler Erholung neue Störung werden gesondert behandelt.
|
|
60
63
|
*/
|
|
61
|
-
observe(events, now, categories) {
|
|
64
|
+
observe(events, now, categories, owns = () => true) {
|
|
62
65
|
if (!this.lastDigest) this.lastDigest = now;
|
|
63
66
|
if (!this.lastNormal) this.lastNormal = now;
|
|
64
67
|
const seen = new Set();
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
let supervisedCount = 0, deviceCount = 0;
|
|
69
|
+
for (const id of this.records.keys()) {
|
|
70
|
+
if (id.startsWith('supervisor:')) supervisedCount++;
|
|
71
|
+
if (id.startsWith('supervisor:device:')) deviceCount++;
|
|
72
|
+
}
|
|
73
|
+
for (const event of events) {
|
|
74
|
+
if (!event || !event.id || !owns(event.id) || !categories.has(event.category)) continue;
|
|
67
75
|
seen.add(event.id);
|
|
68
76
|
let r = this.records.get(event.id);
|
|
69
|
-
if (
|
|
77
|
+
if (event.hold) {
|
|
78
|
+
if (r) { r.suppressed = true; if (!r.active) r.clearSince = 0; }
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (!r) {
|
|
82
|
+
if (event.id.startsWith('supervisor:')) {
|
|
83
|
+
if (supervisedCount >= SUPERVISOR_CAP) continue;
|
|
84
|
+
if (event.id.startsWith('supervisor:device:')) { if (deviceCount >= SUPERVISOR_CAP - 6) continue; deviceCount++; }
|
|
85
|
+
supervisedCount++;
|
|
86
|
+
} else if (this.records.size - supervisedCount >= LEGACY_CAP) continue;
|
|
87
|
+
}
|
|
70
88
|
if (!r) r = { active: false, alertSent: false, lastSent: 0, since: now };
|
|
71
89
|
// A stable recovery ends the incident; brief flapping keeps its delivery history.
|
|
72
90
|
const newEpisode = !r.active && r.clearSince && now - r.clearSince >= 300000;
|
|
@@ -78,12 +96,15 @@ class NotificationPolicy {
|
|
|
78
96
|
r.suppressed = event.suppressed === true;
|
|
79
97
|
r.meta = { id: clean(event.id), category: event.category, title: clean(event.title).slice(0, 140), message: clean(event.message).slice(0, 300),
|
|
80
98
|
severity: ['critical', 'warning', 'info'].includes(event.severity) ? event.severity : 'warning', persistMs: event.severity === 'critical' ? 0 : 60000 };
|
|
99
|
+
if (event.physicalId) r.meta.physicalId = clean(event.physicalId);
|
|
81
100
|
this.records.set(event.id, r);
|
|
82
101
|
}
|
|
83
102
|
for (const [id, r] of this.records) {
|
|
103
|
+
if (!owns(id)) continue;
|
|
84
104
|
if (!categories.has(r.meta?.category)) { this.records.delete(id); continue; }
|
|
85
105
|
if (!seen.has(id)) {
|
|
86
|
-
|
|
106
|
+
r.suppressed = false;
|
|
107
|
+
if (r.active || !r.clearSince) { r.active = false; r.clearSince = now; }
|
|
87
108
|
const pending = !r.lastSent && (r.meta.severity === 'critical' || r.meta.severity === 'info' || r.clearSince - r.since >= 60000);
|
|
88
109
|
if ((!r.alertSent && !r.lastSent && !pending) || (now - (r.clearSince || now) > 2 * DAY)) this.records.delete(id);
|
|
89
110
|
}
|
|
@@ -101,7 +122,7 @@ class NotificationPolicy {
|
|
|
101
122
|
/**
|
|
102
123
|
* Ablauf und Zusammenhang: Wählt fällige Meldungen: neue kritische Fehler sofort, normale Fehler gesammelt nach 30 Minuten, Hinweise/Erinnerungen/Entwarnungen täglich. Unterdrückte Folgefehler werden ausgelassen; auch während SMTP-Ausfall bereits behobene unversandte harte Fehler bleiben meldbar.
|
|
103
124
|
*/
|
|
104
|
-
batch(now, recovery = true) {
|
|
125
|
+
batch(now, recovery = true, allowed = () => true) {
|
|
105
126
|
if (!this.quota(now)) return [];
|
|
106
127
|
const immediate = [], daily = [];
|
|
107
128
|
const digestDue = now - this.lastDigest >= DAY;
|
|
@@ -123,13 +144,19 @@ class NotificationPolicy {
|
|
|
123
144
|
else if (digestDue) daily.push({ ...item, daily: true });
|
|
124
145
|
} else if (!r.active && r.alertSent && now - r.clearSince >= 300000) {
|
|
125
146
|
if (recovery && digestDue) daily.push({ ...r.meta, kind: 'recovery', since: r.since, daily: true });
|
|
126
|
-
else if (!recovery) r.alertSent = false;
|
|
147
|
+
else if (!recovery && allowed(r.meta)) r.alertSent = false;
|
|
127
148
|
}
|
|
128
149
|
}
|
|
129
150
|
// Advance empty half-hour windows too; a new warning cannot bypass the collection interval.
|
|
130
151
|
if (normalDue && !immediate.some(item => item.normal)) this.lastNormal = now;
|
|
131
|
-
immediate.sort((a, b) => Number(b.severity === 'critical') - Number(a.severity === 'critical')
|
|
132
|
-
|
|
152
|
+
immediate.sort((a, b) => Number(b.severity === 'critical') - Number(a.severity === 'critical')
|
|
153
|
+
|| Number(b.id.startsWith('supervisor:process:')) - Number(a.id.startsWith('supervisor:process:')));
|
|
154
|
+
// Leave another live collector its window; its own fresh observations decide delivery.
|
|
155
|
+
const selected = immediate.concat(daily).filter(allowed).slice(0,64);
|
|
156
|
+
const selectedIds = new Set(selected.map(item => item.id));
|
|
157
|
+
this.deferNormal = immediate.some(item => item.normal && !selectedIds.has(item.id));
|
|
158
|
+
this.deferDigest = daily.some(item => !selectedIds.has(item.id));
|
|
159
|
+
return selected;
|
|
133
160
|
}
|
|
134
161
|
/**
|
|
135
162
|
* Ablauf und Zusammenhang: Setzt vor dem tatsächlichen Versand eine zweiminütige Versuchsreservierung. Bei Testmails wird zusätzlich deren letzter Versuch festgehalten.
|
|
@@ -150,8 +177,8 @@ class NotificationPolicy {
|
|
|
150
177
|
this.failures = 0;
|
|
151
178
|
this.nextAttempt = 0;
|
|
152
179
|
if (!batch.length) this.sent.push(now);
|
|
153
|
-
if (batch.some(item => item.daily)) this.lastDigest = now;
|
|
154
|
-
if (batch.some(item => item.normal)) this.lastNormal = now;
|
|
180
|
+
if (!this.deferDigest && batch.some(item => item.daily)) this.lastDigest = now;
|
|
181
|
+
if (!this.deferNormal && batch.some(item => item.normal)) this.lastNormal = now;
|
|
155
182
|
this.sent = this.sent.slice(-24);
|
|
156
183
|
for (const item of batch) {
|
|
157
184
|
const r = this.records.get(item.id);
|
|
@@ -165,7 +192,7 @@ class NotificationPolicy {
|
|
|
165
192
|
*/
|
|
166
193
|
snapshot() {
|
|
167
194
|
return { records: Array.from(this.records.entries()), sent: this.sent, nextAttempt: this.nextAttempt,
|
|
168
|
-
failures: this.failures, lastTest: this.lastTest, lastDigest: this.lastDigest, lastNormal: this.lastNormal, recipientHash: this.recipientHash };
|
|
195
|
+
failures: this.failures, lastTest: this.lastTest, lastDigest: this.lastDigest, lastNormal: this.lastNormal, recipientHash: this.recipientHash, supervisedNamespaces:this.supervisedNamespaces };
|
|
169
196
|
}
|
|
170
197
|
}
|
|
171
198
|
module.exports = { NotificationPolicy };
|
package/ui/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nexowatt-eos-ui-internal",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.35",
|
|
4
4
|
"description": "Internal UI and EMS module hosted by iobroker.eos-admin; not an ioBroker adapter entry point.",
|
|
5
5
|
"author": "NexoWatt",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -1129,6 +1129,7 @@
|
|
|
1129
1129
|
"www/tariff-display.js",
|
|
1130
1130
|
"lib/tariff-price.js",
|
|
1131
1131
|
"www/live-display.js",
|
|
1132
|
+
"www/dashboard-process-status.js",
|
|
1132
1133
|
"www/storagefarm-dispatch.js",
|
|
1133
1134
|
"lib/influx-direct.js",
|
|
1134
1135
|
"lib/influx-config.js",
|