iobroker.eos-admin 9.0.31 → 9.0.33
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 +11 -11
- package/README.md +9 -7
- package/adminWww/.vite/manifest.json +39 -39
- package/adminWww/NEXOWATT_EOS_FRONTEND_MANIFEST.json +107 -107
- package/adminWww/assets/{AdapterUpdateDialog-UhaQHyF1.js → AdapterUpdateDialog-DBUqmmyD.js} +1 -1
- package/adminWww/assets/{Adapters-Di3sM_ky.js → Adapters-dDEp7o5h.js} +1 -1
- package/adminWww/assets/{ConfigManager-C2naRwDl.js → ConfigManager-DbqTWi2N.js} +1 -1
- package/adminWww/assets/{Enums-B9ucB-qg.js → Enums-DjldGElU.js} +1 -1
- package/adminWww/assets/{Fields-DN41WFbp.js → Fields-0GsPCJeU.js} +1 -1
- package/adminWww/assets/{Files-C3PbbeNR.js → Files-COnUtEbg.js} +1 -1
- package/adminWww/assets/{Hosts-DXjTE0pX.js → Hosts-CwU1LujG.js} +1 -1
- package/adminWww/assets/{Instances-PKvEjDNQ.js → Instances-CUX5mxMQ.js} +1 -1
- package/adminWww/assets/{Intro-BnYMjDZr.js → Intro-BhQmHn3A.js} +1 -1
- package/adminWww/assets/{Logs-DTo6XJF_.js → Logs-B5SpNqHq.js} +1 -1
- package/adminWww/assets/{Objects-DyEBMDK6.js → Objects-COg_cFkz.js} +1 -1
- package/adminWww/assets/{Overview-CWLYuqZx.js → Overview-CitzUjBF.js} +1 -1
- package/adminWww/assets/{State-Ca9_Ke_c.js → State-D5ljzf-T.js} +1 -1
- package/adminWww/assets/{UsedResources-20bsoxmj.js → UsedResources-BY_NF2wB.js} +1 -1
- package/adminWww/assets/{Users-yZyZX-18.js → Users-Cu93_-VF.js} +1 -1
- package/adminWww/assets/{bootstrap-BQ4OzwbT.js → bootstrap-Dwfxhm2V.js} +3 -3
- package/adminWww/assets/{hostInit-CGSSNegd.js → hostInit-3BbTwhaZ.js} +1 -1
- package/adminWww/assets/{icons-material-C3PNaipj.js → icons-material-DjqX0l_7.js} +1 -1
- package/adminWww/assets/{index-C4CShixx.js → index-nddph2Sl.js} +2 -2
- package/adminWww/assets/{installSVGRenderer-DeaOAT3W.js → installSVGRenderer-CPDIwFAL.js} +1 -1
- package/adminWww/assets/{mf-entry-bootstrap-0-c5733c2d.js → mf-entry-bootstrap-0-d1f0f40f.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.33.js +12 -0
- package/adminWww/remoteEntry.js +1 -1
- package/build/lib/eosUiProcess.js +31 -14
- package/build/lib/eosUiProcess.js.map +1 -1
- package/build/lib/eosUiProcessRpc.js +3 -1
- package/build/lib/eosUiProcessRpc.js.map +1 -1
- package/build/lib/eosUiProcessWorker.js +6 -4
- package/build/lib/eosUiProcessWorker.js.map +1 -1
- package/docs/README.md +3 -2
- package/docs/reports/unified-9.0.32/PRUEFBERICHT.md +34 -0
- package/docs/reports/unified-9.0.32/PRUEFERGEBNISSE.json +112 -0
- package/docs/reports/unified-9.0.32/raw/INDEX.json +102 -0
- package/docs/reports/unified-9.0.32/raw/backend.log +5 -0
- package/docs/reports/unified-9.0.32/raw/browser-cadence-headless.json +63 -0
- package/docs/reports/unified-9.0.32/raw/browser-flow-headless.json +328 -0
- package/docs/reports/unified-9.0.32/raw/focused.log +67 -0
- package/docs/reports/unified-9.0.32/raw/frontend.log +151 -0
- package/docs/reports/unified-9.0.32/raw/installer.log +26 -0
- package/docs/reports/unified-9.0.32/raw/lint.log +5 -0
- package/docs/reports/unified-9.0.32/raw/modules.log +5 -0
- package/docs/reports/unified-9.0.32/raw/node22-tests-final.log +17212 -0
- package/docs/reports/unified-9.0.32/raw/node22-version.log +1 -0
- package/docs/reports/unified-9.0.32/raw/node24-tests-final.log +2869 -0
- package/docs/reports/unified-9.0.32/raw/node24-version.log +1 -0
- package/docs/reports/unified-9.0.32/raw/sbom.log +2 -0
- package/docs/reports/unified-9.0.32/raw/typecheck.log +5 -0
- package/docs/reports/unified-9.0.32/raw/ui-runtime.log +8 -0
- package/docs/reports/unified-9.0.32/raw/version-parity-928-929.log +6 -0
- package/docs/reports/unified-9.0.33/PRUEFBERICHT.md +60 -0
- package/docs/reports/unified-9.0.33/PRUEFERGEBNISSE.json +112 -0
- package/docs/reports/unified-9.0.33/raw/INDEX.json +272 -0
- package/docs/reports/unified-9.0.33/raw/backend.log +5 -0
- package/docs/reports/unified-9.0.33/raw/browser/UI_REVIEW.json +147 -0
- package/docs/reports/unified-9.0.33/raw/browser/admin-bundle.log +136 -0
- package/docs/reports/unified-9.0.33/raw/browser/eos-backup-settings-browser.log +67 -0
- package/docs/reports/unified-9.0.33/raw/browser/eos-customer-tariff-startup-browser.log +43 -0
- package/docs/reports/unified-9.0.33/raw/browser/eos-energyflow-browser-smoke.log +438 -0
- package/docs/reports/unified-9.0.33/raw/browser/eos-energyflow-cadence-browser-10s.log +108 -0
- package/docs/reports/unified-9.0.33/raw/browser/eos-evcs-delete-browser.log +1 -0
- package/docs/reports/unified-9.0.33/raw/browser/eos-history-setup-browser-smoke.log +49 -0
- package/docs/reports/unified-9.0.33/raw/browser/eos-kiosk-browser.log +59 -0
- package/docs/reports/unified-9.0.33/raw/browser/eos-ocpp-admin-browser.log +71 -0
- package/docs/reports/unified-9.0.33/raw/browser/eos-ocpp-installer-discovery-browser.log +11 -0
- package/docs/reports/unified-9.0.33/raw/browser/eos-pwa-trust-browser.log +35 -0
- package/docs/reports/unified-9.0.33/raw/browser/eos-runtime-controls-browser.log +78 -0
- package/docs/reports/unified-9.0.33/raw/browser/eos-runtime-health-browser.log +49 -0
- package/docs/reports/unified-9.0.33/raw/browser/eos-runtime-login-browser.log +34 -0
- package/docs/reports/unified-9.0.33/raw/browser/smarthome.log +46 -0
- package/docs/reports/unified-9.0.33/raw/browser-ten-seconds.json +108 -0
- package/docs/reports/unified-9.0.33/raw/changed-test-coverage.json +116 -0
- package/docs/reports/unified-9.0.33/raw/connected-control-node22.jsonl +42 -0
- package/docs/reports/unified-9.0.33/raw/connected-control-summary-node22.json +103 -0
- package/docs/reports/unified-9.0.33/raw/connected-control-summary.json +103 -0
- package/docs/reports/unified-9.0.33/raw/connected-control.jsonl +42 -0
- package/docs/reports/unified-9.0.33/raw/display-ui-node22.log +162 -0
- package/docs/reports/unified-9.0.33/raw/display-ui.log +35 -0
- package/docs/reports/unified-9.0.33/raw/frontend.log +151 -0
- package/docs/reports/unified-9.0.33/raw/git-delivery-fix.log +10 -0
- package/docs/reports/unified-9.0.33/raw/installer.log +26 -0
- package/docs/reports/unified-9.0.33/raw/license-central-node24.log +173 -0
- package/docs/reports/unified-9.0.33/raw/lint-final.log +45 -0
- package/docs/reports/unified-9.0.33/raw/modules.log +5 -0
- package/docs/reports/unified-9.0.33/raw/node22-npm-version.log +1 -0
- package/docs/reports/unified-9.0.33/raw/node22-tests-final.log +17646 -0
- package/docs/reports/unified-9.0.33/raw/node22-version.log +1 -0
- package/docs/reports/unified-9.0.33/raw/node24-npm-version.log +1 -0
- package/docs/reports/unified-9.0.33/raw/node24-tests-final.log +2941 -0
- package/docs/reports/unified-9.0.33/raw/node24-version.log +1 -0
- package/docs/reports/unified-9.0.33/raw/process-final-node22.log +220 -0
- package/docs/reports/unified-9.0.33/raw/process-final-node24.log +110 -0
- package/docs/reports/unified-9.0.33/raw/ram-picker.jsonl +12 -0
- package/docs/reports/unified-9.0.33/raw/reg-combined-node22.log +622 -0
- package/docs/reports/unified-9.0.33/raw/reg-combined.log +108 -0
- package/docs/reports/unified-9.0.33/raw/sbom-final.log +8 -0
- package/docs/reports/unified-9.0.33/raw/tariff-update-all-final-node22.log +1185 -0
- package/docs/reports/unified-9.0.33/raw/typecheck-final.log +5 -0
- package/docs/reports/unified-9.0.33/raw/ui-functional-node24.log +430 -0
- package/docs/reports/unified-9.0.33/raw/ui-runtime-final-verification.log +1 -0
- package/docs/reports/unified-9.0.33/raw/update-controller-standard-7-2-5.log +4 -0
- package/docs/reports/unified-9.0.33/raw/worker-memory-eos933.log +12 -0
- package/docs/reports/unified-9.0.33/raw/worker-memory-flow932.log +12 -0
- package/docs/start/START_HIER_9.0.32.md +16 -0
- package/docs/start/START_HIER_9.0.33.md +32 -0
- package/io-package.json +12 -12
- package/package.json +8 -5
- package/release-manifests/unified/build-environment.cdx.json +7 -7
- package/release-manifests/unified/files.json +208 -129
- package/release-manifests/unified/frontend.cdx.json +7 -7
- package/release-manifests/unified/installer.cdx.json +7 -7
- package/release-manifests/unified/obsolete-admin-assets.json +198 -28
- package/release-manifests/unified/runtime.cdx.json +27 -27
- package/release-manifests/unified/validation.json +15 -15
- package/tools/eos-release-manifest.cjs +2 -2
- package/ui/ems/consumers/sg-ready.js +26 -6
- package/ui/ems/datapoints.js +12 -4
- package/ui/ems/modules/charging-management.js +58 -67
- package/ui/ems/modules/core-limits.js +59 -36
- package/ui/ems/modules/prime-mover-control.js +141 -29
- package/ui/ems/modules/storage-control.js +31 -38
- package/ui/ems/modules/storage-mapping.js +14 -13
- package/ui/ems/modules/tarif-vis.js +38 -56
- package/ui/ems/services/measurement-freshness.js +58 -21
- package/ui/ems/services/safety-envelope.js +13 -6
- package/ui/io-package.json +9 -1
- package/ui/lib/datapoint-picker.js +27 -20
- package/ui/lib/tariff-price.js +7 -1
- package/ui/lib/ts-mirrors/ems/core-limits/core-runtime.js +5 -1
- package/ui/main.js +277 -182
- package/ui/package.json +4 -3
- package/ui/www/app.js +207 -87
- package/ui/www/ems-apps.js +3 -2
- package/ui/www/index.html +1 -0
- package/ui/www/live-display.js +38 -4
- package/ui/www/manifest.webmanifest +2 -2
- package/ui/www/power-measurements.js +28 -3
- package/adminWww/remoteEntry-eos-9.0.31.js +0 -12
package/ui/main.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* AUTO-GENERATED RUNTIME FILE - NICHT MANUELL BEARBEITEN.
|
|
8
8
|
*
|
|
9
9
|
* Quelle: src-ts/runtime-executables/main.ts
|
|
10
|
-
* Quell-Hash: sha256:
|
|
10
|
+
* Quell-Hash: sha256:604549a0e9412d2a3ffab1960c03d4fac51251a2922417eca81b0168d37f41ee
|
|
11
11
|
* Erzeugung: npm run sync:ts-runtime-executables
|
|
12
12
|
*
|
|
13
13
|
* Zweck:
|
|
@@ -58,6 +58,7 @@ const crypto = require('crypto');
|
|
|
58
58
|
const { installerRevision, assertInstallerRevision, provisionInstallerObjects, assertDeviceAppActivations, numericMeasurement, activeDeviceProfileReferences, awaitEmsTransition } = require('./lib/installer-lifecycle');
|
|
59
59
|
const { buildFarmOverview } = require('./lib/storage-farm-overview');
|
|
60
60
|
const { readFlowMeasurement, sumFlowMeasurements } = require('./lib/flow-measurement');
|
|
61
|
+
const nwDefaultFlowMappings = require('./io-package.json').native.datapoints;
|
|
61
62
|
const { tariffDisplayConfig, tariffPriceNumber } = require('./lib/tariff-price');
|
|
62
63
|
const { customerTariffView, prepareCustomerTariffChange, mergeInstallerTariffSecrets } = require('./lib/customer-tariff');
|
|
63
64
|
const { InfluxDirectClient } = require('./lib/influx-direct');
|
|
@@ -294,7 +295,7 @@ class NexoWattVis extends HostedAdapter {
|
|
|
294
295
|
});
|
|
295
296
|
this.sseClients = this._nwSseGuard.clients;
|
|
296
297
|
// Batch SSE updates to prevent UI freezes on frequent state updates
|
|
297
|
-
this._ssePendingPayload =
|
|
298
|
+
this._ssePendingPayload = null;
|
|
298
299
|
this._sseFlushTimer = null;
|
|
299
300
|
this.server = null;
|
|
300
301
|
this._serverSockets = new Set();
|
|
@@ -557,7 +558,7 @@ class NexoWattVis extends HostedAdapter {
|
|
|
557
558
|
} catch (_e) {}
|
|
558
559
|
// A pending coalesced patch is disposable: every browser receives a full
|
|
559
560
|
// current snapshot after reconnect/resync, while EMS control is untouched.
|
|
560
|
-
try { this._ssePendingPayload =
|
|
561
|
+
try { this._ssePendingPayload = null; } catch (_e) {}
|
|
561
562
|
try {
|
|
562
563
|
if (removed > 0) {
|
|
563
564
|
this.log.warn(`[memory-guard] ${removed} unhealthy SSE client(s) closed to release buffered live data; heap=${Math.round(Number(sample?.ratio || 0) * 1000) / 10}%`);
|
|
@@ -569,7 +570,7 @@ class NexoWattVis extends HostedAdapter {
|
|
|
569
570
|
/** Memory guard: final cleanup before the emergency restart safety net. */
|
|
570
571
|
_nwPrepareControlledRestart(sample) {
|
|
571
572
|
try { this._nwCloseSseClients(); } catch (_e) {}
|
|
572
|
-
try { this._ssePendingPayload =
|
|
573
|
+
try { this._ssePendingPayload = null; } catch (_e) {}
|
|
573
574
|
try {
|
|
574
575
|
this.log.error(`[memory-guard] preparing controlled restart at ${Math.round(Number(sample?.ratio || 0) * 1000) / 10}% heap usage`);
|
|
575
576
|
} catch (_e) {}
|
|
@@ -6575,9 +6576,7 @@ class NexoWattVis extends HostedAdapter {
|
|
|
6575
6576
|
//
|
|
6576
6577
|
// The timeout is configurable in the end-user settings page (Einstellungen).
|
|
6577
6578
|
const now = Date.now();
|
|
6578
|
-
const
|
|
6579
|
-
const staleSec = (Number.isFinite(staleSecRaw) && staleSecRaw > 0) ? staleSecRaw : 300;
|
|
6580
|
-
const staleMs = Math.max(10_000, Math.round(staleSec * 1000));
|
|
6579
|
+
const staleMs = this._nwLiveInputMaxAgeMs();
|
|
6581
6580
|
|
|
6582
6581
|
// Local read cache (per tick) to avoid repeating getForeignStateAsync calls.
|
|
6583
6582
|
const _stCache = new Map();
|
|
@@ -6753,7 +6752,7 @@ class NexoWattVis extends HostedAdapter {
|
|
|
6753
6752
|
|
|
6754
6753
|
const st = await getState(sid);
|
|
6755
6754
|
if (!st || st.val === undefined || st.val === null) return NaN;
|
|
6756
|
-
if (opts.display === true && ((st.q !== undefined && st.q !== 0) || !Number.isFinite(st.ts) || st.ts > now
|
|
6755
|
+
if (opts.display === true && ((st.q !== undefined && st.q !== 0) || !Number.isFinite(st.ts) || st.ts <= 0 || st.ts > now)) return NaN;
|
|
6757
6756
|
|
|
6758
6757
|
// IMPORTANT: We intentionally do NOT apply stale filtering here.
|
|
6759
6758
|
// Some devices update SoC or power only sporadically; the UI should still show
|
|
@@ -6808,6 +6807,7 @@ class NexoWattVis extends HostedAdapter {
|
|
|
6808
6807
|
let totalCharge = 0;
|
|
6809
6808
|
let totalDischarge = 0;
|
|
6810
6809
|
const batteryFlowSources = new Set();
|
|
6810
|
+
const physicalBatteryTimes = [];
|
|
6811
6811
|
let totalPvAc = 0;
|
|
6812
6812
|
let totalPvDc = 0;
|
|
6813
6813
|
let totalPvUnknown = 0;
|
|
@@ -7372,13 +7372,13 @@ class NexoWattVis extends HostedAdapter {
|
|
|
7372
7372
|
const pvAgeMs = (stPv && typeof stPv.ts === 'number' && Number.isFinite(stPv.ts))
|
|
7373
7373
|
? Math.max(0, now - Number(stPv.ts))
|
|
7374
7374
|
: null;
|
|
7375
|
-
const
|
|
7376
|
-
const
|
|
7375
|
+
const pvValue = !explicitOffline ? await readNumber(pvSourceId, 'power', { allowStale: false, display: true }) : NaN;
|
|
7376
|
+
const pvFresh = Number.isFinite(pvValue);
|
|
7377
7377
|
const pvAbs = Number.isFinite(pvValue) ? Math.max(0, Math.abs(pvValue)) : 0;
|
|
7378
7378
|
status.pvSourceOnline = !!pvFresh;
|
|
7379
7379
|
if (pvAgeMs !== null) status.pvSourceAgeSec = Math.floor(pvAgeMs / 1000);
|
|
7380
7380
|
if (pvFresh && Number.isFinite(pvValue)) status.pvPowerW = pvAbs;
|
|
7381
|
-
const displayPv =
|
|
7381
|
+
const displayPv = pvValue;
|
|
7382
7382
|
// Gepunktete Geräte-IDs enden erst vor `.aliases.`, nicht am ersten Punkt.
|
|
7383
7383
|
// Unbekannte manuelle Pfade bleiben exakte Quellen statt geratenen Geräteklassen.
|
|
7384
7384
|
const aliasDeviceBase = pvSourceId.match(/^(.*\.devices\..+?)\.aliases(?:\.|$)/)?.[1];
|
|
@@ -7500,6 +7500,8 @@ class NexoWattVis extends HostedAdapter {
|
|
|
7500
7500
|
Math.max(0, invDchg ? -discharge : discharge) - Math.max(0, invChg ? -charge : charge);
|
|
7501
7501
|
}
|
|
7502
7502
|
if (Number.isFinite(physicalPower)) {
|
|
7503
|
+
const observedIds = batteryFlowId ? [batteryFlowId] : signedFeedbackUsable ? [signedId] : [chgId, dchgId].filter(Boolean);
|
|
7504
|
+
for (const id of observedIds) physicalBatteryTimes.push((await getState(id)).ts);
|
|
7503
7505
|
status.batteryFlowPowerW = physicalPower;
|
|
7504
7506
|
overviewMember.batteryPowerW = physicalPower;
|
|
7505
7507
|
if (duplicateBatteryFlow) status.batteryFlowDuplicate = true;
|
|
@@ -7561,7 +7563,10 @@ class NexoWattVis extends HostedAdapter {
|
|
|
7561
7563
|
const totalBatteryPowerState = farmOverview.battery.netW;
|
|
7562
7564
|
const totalChargeState = Math.round(totalCharge);
|
|
7563
7565
|
const totalDischargeState = Math.round(totalDischarge);
|
|
7564
|
-
const
|
|
7566
|
+
const pvComplete = pvSourcesOnline > 0 && pvSourcesOnline === pvSourceRows.length;
|
|
7567
|
+
const totalPvState = pvComplete ? Math.round(totalPv) : null;
|
|
7568
|
+
const pvPowerTs = pvComplete ? Math.min(...pvSourceRows.map(row => now - row.ageMs)) : now;
|
|
7569
|
+
const batteryPowerTs = totalBatteryPowerState !== null && physicalBatteryTimes.length ? Math.min(...physicalBatteryTimes) : now;
|
|
7565
7570
|
const totalPvAcState = Math.round(totalPvAc);
|
|
7566
7571
|
const totalPvDcState = Math.round(totalPvDc);
|
|
7567
7572
|
const totalPvUnknownState = Math.round(totalPvUnknown);
|
|
@@ -7576,9 +7581,9 @@ class NexoWattVis extends HostedAdapter {
|
|
|
7576
7581
|
await writeDerived('storageFarm.socSourcesOnline', { val: socSourcesOnline, ack: true });
|
|
7577
7582
|
await writeDerived('storageFarm.socDegraded', { val: !!socDegraded, ack: true });
|
|
7578
7583
|
await writeDerived('storageFarm.totalPowerW', { val: totalPowerState, ack: true });
|
|
7579
|
-
await writeDerived('storageFarm.totalBatteryPowerW', { val: totalBatteryPowerState, ack: true });
|
|
7580
|
-
await writeDerived('storageFarm.totalBatteryChargePowerW', { val: farmOverview.battery.chargeW, ack: true });
|
|
7581
|
-
await writeDerived('storageFarm.totalBatteryDischargePowerW', { val: farmOverview.battery.dischargeW, ack: true });
|
|
7584
|
+
await writeDerived('storageFarm.totalBatteryPowerW', { val: totalBatteryPowerState, ack: true, ts: batteryPowerTs });
|
|
7585
|
+
await writeDerived('storageFarm.totalBatteryChargePowerW', { val: farmOverview.battery.chargeW, ack: true, ts: batteryPowerTs });
|
|
7586
|
+
await writeDerived('storageFarm.totalBatteryDischargePowerW', { val: farmOverview.battery.dischargeW, ack: true, ts: batteryPowerTs });
|
|
7582
7587
|
await writeDerived('storageFarm.displayMeanSoc', { val: farmOverview.soc.meanPct, ack: true });
|
|
7583
7588
|
await writeDerived('storageFarm.totalCapacityKWh', { val: farmOverview.capacity.totalKWh, ack: true });
|
|
7584
7589
|
await writeDerived('storageFarm.overviewJson', { val: farmOverviewJson, ack: true });
|
|
@@ -7586,7 +7591,7 @@ class NexoWattVis extends HostedAdapter {
|
|
|
7586
7591
|
await writeDerived('storageFarm.powerSourcesOnline', { val: powerSourcesOnline, ack: true });
|
|
7587
7592
|
await writeDerived('storageFarm.totalChargePowerW', { val: totalChargeState, ack: true });
|
|
7588
7593
|
await writeDerived('storageFarm.totalDischargePowerW', { val: totalDischargeState, ack: true });
|
|
7589
|
-
await writeDerived('storageFarm.totalPvPowerW', { val: totalPvState, ack: true });
|
|
7594
|
+
await writeDerived('storageFarm.totalPvPowerW', { val: totalPvState, ack: true, ts: pvPowerTs });
|
|
7590
7595
|
await writeDerived('storageFarm.totalPvAcPowerW', { val: totalPvAcState, ack: true });
|
|
7591
7596
|
await writeDerived('storageFarm.totalPvDcPowerW', { val: totalPvDcState, ack: true });
|
|
7592
7597
|
await writeDerived('storageFarm.totalPvUnknownPowerW', { val: totalPvUnknownState, ack: true });
|
|
@@ -7616,9 +7621,9 @@ class NexoWattVis extends HostedAdapter {
|
|
|
7616
7621
|
this.updateValue('storageFarm.socSourcesOnline', socSourcesOnline, now);
|
|
7617
7622
|
this.updateValue('storageFarm.socDegraded', !!socDegraded, now);
|
|
7618
7623
|
this.updateValue('storageFarm.totalPowerW', totalPowerState, now);
|
|
7619
|
-
this.updateValue('storageFarm.totalBatteryPowerW', totalBatteryPowerState,
|
|
7620
|
-
this.updateValue('storageFarm.totalBatteryChargePowerW', farmOverview.battery.chargeW,
|
|
7621
|
-
this.updateValue('storageFarm.totalBatteryDischargePowerW', farmOverview.battery.dischargeW,
|
|
7624
|
+
this.updateValue('storageFarm.totalBatteryPowerW', totalBatteryPowerState, batteryPowerTs);
|
|
7625
|
+
this.updateValue('storageFarm.totalBatteryChargePowerW', farmOverview.battery.chargeW, batteryPowerTs);
|
|
7626
|
+
this.updateValue('storageFarm.totalBatteryDischargePowerW', farmOverview.battery.dischargeW, batteryPowerTs);
|
|
7622
7627
|
this.updateValue('storageFarm.displayMeanSoc', farmOverview.soc.meanPct, now);
|
|
7623
7628
|
this.updateValue('storageFarm.totalCapacityKWh', farmOverview.capacity.totalKWh, now);
|
|
7624
7629
|
this.updateValue('storageFarm.overviewJson', farmOverviewJson, now);
|
|
@@ -7626,7 +7631,7 @@ class NexoWattVis extends HostedAdapter {
|
|
|
7626
7631
|
this.updateValue('storageFarm.powerSourcesOnline', powerSourcesOnline, now);
|
|
7627
7632
|
this.updateValue('storageFarm.totalChargePowerW', totalChargeState, now);
|
|
7628
7633
|
this.updateValue('storageFarm.totalDischargePowerW', totalDischargeState, now);
|
|
7629
|
-
this.updateValue('storageFarm.totalPvPowerW', totalPvState,
|
|
7634
|
+
this.updateValue('storageFarm.totalPvPowerW', totalPvState, pvPowerTs);
|
|
7630
7635
|
this.updateValue('storageFarm.totalPvAcPowerW', totalPvAcState, now);
|
|
7631
7636
|
this.updateValue('storageFarm.totalPvDcPowerW', totalPvDcState, now);
|
|
7632
7637
|
this.updateValue('storageFarm.totalPvUnknownPowerW', totalPvUnknownState, now);
|
|
@@ -27187,6 +27192,9 @@ return res.json(out);
|
|
|
27187
27192
|
const slice = plan.slice(i, i + concurrency);
|
|
27188
27193
|
await Promise.all(slice.map((entry) => applyState(entry)));
|
|
27189
27194
|
}
|
|
27195
|
+
if (this._derivedFlow?.reviewAt && Date.now() >= this._derivedFlow.reviewAt) {
|
|
27196
|
+
this.scheduleDerivedFlowUpdate('measurement-expiry');
|
|
27197
|
+
}
|
|
27190
27198
|
} finally {
|
|
27191
27199
|
this._nwLiveCoreRefreshRunning = false;
|
|
27192
27200
|
}
|
|
@@ -27385,6 +27393,7 @@ return res.json(out);
|
|
|
27385
27393
|
// "Datenpunkte" gemappt wurden. Daher wird im Subscribe-Loop unten auf die lokalen
|
|
27386
27394
|
// Adapter-States (namespace + key) zurückgefallen.
|
|
27387
27395
|
const localUiKeys = [
|
|
27396
|
+
'speicher.dcPvPowerW',
|
|
27388
27397
|
'tarif.statusText', 'tarif.intentStatusText', 'tarif.intentSnapshotAgeMs', 'tarif.intentSnapshotFresh', 'tarif.statusJson',
|
|
27389
27398
|
'tarif.speicherIntentW', 'tarif.speicherIntentStatus', 'tarif.speicherIntentGrund',
|
|
27390
27399
|
'tarif.speicherRequestW', 'tarif.speicherRequestQuelle', 'tarif.speicherRequestGrund',
|
|
@@ -28670,9 +28679,10 @@ return res.json(out);
|
|
|
28670
28679
|
// Nach einem Update kann der neu angelegte totalPowerW-State kurz 0 W enthalten,
|
|
28671
28680
|
// während die bereits vorhandenen Brutto-States noch den echten Farmfluss zeigen.
|
|
28672
28681
|
// Erst nach mindestens einer ausgewerteten Leistungsquelle ist totalPowerW führend.
|
|
28673
|
-
const
|
|
28674
|
-
|
|
28675
|
-
|
|
28682
|
+
const useLegacySigned = signedState !== null && (powerSourcesTotal > 0 || (grossChargeW <= 0 && grossDischargeW <= 0));
|
|
28683
|
+
const signedW = hasBatteryFlow ? batteryFlowState : useLegacySigned ? signedState : grossDischargeW - grossChargeW;
|
|
28684
|
+
const powerSourceKeys = hasBatteryFlow ? ['storageFarm.totalBatteryPowerW']
|
|
28685
|
+
: useLegacySigned ? ['storageFarm.totalPowerW'] : ['storageFarm.totalChargePowerW', 'storageFarm.totalDischargePowerW'];
|
|
28676
28686
|
const chargeW = signedW === null ? null : signedW < 0 ? Math.abs(signedW) : 0;
|
|
28677
28687
|
const dischargeW = signedW === null ? null : signedW > 0 ? signedW : 0;
|
|
28678
28688
|
|
|
@@ -28703,6 +28713,7 @@ return res.json(out);
|
|
|
28703
28713
|
totalPowerW: signedW === null ? null : Math.round(signedW),
|
|
28704
28714
|
chargeW: chargeW === null ? null : Math.round(chargeW),
|
|
28705
28715
|
dischargeW: dischargeW === null ? null : Math.round(dischargeW),
|
|
28716
|
+
powerSourceKeys,
|
|
28706
28717
|
grossChargeW: Math.round(grossChargeW),
|
|
28707
28718
|
grossDischargeW: Math.round(grossDischargeW),
|
|
28708
28719
|
pvTotalW: Math.round(pvTotalW),
|
|
@@ -28837,6 +28848,7 @@ return res.json(out);
|
|
|
28837
28848
|
const maxAgeMs = opts.maxAgeMs === undefined ? this._nwLiveInputMaxAgeMs() : opts.maxAgeMs;
|
|
28838
28849
|
const deadbandW = Number.isFinite(Number(opts.deadbandW)) ? Math.max(0, Number(opts.deadbandW)) : 25;
|
|
28839
28850
|
const strictStale = opts.strictStale === true;
|
|
28851
|
+
const observe = opts.observe === true;
|
|
28840
28852
|
|
|
28841
28853
|
const dps = (this.config && this.config.datapoints && typeof this.config.datapoints === 'object') ? this.config.datapoints : {};
|
|
28842
28854
|
/**
|
|
@@ -28868,11 +28880,10 @@ return res.json(out);
|
|
|
28868
28880
|
* Zusammenhang: Teil von Adapterkern: Lifecycle, Webserver, API, States, EMS-Engine; Aufrufstellen und abhängige States/APIs beim Ändern mitprüfen.
|
|
28869
28881
|
* TypeScript: Parameter, Rückgabewert und verwendete Config-/State-Objekte später explizit typisieren.
|
|
28870
28882
|
*/
|
|
28871
|
-
const readMapped = (key
|
|
28872
|
-
|
|
28873
|
-
|
|
28874
|
-
|
|
28875
|
-
: this._nwGetNumberFromCacheFresh(key, strictStale ? maxAgeMs : null, null, now);
|
|
28883
|
+
const readMapped = (key) => this._nwGetRawNumberFromCache(key, strictStale ? maxAgeMs : null, null, now);
|
|
28884
|
+
const observeMapped = (key) => {
|
|
28885
|
+
// A normalized display mirror cannot supply a physical observation.
|
|
28886
|
+
return readFlowMeasurement(this._nwRawValueCache, key, now, maxAgeMs);
|
|
28876
28887
|
};
|
|
28877
28888
|
/**
|
|
28878
28889
|
* Code-Teil: ageInfo
|
|
@@ -28908,6 +28919,7 @@ return res.json(out);
|
|
|
28908
28919
|
fromSigned: true,
|
|
28909
28920
|
mirror: opts2.mirror !== false,
|
|
28910
28921
|
derived: false,
|
|
28922
|
+
observedAt: opts2.observedAt ?? null,
|
|
28911
28923
|
staleMs: ageInfo(),
|
|
28912
28924
|
};
|
|
28913
28925
|
};
|
|
@@ -28986,10 +28998,13 @@ return res.json(out);
|
|
|
28986
28998
|
const sfEnabled = !!(farmMetrics && farmMetrics.active);
|
|
28987
28999
|
if (farmSelectedForControl) {
|
|
28988
29000
|
let signed = farmMetrics ? numericMeasurement(farmMetrics.totalPowerW) : null;
|
|
29001
|
+
// Converter/dispatch power is not a measurement of a hybrid battery.
|
|
29002
|
+
const observation = observe && farmMetrics
|
|
29003
|
+
? readFlowMeasurement(this.stateCache, 'storageFarm.totalBatteryPowerW', now, maxAgeMs) : null;
|
|
29004
|
+
if (observe) signed = observation?.value ?? null;
|
|
28989
29005
|
if (signed !== null && Number.isFinite(signed)) {
|
|
28990
|
-
//
|
|
28991
|
-
//
|
|
28992
|
-
// Anzeige-Invert darf diesen kanonischen Farmwert nicht ein zweites Mal drehen.
|
|
29006
|
+
// Die Batterie-Nettoleistung der Farm ist bereits pro Speicher normalisiert
|
|
29007
|
+
// (+ Entladen, - Laden) und darf nicht nochmals invertiert werden.
|
|
28993
29008
|
if (Math.abs(signed) <= deadbandW) signed = 0;
|
|
28994
29009
|
const c = signed < 0 ? Math.abs(signed) : 0;
|
|
28995
29010
|
const d = signed > 0 ? signed : 0;
|
|
@@ -29002,6 +29017,7 @@ return res.json(out);
|
|
|
29002
29017
|
fromSigned: true,
|
|
29003
29018
|
derived: false,
|
|
29004
29019
|
mirror: true,
|
|
29020
|
+
observedAt: observation?.ts ?? null,
|
|
29005
29021
|
grossChargeW: farmMetrics.grossChargeW,
|
|
29006
29022
|
grossDischargeW: farmMetrics.grossDischargeW,
|
|
29007
29023
|
staleMs: {
|
|
@@ -29031,15 +29047,23 @@ return res.json(out);
|
|
|
29031
29047
|
};
|
|
29032
29048
|
}
|
|
29033
29049
|
|
|
29034
|
-
const
|
|
29035
|
-
const
|
|
29036
|
-
const
|
|
29050
|
+
const batterySample = observe && batteryMapped ? observeMapped('batteryPower') : null;
|
|
29051
|
+
const chargeSample = observe && chargeMapped ? observeMapped('storageChargePower') : null;
|
|
29052
|
+
const dischargeSample = observe && dischargeMapped ? observeMapped('storageDischargePower') : null;
|
|
29053
|
+
const batterySigned = batteryMapped ? (observe ? batterySample?.value ?? null : readMapped('batteryPower')) : null;
|
|
29054
|
+
const chargeRaw = chargeMapped ? (observe ? chargeSample?.value ?? null : readMapped('storageChargePower')) : null;
|
|
29055
|
+
const dischargeRaw = dischargeMapped ? (observe ? dischargeSample?.value ?? null : readMapped('storageDischargePower')) : null;
|
|
29037
29056
|
|
|
29038
29057
|
// Beide Split-Felder auf denselben DP gemappt = tatsächlich ein signed DP.
|
|
29039
|
-
if (sameChargeDischargeId
|
|
29040
|
-
return fromSigned(chargeRaw, 'sameChargeDischargeSigned', {
|
|
29058
|
+
if (sameChargeDischargeId) {
|
|
29059
|
+
if (chargeRaw !== null) return fromSigned(chargeRaw, 'sameChargeDischargeSigned', { observedAt: chargeSample?.ts });
|
|
29060
|
+
if (observe && dischargeSample) return fromSigned(dischargeSample.value, 'sameChargeDischargeSigned', { observedAt: dischargeSample.ts });
|
|
29041
29061
|
}
|
|
29042
29062
|
|
|
29063
|
+
const completeSplit = chargeSample !== null && dischargeSample !== null;
|
|
29064
|
+
if (observe && !completeSplit && batterySample) {
|
|
29065
|
+
return fromSigned(batterySample.value, 'batterySigned', { observedAt: batterySample.ts });
|
|
29066
|
+
}
|
|
29043
29067
|
// Getrennte Lade-/Entlade-DPs sind autoritativ. Eine fehlende Seite wird als 0 W
|
|
29044
29068
|
// behandelt; sie wird nicht durch Bilanzwerte ersetzt. Das schützt Historie und
|
|
29045
29069
|
// Regelung vor verfälschten Speicherwerten bei konstantem/stalem 0-Wert.
|
|
@@ -29069,19 +29093,20 @@ return res.json(out);
|
|
|
29069
29093
|
fromSigned: false,
|
|
29070
29094
|
derived: false,
|
|
29071
29095
|
mirror: false,
|
|
29096
|
+
observedAt: observe && completeSplit ? Math.min(chargeSample?.ts ?? now, dischargeSample?.ts ?? now) : null,
|
|
29072
29097
|
staleMs: ageInfo(),
|
|
29073
29098
|
};
|
|
29074
29099
|
}
|
|
29075
29100
|
|
|
29076
29101
|
// Signed Batterie-DP ist der Fallback, wenn keine Split-DPs einen Wert liefern.
|
|
29077
29102
|
if (batterySigned !== null) {
|
|
29078
|
-
return fromSigned(batterySigned, 'batterySigned', {
|
|
29103
|
+
return fromSigned(batterySigned, 'batterySigned', { observedAt: batterySample?.ts });
|
|
29079
29104
|
}
|
|
29080
29105
|
|
|
29081
29106
|
// Rechen-Fallback nur, wenn überhaupt kein Speicher-DP konfiguriert ist.
|
|
29082
29107
|
// Wenn ein Speicher-DP konfiguriert, aber aktuell nicht lesbar ist, zeigen wir keinen
|
|
29083
29108
|
// geratenen Wert, damit Historie/Regelung nicht verfälscht werden.
|
|
29084
|
-
if (!anyStorageMapped) {
|
|
29109
|
+
if (!anyStorageMapped && !observe) {
|
|
29085
29110
|
const derived = fromBalance();
|
|
29086
29111
|
if (derived) return derived;
|
|
29087
29112
|
}
|
|
@@ -30803,33 +30828,59 @@ return res.json(out);
|
|
|
30803
30828
|
* Zusammenhang: Teil von Adapterkern: Lifecycle, Webserver, API, States, EMS-Engine; Aufrufstellen und abhängige States/APIs beim Ändern mitprüfen.
|
|
30804
30829
|
* TypeScript: Parameter, Rückgabewert und verwendete Config-/State-Objekte später explizit typisieren.
|
|
30805
30830
|
*/
|
|
30806
|
-
_nwResolveGridImportExportFromCache() {
|
|
30831
|
+
_nwResolveGridImportExportFromCache(opts = {}) {
|
|
30807
30832
|
const gridBuyMapped = this._nwHasMappedDatapoint('gridBuyPower');
|
|
30808
30833
|
const gridSellMapped = this._nwHasMappedDatapoint('gridSellPower');
|
|
30809
30834
|
const gridNetMapped = this._nwHasMappedDatapoint('gridPointPower');
|
|
30810
|
-
const
|
|
30811
|
-
const
|
|
30835
|
+
const observe = opts.observe === true;
|
|
30836
|
+
const now = opts.now ?? Date.now();
|
|
30837
|
+
const maxAgeMs = opts.maxAgeMs ?? this._nwLiveInputMaxAgeMs();
|
|
30812
30838
|
const canonicalRec = this.stateCache && this.stateCache['ems.gridMeasurementFresh'];
|
|
30813
30839
|
const canonicalAge = canonicalRec ? this._nwGetCacheAgeMs('ems.gridMeasurementFresh', now) : null;
|
|
30814
|
-
const canonicalKnown = !!(canonicalRec && canonicalAge !== null && canonicalAge <= Math.max(maxAgeMs, 15000));
|
|
30840
|
+
const canonicalKnown = !observe && !!(canonicalRec && canonicalAge !== null && canonicalAge <= Math.max(maxAgeMs, 15000));
|
|
30815
30841
|
const readFresh = (key, mapped) => mapped ? this._nwGetNumberFromCacheFresh(key, maxAgeMs, null, now) : null;
|
|
30816
|
-
|
|
30842
|
+
const observeMapped = (key, mapped) => observe && mapped ? readFlowMeasurement(this._nwRawValueCache, key, now, maxAgeMs) : null;
|
|
30843
|
+
const signed = observeMapped('gridPointPower', gridNetMapped);
|
|
30844
|
+
const buy = observeMapped('gridBuyPower', gridBuyMapped);
|
|
30845
|
+
const sell = observeMapped('gridSellPower', gridSellMapped);
|
|
30846
|
+
const localNvp = observe ? this._nvpFreshnessSnapshot : null;
|
|
30847
|
+
const latestPhysicalTs = Math.max(signed?.ts ?? 0, buy?.ts ?? 0, sell?.ts ?? 0);
|
|
30848
|
+
const nvpUnavailable = localNvp?.usable === false && Number.isFinite(localNvp.ts)
|
|
30849
|
+
&& localNvp.ts <= now && now - localNvp.ts <= Math.min(maxAgeMs, 15000)
|
|
30850
|
+
&& (localNvp.connected === false || latestPhysicalTs <= localNvp.ts);
|
|
30851
|
+
const invert = observe && this.config?.settings?.flowInvertGrid === true;
|
|
30852
|
+
const measuredImport = invert ? sell : buy;
|
|
30853
|
+
const measuredExport = invert ? buy : sell;
|
|
30854
|
+
const resolved = resolveNvpDisplay({
|
|
30817
30855
|
maxAgeMs,
|
|
30818
|
-
canonicalKnown,
|
|
30819
|
-
canonicalFresh: canonicalKnown && typeof canonicalRec.value === 'boolean' ? canonicalRec.value : null,
|
|
30820
|
-
|
|
30856
|
+
canonicalKnown: canonicalKnown || nvpUnavailable,
|
|
30857
|
+
canonicalFresh: nvpUnavailable ? false : canonicalKnown && typeof canonicalRec.value === 'boolean' ? canonicalRec.value : null,
|
|
30858
|
+
// The EMS mirror carries its publication time, so it cannot establish
|
|
30859
|
+
// the age of a physical sample for an observed building balance.
|
|
30860
|
+
canonicalNetW: observe ? null : this._nwGetNumberFromCacheFresh('ems.gridPowerRawW', maxAgeMs, null, now),
|
|
30821
30861
|
canonicalSource: this.stateCache?.['ems.gridPowerSource']?.value,
|
|
30822
|
-
canonicalStatus: this.stateCache?.['ems.gridMeasurementStatus']?.value,
|
|
30823
|
-
gridNetRaw: readFresh('gridPointPower', gridNetMapped),
|
|
30824
|
-
gridBuyRaw: readFresh('gridBuyPower', gridBuyMapped),
|
|
30825
|
-
gridSellRaw: readFresh('gridSellPower', gridSellMapped),
|
|
30826
|
-
gridBuyTs: this.stateCache?.gridBuyPower?.ts,
|
|
30827
|
-
gridSellTs: this.stateCache?.gridSellPower?.ts,
|
|
30862
|
+
canonicalStatus: nvpUnavailable ? localNvp.status : this.stateCache?.['ems.gridMeasurementStatus']?.value,
|
|
30863
|
+
gridNetRaw: observe ? (signed ? (invert ? -signed.value : signed.value) : null) : readFresh('gridPointPower', gridNetMapped),
|
|
30864
|
+
gridBuyRaw: observe ? measuredImport?.value ?? null : readFresh('gridBuyPower', gridBuyMapped),
|
|
30865
|
+
gridSellRaw: observe ? measuredExport?.value ?? null : readFresh('gridSellPower', gridSellMapped),
|
|
30866
|
+
gridBuyTs: observe ? measuredImport?.ts : this.stateCache?.gridBuyPower?.ts,
|
|
30867
|
+
gridSellTs: observe ? measuredExport?.ts : this.stateCache?.gridSellPower?.ts,
|
|
30828
30868
|
maxSkewMs: this.config?.diagnostics?.nvpMaxSkewMs,
|
|
30829
30869
|
gridBuyMapped,
|
|
30830
30870
|
gridSellMapped,
|
|
30831
30871
|
gridNetMapped,
|
|
30832
30872
|
});
|
|
30873
|
+
if (!observe) return resolved;
|
|
30874
|
+
|
|
30875
|
+
let observedAt = null;
|
|
30876
|
+
const splitComplete = (!gridBuyMapped || buy !== null) && (!gridSellMapped || sell !== null);
|
|
30877
|
+
if (resolved.sampleSource === 'signed') observedAt = signed.ts;
|
|
30878
|
+
else if (splitComplete) {
|
|
30879
|
+
if (resolved.sampleSource === 'split') observedAt = Math.min(measuredImport.ts, measuredExport.ts);
|
|
30880
|
+
else if (resolved.sampleSource === 'import') observedAt = measuredImport.ts;
|
|
30881
|
+
else if (resolved.sampleSource === 'export') observedAt = measuredExport.ts;
|
|
30882
|
+
}
|
|
30883
|
+
return { ...resolved, observedAt };
|
|
30833
30884
|
}
|
|
30834
30885
|
|
|
30835
30886
|
/**
|
|
@@ -31124,7 +31175,7 @@ return res.json(out);
|
|
|
31124
31175
|
gridSellW,
|
|
31125
31176
|
hasGrid,
|
|
31126
31177
|
} = this._nwResolveGridImportExportFromCache();
|
|
31127
|
-
const historyCoreMaxAgeMs =
|
|
31178
|
+
const historyCoreMaxAgeMs = this._nwLiveInputMaxAgeMs();
|
|
31128
31179
|
// History samples are observations, not a refresh of the last cached value.
|
|
31129
31180
|
// Missing timestamps, stale values and missing measurements remain gaps.
|
|
31130
31181
|
const readHistory = (key, maxAgeMs = historyCoreMaxAgeMs) => {
|
|
@@ -31152,8 +31203,9 @@ return res.json(out);
|
|
|
31152
31203
|
? this._nwGetStorageControlAuthority()
|
|
31153
31204
|
: { selectedTopology: 'none', writerActive: false };
|
|
31154
31205
|
const selectedStorageTopologyHist = String(storageAuthorityHist.selectedTopology || 'none');
|
|
31155
|
-
const storageFlowHist = this._nwResolveBatteryFlowFromCache({ now, strictStale: true });
|
|
31156
|
-
const storageMissing =
|
|
31206
|
+
const storageFlowHist = this._nwResolveBatteryFlowFromCache({ now, strictStale: true, observe: true, maxAgeMs: historyCoreMaxAgeMs });
|
|
31207
|
+
const storageMissing = !Number.isFinite(storageFlowHist.observedAt)
|
|
31208
|
+
|| ['missing', 'mapped-missing', 'storageFarm-missing-power', 'storageFarm-unavailable'].includes(storageFlowHist.src);
|
|
31157
31209
|
const farmPowerAge = storageFlowHist.staleMs && numericMeasurement(storageFlowHist.staleMs.farmPower);
|
|
31158
31210
|
const farmPowerStale = selectedStorageTopologyHist === 'farm'
|
|
31159
31211
|
&& (farmPowerAge === null || farmPowerAge === undefined || farmPowerAge > historyCoreMaxAgeMs);
|
|
@@ -31204,28 +31256,32 @@ return res.json(out);
|
|
|
31204
31256
|
&& this.config.storage
|
|
31205
31257
|
&& String(this.config.storage.coupling || '').trim().toLowerCase() === 'dc');
|
|
31206
31258
|
|
|
31207
|
-
if (!pvTotalFromDerived && sfEnabled
|
|
31208
|
-
|
|
31209
|
-
|
|
31210
|
-
|
|
31211
|
-
now,
|
|
31212
|
-
|
|
31213
|
-
|
|
31214
|
-
|
|
31215
|
-
|
|
31259
|
+
if (!pvTotalFromDerived && sfEnabled) {
|
|
31260
|
+
const farmPv = readHistory('storageFarm.totalPvPowerW');
|
|
31261
|
+
if (farmPv !== null && typeof this._nwMergeStorageFarmPvWithBase === 'function') {
|
|
31262
|
+
const baseSourceId = String(historyDps.pvPower || historyDps.productionTotal || '').trim();
|
|
31263
|
+
const merged = this._nwMergeStorageFarmPvWithBase(pvTotal ?? 0, { now, metrics: farmMetricsHist, baseSourceId });
|
|
31264
|
+
pvTotal = baseSourceId && pvW === null ? null : Math.max(0, merged.totalW);
|
|
31265
|
+
} else if ((readHistory('storageFarm.pvSourcesTotal') ?? 0) > 0 || farmMetricsHist.pvSources?.length) {
|
|
31266
|
+
pvTotal = null;
|
|
31267
|
+
}
|
|
31216
31268
|
} else if (!pvTotalFromDerived && singleStorageDcEnabled) {
|
|
31269
|
+
const dcId = String(nwNormalizeStorageDatapointsConfig(this.config.storage).dcPvPowerObjectId || historyDps.storagePvPower || '').trim();
|
|
31270
|
+
const acId = String(historyDps.pvPower || historyDps.productionTotal || '').trim();
|
|
31217
31271
|
const dcValueW = readHistory('speicher.dcPvPowerW');
|
|
31218
|
-
if (
|
|
31219
|
-
const
|
|
31220
|
-
if (pvTotal
|
|
31221
|
-
else
|
|
31222
|
-
const pvAbs = Math.abs(pvTotal);
|
|
31223
|
-
const relDiff = Math.abs(pvAbs - dcAbs) / Math.max(1, dcAbs);
|
|
31224
|
-
pvTotal = relDiff < 0.05 ? Math.max(pvAbs, dcAbs) : (pvAbs + dcAbs);
|
|
31225
|
-
}
|
|
31272
|
+
if (dcId) {
|
|
31273
|
+
const sameSource = !!acId && nwPhysicalPvSourceKey(acId) === nwPhysicalPvSourceKey(dcId);
|
|
31274
|
+
if (sameSource) pvTotal = pvW ?? (dcValueW === null ? null : Math.abs(dcValueW));
|
|
31275
|
+
else pvTotal = dcValueW === null || (acId && pvW === null) ? null : (pvTotal ?? 0) + Math.abs(dcValueW);
|
|
31226
31276
|
}
|
|
31227
31277
|
}
|
|
31228
31278
|
|
|
31279
|
+
// The live balance explicitly rejected a partial source set. History must
|
|
31280
|
+
// not reconstruct a plausible sum from only the remaining generation meters.
|
|
31281
|
+
const canonicalPv = Object.getOwnPropertyDescriptor(this.stateCache || {}, 'derived.core.pv.totalW');
|
|
31282
|
+
if (canonicalPv && 'value' in canonicalPv && canonicalPv.value && typeof canonicalPv.value === 'object'
|
|
31283
|
+
&& Object.getOwnPropertyDescriptor(canonicalPv.value, 'value')?.value === null) pvTotal = null;
|
|
31284
|
+
|
|
31229
31285
|
// Ohne expliziten Energiefluss-Override folgt die Historie weiterhin der
|
|
31230
31286
|
// aktiven Speichertopologie. Ein vorhandener, gueltiger Override bleibt aber
|
|
31231
31287
|
// autoritativ und wird nicht durch Writer-/App-Lifecycle auf null gesetzt.
|
|
@@ -31238,7 +31294,7 @@ return res.json(out);
|
|
|
31238
31294
|
}
|
|
31239
31295
|
}
|
|
31240
31296
|
|
|
31241
|
-
let loadTotal = Number.isFinite(loadW)
|
|
31297
|
+
let loadTotal = Number.isFinite(loadW) && loadW >= 0 ? loadW : null;
|
|
31242
31298
|
const chg = Number.isFinite(chgW) ? Math.max(0, chgW) : null;
|
|
31243
31299
|
const dchg = Number.isFinite(dchgW) ? Math.max(0, dchgW) : null;
|
|
31244
31300
|
const evAbs = Number.isFinite(evW) ? Math.abs(evW) : null;
|
|
@@ -32545,23 +32601,43 @@ return res.json(out);
|
|
|
32545
32601
|
scheduleDerivedFlowUpdate(reason = '') {
|
|
32546
32602
|
if (this._nwShuttingDown) return;
|
|
32547
32603
|
// Throttle derived calculations to avoid excessive state writes on high-frequency meters.
|
|
32548
|
-
const
|
|
32549
|
-
|
|
32550
|
-
|
|
32551
|
-
|
|
32552
|
-
|
|
32553
|
-
|
|
32554
|
-
if (
|
|
32604
|
+
const flow = this._derivedFlow;
|
|
32605
|
+
flow.lastReason = reason;
|
|
32606
|
+
if (flow.running) {
|
|
32607
|
+
flow.rerun = true;
|
|
32608
|
+
return;
|
|
32609
|
+
}
|
|
32610
|
+
if (flow.pending) return;
|
|
32555
32611
|
|
|
32556
|
-
const
|
|
32557
|
-
const delay =
|
|
32612
|
+
const now = Date.now();
|
|
32613
|
+
const delay = Math.max(0, (flow.minIntervalMs ?? 250) - (now - (flow.lastRunMs ?? 0)));
|
|
32558
32614
|
|
|
32559
|
-
|
|
32560
|
-
this._nwSetTimeout(() => {
|
|
32561
|
-
|
|
32562
|
-
|
|
32563
|
-
|
|
32564
|
-
|
|
32615
|
+
flow.pending = true;
|
|
32616
|
+
this._nwSetTimeout(async () => {
|
|
32617
|
+
flow.pending = false;
|
|
32618
|
+
flow.running = true;
|
|
32619
|
+
flow.lastRunMs = Date.now();
|
|
32620
|
+
try {
|
|
32621
|
+
await this.updateDerivedFlowStates(flow.lastReason || 'scheduled');
|
|
32622
|
+
if (flow.retryTimer) this._nwClearTimeout(flow.retryTimer);
|
|
32623
|
+
flow.retryTimer = null;
|
|
32624
|
+
flow.retryDelayMs = 0;
|
|
32625
|
+
} catch (e) {
|
|
32626
|
+
this.log.debug(`[derivedFlow] ${e?.message || e}`);
|
|
32627
|
+
if (!this._nwShuttingDown && !flow.retryTimer) {
|
|
32628
|
+
flow.retryDelayMs = Math.min(30000, (flow.retryDelayMs || 500) * 2);
|
|
32629
|
+
flow.retryTimer = this._nwSetTimeout(() => {
|
|
32630
|
+
flow.retryTimer = null;
|
|
32631
|
+
this.scheduleDerivedFlowUpdate('publication-retry');
|
|
32632
|
+
}, flow.retryDelayMs);
|
|
32633
|
+
}
|
|
32634
|
+
} finally {
|
|
32635
|
+
flow.running = false;
|
|
32636
|
+
if (flow.rerun) {
|
|
32637
|
+
flow.rerun = false;
|
|
32638
|
+
this.scheduleDerivedFlowUpdate(flow.lastReason);
|
|
32639
|
+
}
|
|
32640
|
+
}
|
|
32565
32641
|
}, delay);
|
|
32566
32642
|
}
|
|
32567
32643
|
/**
|
|
@@ -32570,14 +32646,32 @@ return res.json(out);
|
|
|
32570
32646
|
* Zusammenhang: Teil von Adapterkern: Lifecycle, Webserver, API, States, EMS-Engine; Aufrufstellen und abhängige States/APIs beim Ändern mitprüfen.
|
|
32571
32647
|
* TypeScript: Parameter, Rückgabewert und verwendete Config-/State-Objekte später explizit typisieren.
|
|
32572
32648
|
*/
|
|
32649
|
+
async _nwMissingTemplatePvSource(key, id, now) {
|
|
32650
|
+
if (!id || id !== nwDefaultFlowMappings[key] || this.stateCache?.[key]) return false;
|
|
32651
|
+
// An untouched example mapping may have no ioBroker object at all. A real
|
|
32652
|
+
// meter, a previous observation, and a database error all keep it required.
|
|
32653
|
+
const previous = this._nwTemplatePvCheck;
|
|
32654
|
+
if (previous?.id === id && previous.until > now) return previous.absent;
|
|
32655
|
+
try {
|
|
32656
|
+
const object = await this.getForeignObjectAsync(id);
|
|
32657
|
+
const absent = object === null || object === undefined;
|
|
32658
|
+
this._nwTemplatePvCheck = { id, absent, until: now + 60000 };
|
|
32659
|
+
return absent && !this.stateCache?.[key];
|
|
32660
|
+
} catch { return false; }
|
|
32661
|
+
}
|
|
32662
|
+
|
|
32573
32663
|
async updateDerivedFlowStates(reason = '') {
|
|
32574
32664
|
// Building consumption can be derived from the power balance at NVP:
|
|
32575
32665
|
// load = (PV + other production) + gridImport + batteryDischarge - gridExport - batteryCharge
|
|
32576
32666
|
// If no direct house meter (consumptionTotal) is configured, we use this as fallback for the UI.
|
|
32577
32667
|
|
|
32668
|
+
// Take the measurement snapshot after asynchronous inventory/metadata reads.
|
|
32669
|
+
await this._derivedRefreshPvInvertersCache(false);
|
|
32670
|
+
const pvMeterKey = this._nwHasMappedDatapoint('pvPower') ? 'pvPower' : 'productionTotal';
|
|
32671
|
+
const pvMeterId = String(this.config?.datapoints?.[pvMeterKey] || '').trim();
|
|
32672
|
+
const missingTemplatePv = await this._nwMissingTemplatePvSource(pvMeterKey, pvMeterId, Date.now());
|
|
32578
32673
|
const ts = Date.now();
|
|
32579
|
-
const
|
|
32580
|
-
const liveMaxAgeMs = Math.max(10000, (configuredAgeSec !== null && configuredAgeSec > 0 ? configuredAgeSec : 60) * 1000);
|
|
32674
|
+
const liveMaxAgeMs = this._nwLiveInputMaxAgeMs();
|
|
32581
32675
|
const inputTimes = [];
|
|
32582
32676
|
const pvTimes = [];
|
|
32583
32677
|
const producerTimes = [];
|
|
@@ -32590,23 +32684,19 @@ return res.json(out);
|
|
|
32590
32684
|
};
|
|
32591
32685
|
const oldestTime = (times) => times.length ? Math.min(...times) : ts;
|
|
32592
32686
|
|
|
32593
|
-
// Keep PV-inverter auto-cache reasonably fresh (cheap no-op when not due)
|
|
32594
|
-
await this._derivedRefreshPvInvertersCache(false);
|
|
32595
|
-
|
|
32596
32687
|
const pvPowerMapped = this._nwHasMappedDatapoint('pvPower');
|
|
32597
32688
|
const prodTotalMapped = this._nwHasMappedDatapoint('productionTotal');
|
|
32598
32689
|
const consumptionMapped = this._nwHasMappedDatapoint('consumptionTotal');
|
|
32599
32690
|
|
|
32600
32691
|
// --- Grid ---
|
|
32601
32692
|
const {
|
|
32602
|
-
gridBuyRaw,
|
|
32603
|
-
gridSellRaw,
|
|
32604
32693
|
gridNetRaw,
|
|
32605
32694
|
gridBuyW,
|
|
32606
32695
|
gridSellW,
|
|
32607
32696
|
hasGrid,
|
|
32608
32697
|
src: gridSrc,
|
|
32609
|
-
|
|
32698
|
+
observedAt: gridObservedAt,
|
|
32699
|
+
} = this._nwResolveGridImportExportFromCache({ now: ts, maxAgeMs: liveMaxAgeMs, observe: true });
|
|
32610
32700
|
|
|
32611
32701
|
// --- Storage ---
|
|
32612
32702
|
// Normalize storage power centrally:
|
|
@@ -32614,7 +32704,7 @@ return res.json(out);
|
|
|
32614
32704
|
// settings.flowInvertBattery flips that signed value before splitting.
|
|
32615
32705
|
// Separate charge/discharge datapoints remain supported, but stale/legacy mirrored
|
|
32616
32706
|
// values must not make the UI or derived balance show both directions at once.
|
|
32617
|
-
const storageFlow = this._nwResolveBatteryFlowFromCache({ now: ts, strictStale: true, maxAgeMs: liveMaxAgeMs });
|
|
32707
|
+
const storageFlow = this._nwResolveBatteryFlowFromCache({ now: ts, strictStale: true, maxAgeMs: liveMaxAgeMs, observe: true });
|
|
32618
32708
|
const chargeW = Math.max(0, Number(storageFlow.chargeW) || 0);
|
|
32619
32709
|
const dischargeW = Math.max(0, Number(storageFlow.dischargeW) || 0);
|
|
32620
32710
|
const storageSrc = storageFlow.src || 'missing';
|
|
@@ -32671,9 +32761,7 @@ return res.json(out);
|
|
|
32671
32761
|
} else {
|
|
32672
32762
|
// Auto: sum all PV_INVERTER devices from nexowatt-devices
|
|
32673
32763
|
const pvAuto = this._derivedFlow?.auto?.pvInverters;
|
|
32674
|
-
|
|
32675
|
-
const staleMs = Math.max(10 * 1000, (Number.isFinite(staleSec) ? staleSec : 60) * 1000);
|
|
32676
|
-
|
|
32764
|
+
pvBaseSourceIds = [];
|
|
32677
32765
|
let sum = 0;
|
|
32678
32766
|
let used = 0;
|
|
32679
32767
|
let offline = 0;
|
|
@@ -32685,7 +32773,7 @@ return res.json(out);
|
|
|
32685
32773
|
|
|
32686
32774
|
const connected = (cRec && cRec.val !== undefined) ? !!cRec.val : true;
|
|
32687
32775
|
const isOffline = (oRec && oRec.val !== undefined) ? !!oRec.val : false;
|
|
32688
|
-
const ageOk = (pRec && Number.isFinite(Number(pRec.ts))) ? ((ts - Number(pRec.ts)) <=
|
|
32776
|
+
const ageOk = (pRec && Number.isFinite(Number(pRec.ts))) ? ((ts - Number(pRec.ts)) <= liveMaxAgeMs) : false;
|
|
32689
32777
|
|
|
32690
32778
|
if (!connected || isOffline || !ageOk || (pRec?.q !== undefined && pRec.q !== 0)) {
|
|
32691
32779
|
offline++;
|
|
@@ -32734,8 +32822,24 @@ return res.json(out);
|
|
|
32734
32822
|
let pvDcIncluded = false;
|
|
32735
32823
|
let pvFarmMerge = null;
|
|
32736
32824
|
let pvTotalW = pvAcW;
|
|
32825
|
+
const siteMeterExpected = (pvPowerMapped || prodTotalMapped) && (!missingTemplatePv || !!this.stateCache?.[pvMeterKey]);
|
|
32826
|
+
const sitePvExpected = siteMeterExpected || !!this._derivedFlow?.auto?.pvInverters?.list?.length;
|
|
32827
|
+
const siteKey = nwPhysicalPvSourceKey(pvMeterId) || pvMeterId.toLowerCase();
|
|
32828
|
+
// A collection of other inverters cannot prove the output of a failed site meter.
|
|
32829
|
+
const sitePvValid = pvSource !== 'missing' && !pvSource.includes('incomplete')
|
|
32830
|
+
&& (!siteMeterExpected || pvAcRaw !== null || pvBaseSourceIds.some(id => (nwPhysicalPvSourceKey(id) || id.toLowerCase()) === siteKey));
|
|
32831
|
+
let pvObserved = sitePvValid || (!sitePvExpected && !missingTemplatePv);
|
|
32737
32832
|
|
|
32738
32833
|
if (sfEnabled && typeof this._nwMergeStorageFarmPvWithBase === 'function') {
|
|
32834
|
+
const farmPvExpected = (this._nwGetNumberFromCache('storageFarm.pvSourcesTotal') ?? 0) > 0 || !!farmMetrics.pvSources?.length;
|
|
32835
|
+
const farmPvSample = farmPvExpected ? readLive('storageFarm.totalPvPowerW', pvTimes) : null;
|
|
32836
|
+
const farmPvValid = farmPvSample !== null;
|
|
32837
|
+
if (farmPvExpected) {
|
|
32838
|
+
const farmCoversSite = siteMeterExpected && !this._derivedFlow?.auto?.pvInverters?.list?.length
|
|
32839
|
+
&& farmMetrics.pvSources?.some(row => row.online === true && (nwPhysicalPvSourceKey(row.id) || String(row.id).toLowerCase()) === siteKey);
|
|
32840
|
+
pvObserved = (!sitePvExpected || sitePvValid || farmCoversSite) && farmPvValid;
|
|
32841
|
+
if ((!sitePvExpected || farmCoversSite) && farmPvValid) pvSource = 'farm:pv-sources';
|
|
32842
|
+
}
|
|
32739
32843
|
pvFarmMerge = this._nwMergeStorageFarmPvWithBase(pvAcW, {
|
|
32740
32844
|
now: ts,
|
|
32741
32845
|
metrics: farmMetrics,
|
|
@@ -32750,24 +32854,30 @@ return res.json(out);
|
|
|
32750
32854
|
if (pvFarmMerge.farmFallbackUsed && pvSource === 'missing') pvSource = 'farm:pv-sources';
|
|
32751
32855
|
else if (pvFarmMerge.farmAddedW > 0) pvSource = pvSource === 'missing' ? 'farm:pv-sources' : `${pvSource}+farm`;
|
|
32752
32856
|
} else if (singleStorageDcEnabled) {
|
|
32753
|
-
const
|
|
32754
|
-
|
|
32755
|
-
|
|
32756
|
-
|
|
32757
|
-
|
|
32758
|
-
|
|
32759
|
-
|
|
32760
|
-
|
|
32761
|
-
|
|
32762
|
-
|
|
32763
|
-
if (pvSource === 'missing') pvSource = pvDcSource;
|
|
32857
|
+
const dcId = String(nwNormalizeStorageDatapointsConfig(this.config.storage).dcPvPowerObjectId
|
|
32858
|
+
|| this._nwStorageMeasurementFallback?.datapoints?.dcPvPowerObjectId
|
|
32859
|
+
|| this._nwStorageMeasurementFallback?.dcPvPowerObjectId || this.config.datapoints?.storagePvPower || '').trim();
|
|
32860
|
+
if (dcId) {
|
|
32861
|
+
const dcKey = nwPhysicalPvSourceKey(dcId) || dcId.toLowerCase();
|
|
32862
|
+
const duplicate = pvBaseSourceIds.some(id => (nwPhysicalPvSourceKey(id) || id.toLowerCase()) === dcKey);
|
|
32863
|
+
const dcCoversMissingSite = dcKey === siteKey && !this._derivedFlow?.auto?.pvInverters?.list?.length;
|
|
32864
|
+
const dc = readLive('speicher.dcPvPowerW', pvTimes);
|
|
32865
|
+
if (dc === null) {
|
|
32866
|
+
if (!duplicate || !sitePvValid) pvObserved = false;
|
|
32764
32867
|
} else {
|
|
32765
|
-
|
|
32766
|
-
|
|
32767
|
-
|
|
32768
|
-
pvTotalW =
|
|
32868
|
+
pvDcW = Math.abs(dc);
|
|
32869
|
+
pvDcSource = 'storage:dc';
|
|
32870
|
+
if (duplicate && sitePvValid) {
|
|
32871
|
+
pvTotalW = pvAcW;
|
|
32872
|
+
} else {
|
|
32769
32873
|
pvDcIncluded = true;
|
|
32874
|
+
pvTotalW = pvAcW + pvDcW;
|
|
32875
|
+
if (!sitePvValid && (!sitePvExpected || dcCoversMissingSite)) {
|
|
32876
|
+
pvObserved = true;
|
|
32877
|
+
pvSource = pvDcSource;
|
|
32878
|
+
}
|
|
32770
32879
|
}
|
|
32880
|
+
pvBaseSourceIds.push(dcId);
|
|
32771
32881
|
}
|
|
32772
32882
|
}
|
|
32773
32883
|
}
|
|
@@ -32832,33 +32942,13 @@ return res.json(out);
|
|
|
32832
32942
|
|
|
32833
32943
|
// A balance is usable only with all configured contributors observed.
|
|
32834
32944
|
// Never refresh an old measurement through this periodic calculation.
|
|
32835
|
-
|
|
32836
|
-
if (
|
|
32837
|
-
if (gridSrc === 'net-fresh') gridObserved = readLive('gridPointPower', gridTimes) !== null;
|
|
32838
|
-
else if (String(gridSrc).startsWith('split-')) {
|
|
32839
|
-
const buyRequired = this._nwHasMappedDatapoint('gridBuyPower');
|
|
32840
|
-
const sellRequired = this._nwHasMappedDatapoint('gridSellPower');
|
|
32841
|
-
const buy = buyRequired ? readLive('gridBuyPower', gridTimes) : 0;
|
|
32842
|
-
const sell = sellRequired ? readLive('gridSellPower', gridTimes) : 0;
|
|
32843
|
-
gridObserved = (buyRequired || sellRequired) && buy !== null && sell !== null;
|
|
32844
|
-
} else gridObserved = readLive('ems.gridPowerRawW', gridTimes) !== null;
|
|
32845
|
-
}
|
|
32945
|
+
const gridObserved = hasGrid && Number.isFinite(gridObservedAt);
|
|
32946
|
+
if (gridObserved) gridTimes.push(gridObservedAt);
|
|
32846
32947
|
const storageConfigured = selectedStorageTopologyLive !== 'none'
|
|
32847
32948
|
|| ['batteryPower', 'storageChargePower', 'storageDischargePower', 'storageSoc'].some(key => this._nwHasMappedDatapoint(key));
|
|
32848
|
-
|
|
32849
|
-
|
|
32850
|
-
|
|
32851
|
-
} else if (storageSrc === 'batterySigned') storageObserved = readLive('batteryPower', storageTimes) !== null;
|
|
32852
|
-
else if (storageSrc === 'sameChargeDischargeSigned') storageObserved = readLive('storageChargePower', storageTimes) !== null;
|
|
32853
|
-
else if (String(storageSrc).startsWith('chargeDischarge')) {
|
|
32854
|
-
storageObserved = ['storageChargePower', 'storageDischargePower'].every(key => !this._nwHasMappedDatapoint(key) || readLive(key, storageTimes) !== null);
|
|
32855
|
-
}
|
|
32856
|
-
const autoPvConfigured = (this._derivedFlow?.auto?.pvInverters?.list || []).length > 0;
|
|
32857
|
-
const pvConfigured = pvPowerMapped || prodTotalMapped || autoPvConfigured || sfEnabled || singleStorageDcEnabled;
|
|
32858
|
-
let pvObserved = !pvConfigured || (pvSource !== 'missing' && !pvSource.includes('incomplete'));
|
|
32859
|
-
if (sfEnabled && (pvFarmMerge?.farmAddedW > 0 || pvFarmMerge?.farmFallbackUsed)) {
|
|
32860
|
-
pvObserved = pvObserved && readLive('storageFarm.totalPvPowerW', pvTimes) !== null;
|
|
32861
|
-
}
|
|
32949
|
+
const measuredStorage = Number.isFinite(storageFlow.observedAt);
|
|
32950
|
+
const storageObserved = measuredStorage || !storageConfigured;
|
|
32951
|
+
if (measuredStorage) storageTimes.push(storageFlow.observedAt);
|
|
32862
32952
|
inputTimes.push(...pvTimes, ...producerTimes, ...gridTimes, ...storageTimes);
|
|
32863
32953
|
const balanceObserved = gridObserved && storageObserved && pvObserved && !missingProducer;
|
|
32864
32954
|
const loadTotalW = directLoadTotalW !== null ? directLoadTotalW
|
|
@@ -32893,6 +32983,9 @@ return res.json(out);
|
|
|
32893
32983
|
const loadTotalRound = loadTotalW !== null ? Math.round(loadTotalW) : null;
|
|
32894
32984
|
const loadRestRound = loadRestW !== null ? Math.round(loadRestW) : null;
|
|
32895
32985
|
const restTimestamp = Math.min(loadTimestamp, oldestTime(restTimes));
|
|
32986
|
+
this._derivedFlow.reviewAt = inputTimes.length || directTimes.length || restTimes.length
|
|
32987
|
+
? Math.min(oldestTime(inputTimes), oldestTime(directTimes), oldestTime(restTimes)) + liveMaxAgeMs + 1
|
|
32988
|
+
: 0;
|
|
32896
32989
|
|
|
32897
32990
|
const tsShadow = this._nwRunEnergyFlowTsShadowComparison({
|
|
32898
32991
|
ts,
|
|
@@ -32963,38 +33056,35 @@ return res.json(out);
|
|
|
32963
33056
|
: 'js-runtime';
|
|
32964
33057
|
const energyFlowProductiveTsActive = energyFlowSourceState === 'ts-candidate' || energyFlowSourceState === 'ts-normal';
|
|
32965
33058
|
const energyFlowLiveTestState = this._nwEnergyFlowTsLiveTestStateFromSwitch(effectiveEnergyFlow.switchState || {});
|
|
32966
|
-
const tsSwitchJsonText = JSON.stringify(effectiveEnergyFlow.switchState || {});
|
|
32967
|
-
const tsCandidateJsonText = JSON.stringify(effectiveEnergyFlow.candidate || {});
|
|
32968
|
-
const tsFixedSourceJsonText = JSON.stringify((effectiveEnergyFlow.switchState && effectiveEnergyFlow.switchState.fixedSourceState) || {});
|
|
32969
33059
|
try {
|
|
32970
33060
|
if (this._derivedFlow?.last?.energyFlowSource !== energyFlowSourceState) {
|
|
32971
|
-
this._derivedFlow.last.energyFlowSource = energyFlowSourceState;
|
|
32972
33061
|
await this.setStateAsync('derived.core.building.energyFlowSource', { val: energyFlowSourceState, ack: true });
|
|
33062
|
+
this._derivedFlow.last.energyFlowSource = energyFlowSourceState;
|
|
32973
33063
|
}
|
|
32974
33064
|
if (this._derivedFlow?.last?.tsLiveTestState !== energyFlowLiveTestState) {
|
|
32975
|
-
this._derivedFlow.last.tsLiveTestState = energyFlowLiveTestState;
|
|
32976
33065
|
await this.setStateAsync('derived.core.building.tsLiveTestState', { val: energyFlowLiveTestState, ack: true });
|
|
33066
|
+
this._derivedFlow.last.tsLiveTestState = energyFlowLiveTestState;
|
|
32977
33067
|
}
|
|
32978
33068
|
if (this._derivedFlow?.last?.tsProductiveActive !== energyFlowProductiveTsActive) {
|
|
32979
|
-
this._derivedFlow.last.tsProductiveActive = energyFlowProductiveTsActive;
|
|
32980
33069
|
await this.setStateAsync('derived.core.building.tsProductiveActive', { val: energyFlowProductiveTsActive, ack: true });
|
|
33070
|
+
this._derivedFlow.last.tsProductiveActive = energyFlowProductiveTsActive;
|
|
32981
33071
|
}
|
|
32982
33072
|
} catch (_eTsLiveState) {}
|
|
32983
33073
|
|
|
32984
33074
|
// --- Update adapter states (for App-Center mapping / debugging) ---
|
|
32985
33075
|
if (this._derivedFlow?.last?.loadTotalW !== publishLoadTotalRound || this._derivedFlow?.last?.loadTimestamp !== loadTimestamp) {
|
|
33076
|
+
await this.setStateAsync('derived.core.building.loadTotalW', { val: publishLoadTotalRound, ack: true, ts: loadTimestamp });
|
|
32986
33077
|
this._derivedFlow.last.loadTimestamp = loadTimestamp;
|
|
32987
33078
|
this._derivedFlow.last.loadTotalW = publishLoadTotalRound;
|
|
32988
|
-
await this.setStateAsync('derived.core.building.loadTotalW', { val: publishLoadTotalRound, ack: true, ts: loadTimestamp });
|
|
32989
33079
|
}
|
|
32990
33080
|
if (this._derivedFlow?.last?.loadRestW !== publishLoadRestRound || this._derivedFlow?.last?.restTimestamp !== restTimestamp) {
|
|
33081
|
+
await this.setStateAsync('derived.core.building.loadRestW', { val: publishLoadRestRound, ack: true, ts: restTimestamp });
|
|
32991
33082
|
this._derivedFlow.last.restTimestamp = restTimestamp;
|
|
32992
33083
|
this._derivedFlow.last.loadRestW = publishLoadRestRound;
|
|
32993
|
-
await this.setStateAsync('derived.core.building.loadRestW', { val: publishLoadRestRound, ack: true, ts: restTimestamp });
|
|
32994
33084
|
}
|
|
32995
33085
|
if (this._derivedFlow?.last?.loadSource !== loadTotalSource) {
|
|
32996
|
-
this._derivedFlow.last.loadSource = loadTotalSource;
|
|
32997
33086
|
await this.setStateAsync('derived.core.building.loadSource', { val: loadTotalSource, ack: true });
|
|
33087
|
+
this._derivedFlow.last.loadSource = loadTotalSource;
|
|
32998
33088
|
}
|
|
32999
33089
|
|
|
33000
33090
|
const pvAcRound = Math.round(pvAcW);
|
|
@@ -33003,27 +33093,27 @@ return res.json(out);
|
|
|
33003
33093
|
|
|
33004
33094
|
const publishPvAcW = pvObserved ? pvAcRound : null;
|
|
33005
33095
|
if (this._derivedFlow?.last?.pvAcW !== publishPvAcW || this._derivedFlow?.last?.pvTimestamp !== oldestTime(pvTimes)) {
|
|
33006
|
-
this._derivedFlow.last.pvAcW = publishPvAcW;
|
|
33007
33096
|
await this.setStateAsync('derived.core.pv.acW', { val: publishPvAcW, ack: true, ts: oldestTime(pvTimes) });
|
|
33097
|
+
this._derivedFlow.last.pvAcW = publishPvAcW;
|
|
33008
33098
|
}
|
|
33009
33099
|
const publishPvDcW = pvObserved ? pvDcRound : null;
|
|
33010
33100
|
if (this._derivedFlow?.last?.pvDcW !== publishPvDcW || this._derivedFlow?.last?.pvTimestamp !== oldestTime(pvTimes)) {
|
|
33011
|
-
this._derivedFlow.last.pvDcW = publishPvDcW;
|
|
33012
33101
|
await this.setStateAsync('derived.core.pv.dcW', { val: publishPvDcW, ack: true, ts: oldestTime(pvTimes) });
|
|
33102
|
+
this._derivedFlow.last.pvDcW = publishPvDcW;
|
|
33013
33103
|
}
|
|
33014
33104
|
const publishPvTotalW = pvObserved ? pvTotalRound : null;
|
|
33015
33105
|
if (this._derivedFlow?.last?.pvTotalW !== publishPvTotalW || this._derivedFlow?.last?.pvTimestamp !== oldestTime(pvTimes)) {
|
|
33016
|
-
this._derivedFlow.last.pvTotalW = publishPvTotalW;
|
|
33017
33106
|
await this.setStateAsync('derived.core.pv.totalW', { val: publishPvTotalW, ack: true, ts: oldestTime(pvTimes) });
|
|
33107
|
+
this._derivedFlow.last.pvTotalW = publishPvTotalW;
|
|
33018
33108
|
}
|
|
33019
33109
|
|
|
33020
33110
|
this._derivedFlow.last.pvTimestamp = oldestTime(pvTimes);
|
|
33021
33111
|
const publishExtraW = missingProducer ? null : Math.round(producerSumW);
|
|
33022
33112
|
const producerTimestamp = oldestTime(producerTimes);
|
|
33023
33113
|
if (this._derivedFlow.last.extraProductionW !== publishExtraW || this._derivedFlow.last.extraTimestamp !== producerTimestamp) {
|
|
33114
|
+
await this.setStateAsync('derived.core.production.extraW', { val: publishExtraW, ack: true, ts: producerTimestamp });
|
|
33024
33115
|
this._derivedFlow.last.extraProductionW = publishExtraW;
|
|
33025
33116
|
this._derivedFlow.last.extraTimestamp = producerTimestamp;
|
|
33026
|
-
await this.setStateAsync('derived.core.production.extraW', { val: publishExtraW, ack: true, ts: producerTimestamp });
|
|
33027
33117
|
}
|
|
33028
33118
|
this.updateValue('derived.core.production.extraW', publishExtraW, producerTimestamp, { raw: false });
|
|
33029
33119
|
|
|
@@ -33031,24 +33121,24 @@ return res.json(out);
|
|
|
33031
33121
|
const pvCapacityLimitRound = Math.round(pvPlausibility.capacityLimitW);
|
|
33032
33122
|
const pvDuplicateSuppressedRound = Math.round(pvDuplicateSuppressedW);
|
|
33033
33123
|
if (this._derivedFlow?.last?.pvRawTotalW !== pvRawTotalRound) {
|
|
33034
|
-
this._derivedFlow.last.pvRawTotalW = pvRawTotalRound;
|
|
33035
33124
|
await this.setStateAsync('derived.core.pv.rawTotalW', { val: pvRawTotalRound, ack: true });
|
|
33125
|
+
this._derivedFlow.last.pvRawTotalW = pvRawTotalRound;
|
|
33036
33126
|
}
|
|
33037
33127
|
if (this._derivedFlow?.last?.pvCapacityLimitW !== pvCapacityLimitRound) {
|
|
33038
|
-
this._derivedFlow.last.pvCapacityLimitW = pvCapacityLimitRound;
|
|
33039
33128
|
await this.setStateAsync('derived.core.pv.capacityLimitW', { val: pvCapacityLimitRound, ack: true });
|
|
33129
|
+
this._derivedFlow.last.pvCapacityLimitW = pvCapacityLimitRound;
|
|
33040
33130
|
}
|
|
33041
33131
|
if (this._derivedFlow?.last?.pvDuplicateSuppressedW !== pvDuplicateSuppressedRound) {
|
|
33042
|
-
this._derivedFlow.last.pvDuplicateSuppressedW = pvDuplicateSuppressedRound;
|
|
33043
33132
|
await this.setStateAsync('derived.core.pv.duplicateSuppressedW', { val: pvDuplicateSuppressedRound, ack: true });
|
|
33133
|
+
this._derivedFlow.last.pvDuplicateSuppressedW = pvDuplicateSuppressedRound;
|
|
33044
33134
|
}
|
|
33045
33135
|
if (this._derivedFlow?.last?.pvPlausibilityCapped !== pvPlausibility.capped) {
|
|
33046
|
-
this._derivedFlow.last.pvPlausibilityCapped = pvPlausibility.capped;
|
|
33047
33136
|
await this.setStateAsync('derived.core.pv.plausibilityCapped', { val: !!pvPlausibility.capped, ack: true });
|
|
33137
|
+
this._derivedFlow.last.pvPlausibilityCapped = pvPlausibility.capped;
|
|
33048
33138
|
}
|
|
33049
33139
|
if (this._derivedFlow?.last?.pvSource !== pvSource) {
|
|
33050
|
-
this._derivedFlow.last.pvSource = pvSource;
|
|
33051
33140
|
await this.setStateAsync('derived.core.pv.source', { val: pvSource, ack: true });
|
|
33141
|
+
this._derivedFlow.last.pvSource = pvSource;
|
|
33052
33142
|
}
|
|
33053
33143
|
|
|
33054
33144
|
// Die abgeleiteten Kernwerte werden zusätzlich in den API-/SSE-Cache gespiegelt.
|
|
@@ -33057,6 +33147,8 @@ return res.json(out);
|
|
|
33057
33147
|
this.updateValue('derived.core.building.loadTotalW', publishLoadTotalRound, loadTimestamp, { raw: false });
|
|
33058
33148
|
this.updateValue('derived.core.building.loadRestW', publishLoadRestRound, restTimestamp, { raw: false });
|
|
33059
33149
|
this.updateValue('derived.core.building.loadSource', loadTotalSource, ts, { raw: false });
|
|
33150
|
+
this.updateValue('derived.core.grid.netW', gridObserved ? gridNetRaw : null, gridObservedAt ?? ts, { raw: false });
|
|
33151
|
+
this.updateValue('derived.core.storage.netW', measuredStorage ? dischargeW - chargeW : null, storageFlow.observedAt ?? ts, { raw: false });
|
|
33060
33152
|
this.updateValue('derived.core.pv.acW', pvObserved ? pvAcRound : null, oldestTime(pvTimes), { raw: false });
|
|
33061
33153
|
this.updateValue('derived.core.pv.dcW', pvObserved ? pvDcRound : null, oldestTime(pvTimes), { raw: false });
|
|
33062
33154
|
this.updateValue('derived.core.pv.totalW', pvObserved ? pvTotalRound : null, oldestTime(pvTimes), { raw: false });
|
|
@@ -33078,8 +33170,8 @@ return res.json(out);
|
|
|
33078
33170
|
this.updateValue('derived.core.building.quality', quality, ts, { raw: false });
|
|
33079
33171
|
|
|
33080
33172
|
if (this._derivedFlow?.last?.quality !== quality) {
|
|
33081
|
-
this._derivedFlow.last.quality = quality;
|
|
33082
33173
|
await this.setStateAsync('derived.core.building.quality', { val: quality, ack: true });
|
|
33174
|
+
this._derivedFlow.last.quality = quality;
|
|
33083
33175
|
}
|
|
33084
33176
|
|
|
33085
33177
|
// Diagnostics payload (throttled)
|
|
@@ -33088,7 +33180,6 @@ return res.json(out);
|
|
|
33088
33180
|
const lastDiag = Number(this._derivedFlow?.diagLastMs) || 0;
|
|
33089
33181
|
if (!this._derivedFlow) this._derivedFlow = {};
|
|
33090
33182
|
if ((ts - lastDiag) >= diagEveryMs) {
|
|
33091
|
-
this._derivedFlow.diagLastMs = ts;
|
|
33092
33183
|
const payload = {
|
|
33093
33184
|
ts,
|
|
33094
33185
|
reason,
|
|
@@ -33154,9 +33245,13 @@ return res.json(out);
|
|
|
33154
33245
|
const json = JSON.stringify(payload);
|
|
33155
33246
|
await this.setStateAsync('derived.core.building.inputsJson', { val: json, ack: true });
|
|
33156
33247
|
this.updateValue('derived.core.building.inputsJson', json, ts, { raw: false });
|
|
33248
|
+
const tsSwitchJsonText = JSON.stringify(effectiveEnergyFlow.switchState || {});
|
|
33249
|
+
const tsCandidateJsonText = JSON.stringify(effectiveEnergyFlow.candidate || {});
|
|
33250
|
+
const tsFixedSourceJsonText = JSON.stringify((effectiveEnergyFlow.switchState && effectiveEnergyFlow.switchState.fixedSourceState) || {});
|
|
33157
33251
|
await this.setStateAsync('derived.core.building.tsSwitchJson', { val: tsSwitchJsonText, ack: true });
|
|
33158
33252
|
await this.setStateAsync('derived.core.building.tsCandidateJson', { val: tsCandidateJsonText, ack: true });
|
|
33159
33253
|
await this.setStateAsync('derived.core.building.tsFixedSourceJson', { val: tsFixedSourceJsonText, ack: true });
|
|
33254
|
+
this._derivedFlow.diagLastMs = ts;
|
|
33160
33255
|
}
|
|
33161
33256
|
} catch (_e) {}
|
|
33162
33257
|
|
|
@@ -33165,13 +33260,13 @@ return res.json(out);
|
|
|
33165
33260
|
// derive them from the signed NVP datapoint (Import + / Export -).
|
|
33166
33261
|
const gridBuyMapped = this._nwHasMappedDatapoint('gridBuyPower');
|
|
33167
33262
|
const gridSellMapped = this._nwHasMappedDatapoint('gridSellPower');
|
|
33168
|
-
if (gridObserved && gridNetRaw !== null &&
|
|
33263
|
+
if (gridObserved && gridNetRaw !== null && !gridBuyMapped) {
|
|
33169
33264
|
const cur = Number(this.stateCache?.gridBuyPower?.value);
|
|
33170
33265
|
if (!Number.isFinite(cur) || cur !== gridBuyRound || this.stateCache?.gridBuyPower?.ts !== oldestTime(gridTimes)) {
|
|
33171
33266
|
this.updateValue('gridBuyPower', publishGridBuyRound, oldestTime(gridTimes), { raw: false });
|
|
33172
33267
|
}
|
|
33173
33268
|
}
|
|
33174
|
-
if (gridObserved && gridNetRaw !== null &&
|
|
33269
|
+
if (gridObserved && gridNetRaw !== null && !gridSellMapped) {
|
|
33175
33270
|
const cur = Number(this.stateCache?.gridSellPower?.value);
|
|
33176
33271
|
if (!Number.isFinite(cur) || cur !== gridSellRound || this.stateCache?.gridSellPower?.ts !== oldestTime(gridTimes)) {
|
|
33177
33272
|
this.updateValue('gridSellPower', publishGridSellRound, oldestTime(gridTimes), { raw: false });
|
|
@@ -34214,18 +34309,20 @@ return res.json(out);
|
|
|
34214
34309
|
|
|
34215
34310
|
this.stateCache[key] = { value, ts, ...(opts.q !== undefined ? { q: opts.q } : {}) };
|
|
34216
34311
|
|
|
34217
|
-
|
|
34312
|
+
// Allocate one patch per delivery batch, and none while no dashboard is listening.
|
|
34313
|
+
const payload = this.sseClients?.size ? (this._ssePendingPayload ??= Object.create(null)) : null;
|
|
34314
|
+
if (payload) payload[key] = this.stateCache[key];
|
|
34218
34315
|
|
|
34219
34316
|
// derived EVCS aggregates
|
|
34220
34317
|
try {
|
|
34221
34318
|
if (/^evcs\.\d+\.powerW$/.test(key)) {
|
|
34222
34319
|
const count = Math.max(0, Math.round(Number(this.evcsCount || 0) || 0));
|
|
34223
|
-
const maxAgeMs =
|
|
34320
|
+
const maxAgeMs = this._nwLiveInputMaxAgeMs();
|
|
34224
34321
|
const keys = Array.from({ length: Math.min(count, 1024) }, (_, index) => `evcs.${index + 1}.powerW`);
|
|
34225
34322
|
const observation = sumFlowMeasurements(this.stateCache, keys, Date.now(), maxAgeMs);
|
|
34226
34323
|
const aggregate = observation || { value: null, ts: Date.now() };
|
|
34227
34324
|
this.stateCache['evcs.totalPowerW'] = aggregate;
|
|
34228
|
-
payload['evcs.totalPowerW'] = aggregate;
|
|
34325
|
+
if (payload) payload['evcs.totalPowerW'] = aggregate;
|
|
34229
34326
|
this.setStateAsync('evcs.totalPowerW', { val: aggregate.value, ts: aggregate.ts, ack: true }).catch(() => {});
|
|
34230
34327
|
}
|
|
34231
34328
|
|
|
@@ -34244,14 +34341,14 @@ return res.json(out);
|
|
|
34244
34341
|
base = total;
|
|
34245
34342
|
this.stateCache[baseD] = { value: baseDate, ts };
|
|
34246
34343
|
this.stateCache[baseK] = { value: base, ts };
|
|
34247
|
-
payload[baseD] = this.stateCache[baseD];
|
|
34248
|
-
payload[baseK] = this.stateCache[baseK];
|
|
34344
|
+
if (payload) payload[baseD] = this.stateCache[baseD];
|
|
34345
|
+
if (payload) payload[baseK] = this.stateCache[baseK];
|
|
34249
34346
|
this.setStateAsync(baseD, baseDate, true).catch(()=>{});
|
|
34250
34347
|
this.setStateAsync(baseK, base, true).catch(()=>{});
|
|
34251
34348
|
}
|
|
34252
34349
|
const dayKwh = Math.max(0, total - base);
|
|
34253
34350
|
this.stateCache[`evcs.${idx}.energyDayKwh`] = { value: dayKwh, ts };
|
|
34254
|
-
payload[`evcs.${idx}.energyDayKwh`] = this.stateCache[`evcs.${idx}.energyDayKwh`];
|
|
34351
|
+
if (payload) payload[`evcs.${idx}.energyDayKwh`] = this.stateCache[`evcs.${idx}.energyDayKwh`];
|
|
34255
34352
|
this.setStateAsync(`evcs.${idx}.energyDayKwh`, dayKwh, true).catch(()=>{});
|
|
34256
34353
|
}
|
|
34257
34354
|
} catch(_e) {}
|
|
@@ -34261,14 +34358,15 @@ return res.json(out);
|
|
|
34261
34358
|
|
|
34262
34359
|
// Derived / calculated live values (e.g. building consumption fallback for UI)
|
|
34263
34360
|
try {
|
|
34264
|
-
const isTrigger =
|
|
34361
|
+
const isTrigger = key === 'speicher.dcPvPowerW' || key.startsWith('storageFarm.') || (opts.raw !== false && (
|
|
34265
34362
|
key === 'gridBuyPower' || key === 'gridSellPower' || key === 'gridPointPower' ||
|
|
34266
34363
|
key === 'pvPower' || key === 'productionTotal' ||
|
|
34267
34364
|
key === 'storageChargePower' || key === 'storageDischargePower' || key === 'batteryPower' ||
|
|
34268
|
-
key === '
|
|
34365
|
+
key === 'consumptionTotal' || key === 'consumptionEvcs' ||
|
|
34366
|
+
key === 'settings.flowInvertBattery' || key === 'settings.flowInvertGrid' || key === 'settings.deviceStaleTimeoutSec' ||
|
|
34269
34367
|
/^producer\d+Power$/.test(key) || /^consumer\d+Power$/.test(key) ||
|
|
34270
|
-
/^evcs\.\d+\.powerW$/.test(key) || key === 'evcs.totalPowerW'
|
|
34271
|
-
|
|
34368
|
+
/^evcs\.\d+\.powerW$/.test(key) || key === 'evcs.totalPowerW'
|
|
34369
|
+
));
|
|
34272
34370
|
if (isTrigger) this.scheduleDerivedFlowUpdate(`key:${key}`);
|
|
34273
34371
|
} catch (_e3) {}
|
|
34274
34372
|
|
|
@@ -34277,18 +34375,15 @@ return res.json(out);
|
|
|
34277
34375
|
// RC88_SSE_IDLE_ZERO_ALLOCATION: without connected dashboards there is
|
|
34278
34376
|
// nothing to batch or serialize. Avoid a permanent 120-ms timer/allocation
|
|
34279
34377
|
// chain on headless customer systems.
|
|
34280
|
-
if (!
|
|
34281
|
-
this._ssePendingPayload =
|
|
34378
|
+
if (!payload) {
|
|
34379
|
+
this._ssePendingPayload = null;
|
|
34282
34380
|
return;
|
|
34283
34381
|
}
|
|
34284
|
-
if (!this._ssePendingPayload) this._ssePendingPayload = {};
|
|
34285
|
-
Object.assign(this._ssePendingPayload, payload);
|
|
34286
|
-
|
|
34287
34382
|
if (!this._sseFlushTimer) {
|
|
34288
34383
|
const batchMs = (this.config && Number(this.config.sseBatchMs)) || 120;
|
|
34289
34384
|
this._sseFlushTimer = this._nwSetTimeout(() => {
|
|
34290
|
-
const p = this._ssePendingPayload
|
|
34291
|
-
this._ssePendingPayload =
|
|
34385
|
+
const p = this._ssePendingPayload;
|
|
34386
|
+
this._ssePendingPayload = null;
|
|
34292
34387
|
this._sseFlushTimer = null;
|
|
34293
34388
|
if (!p || !Object.keys(p).length) return;
|
|
34294
34389
|
|
|
@@ -34344,7 +34439,7 @@ return res.json(out);
|
|
|
34344
34439
|
try { this.sseClients.clear(); } catch (_e2) {}
|
|
34345
34440
|
}
|
|
34346
34441
|
} catch (_e3) {}
|
|
34347
|
-
try { this._ssePendingPayload =
|
|
34442
|
+
try { this._ssePendingPayload = null; } catch (_e4) {}
|
|
34348
34443
|
}
|
|
34349
34444
|
/**
|
|
34350
34445
|
* Code-Teil: _nwCloseServer
|
|
@@ -34516,7 +34611,7 @@ return res.json(out);
|
|
|
34516
34611
|
} catch (_eSmartHomePulse) {}
|
|
34517
34612
|
try {
|
|
34518
34613
|
if (this._derivedFlow) this._derivedFlow.pending = false;
|
|
34519
|
-
this._ssePendingPayload =
|
|
34614
|
+
this._ssePendingPayload = null;
|
|
34520
34615
|
} catch (_ePending) {}
|
|
34521
34616
|
cleanup.capture(() => this._nwCloseSseClients());
|
|
34522
34617
|
|