iobroker.eos-admin 9.0.30 → 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 -12
- package/README.md +11 -11
- package/adminWww/.vite/manifest.json +39 -39
- package/adminWww/NEXOWATT_EOS_FRONTEND_MANIFEST.json +111 -110
- package/adminWww/apple-touch-icon-eos-v2.png +0 -0
- package/adminWww/apple-touch-icon.png +0 -0
- package/adminWww/assets/{AdapterUpdateDialog-qC6MANmq.js → AdapterUpdateDialog-DBUqmmyD.js} +1 -1
- package/adminWww/assets/{Adapters-C8quekd0.js → Adapters-dDEp7o5h.js} +1 -1
- package/adminWww/assets/{ConfigManager-hRZCAWRy.js → ConfigManager-DbqTWi2N.js} +1 -1
- package/adminWww/assets/{Enums-Dd0Z2KfV.js → Enums-DjldGElU.js} +1 -1
- package/adminWww/assets/{Fields-WfHFtdYw.js → Fields-0GsPCJeU.js} +1 -1
- package/adminWww/assets/{Files-DyG14v5-.js → Files-COnUtEbg.js} +1 -1
- package/adminWww/assets/{Hosts-3pSXVMxW.js → Hosts-CwU1LujG.js} +1 -1
- package/adminWww/assets/{Instances-DT6fp_TN.js → Instances-CUX5mxMQ.js} +1 -1
- package/adminWww/assets/{Intro-C6pMFhbu.js → Intro-BhQmHn3A.js} +1 -1
- package/adminWww/assets/{Logs-suepwNkZ.js → Logs-B5SpNqHq.js} +1 -1
- package/adminWww/assets/{Objects-CpjVeEjv.js → Objects-COg_cFkz.js} +1 -1
- package/adminWww/assets/{Overview-CxZJgF7X.js → Overview-CitzUjBF.js} +1 -1
- package/adminWww/assets/{State-CUsia7sz.js → State-D5ljzf-T.js} +1 -1
- package/adminWww/assets/{UsedResources-C3zr7pM8.js → UsedResources-BY_NF2wB.js} +1 -1
- package/adminWww/assets/{Users-BoBSUBkO.js → Users-Cu93_-VF.js} +1 -1
- package/adminWww/assets/{bootstrap-CM9qXoc1.js → bootstrap-Dwfxhm2V.js} +3 -3
- package/adminWww/assets/{hostInit-BQPg9kSQ.js → hostInit-3BbTwhaZ.js} +1 -1
- package/adminWww/assets/{icons-material-CDhwkQ0o.js → icons-material-DjqX0l_7.js} +1 -1
- package/adminWww/assets/{index-BrXN_pu2.js → index-nddph2Sl.js} +2 -2
- package/adminWww/assets/{installSVGRenderer-BEgWxsNI.js → installSVGRenderer-CPDIwFAL.js} +1 -1
- package/adminWww/assets/{mf-entry-bootstrap-0-3ef6056c.js → mf-entry-bootstrap-0-d1f0f40f.js} +2 -2
- package/adminWww/index.html +24 -24
- 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/build/lib/web.js +9 -8
- package/build/lib/web.js.map +1 -1
- package/docs/README.md +3 -2
- package/docs/reports/unified-9.0.31/PRUEFBERICHT.md +22 -0
- package/docs/reports/unified-9.0.31/PRUEFERGEBNISSE.json +112 -0
- package/docs/reports/unified-9.0.31/raw/INDEX.json +102 -0
- package/docs/reports/unified-9.0.31/raw/backend.log +5 -0
- package/docs/reports/unified-9.0.31/raw/branding-build-node22.log +59 -0
- package/docs/reports/unified-9.0.31/raw/branding-node24.log +17 -0
- package/docs/reports/unified-9.0.31/raw/frontend.log +151 -0
- package/docs/reports/unified-9.0.31/raw/https-build-node22.log +235 -0
- package/docs/reports/unified-9.0.31/raw/https-node24.log +46 -0
- package/docs/reports/unified-9.0.31/raw/installer.log +26 -0
- package/docs/reports/unified-9.0.31/raw/lint.log +5 -0
- package/docs/reports/unified-9.0.31/raw/modules.log +5 -0
- package/docs/reports/unified-9.0.31/raw/node22-tests-final.log +17170 -0
- package/docs/reports/unified-9.0.31/raw/node22-version.log +1 -0
- package/docs/reports/unified-9.0.31/raw/node24-tests-final.log +2862 -0
- package/docs/reports/unified-9.0.31/raw/node24-version.log +1 -0
- package/docs/reports/unified-9.0.31/raw/typecheck.log +5 -0
- package/docs/reports/unified-9.0.31/raw/ui-runtime.log +8 -0
- package/docs/reports/unified-9.0.31/raw/web-lint.log +0 -0
- 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.31.md +16 -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 +16 -16
- package/package.json +10 -5
- package/public/eos-tls/trust.html +1 -1
- package/release-manifests/unified/build-environment.cdx.json +6 -6
- package/release-manifests/unified/files.json +259 -157
- 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 +341 -88
- package/release-manifests/unified/runtime.cdx.json +26 -26
- 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 +13 -1
- package/ui/lib/datapoint-picker.js +27 -20
- package/ui/lib/eos-presentation-routes.js +2 -5
- package/ui/lib/tariff-price.js +7 -1
- package/ui/lib/ts-mirrors/ems/core-limits/core-runtime.js +5 -1
- package/ui/lib/ui-access-policy.js +12 -3
- package/ui/main.js +280 -190
- package/ui/package.json +4 -3
- package/ui/www/app.js +207 -87
- package/ui/www/ems-apps.html +1 -1
- package/ui/www/ems-apps.js +3 -2
- package/ui/www/energy-ledger.html +1 -1
- package/ui/www/evcs.html +1 -1
- package/ui/www/history.html +1 -1
- package/ui/www/index.html +2 -1
- package/ui/www/live-display.js +38 -4
- package/ui/www/logic.html +1 -1
- package/ui/www/login.html +1 -1
- package/ui/www/manifest.webmanifest +2 -2
- package/ui/www/power-measurements.js +28 -3
- package/ui/www/settings.html +1 -1
- package/ui/www/simulation.html +1 -1
- package/ui/www/smarthome-config.html +1 -1
- package/ui/www/smarthome.html +1 -1
- package/ui/www/storagefarm.html +1 -1
- package/adminWww/remoteEntry-eos-9.0.30.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:
|
|
@@ -46,7 +46,7 @@ const { cleanControls, extendSuggestion, collectKeywordDetectionCandidates, keyw
|
|
|
46
46
|
const { smartHomeEnabled, registerSmartHomeActivationApi } = require('./lib/smarthome-activation');
|
|
47
47
|
const { readPreservedUiStates, parseInstallerConfigState } = require('./lib/preserved-ui-config');
|
|
48
48
|
const { createRuntimeFileSender, runtimeProxyPrefix, rewriteRuntimeProxyHtml, isHttpsRuntimeProxy } = require('./lib/runtime-proxy-html');
|
|
49
|
-
const { parseUiCookies, isPublicUiRequest, isIndependentMachineRequest, uiRequestPath, constantTimeToken } = require('./lib/ui-access-policy');
|
|
49
|
+
const { APPLE_TOUCH_ICON_PATHS, parseUiCookies, isPublicUiRequest, isIndependentMachineRequest, uiRequestPath, constantTimeToken } = require('./lib/ui-access-policy');
|
|
50
50
|
const { resolveUiTlsOptions, UiTlsConfigurationError } = require('./lib/ui-server-transport');
|
|
51
51
|
const { createMeshPeerClient, safeMeshPeerError } = require('./lib/mesh-peer-http');
|
|
52
52
|
const path = require('path');
|
|
@@ -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);
|
|
@@ -13237,13 +13242,8 @@ app.get('/sw.js', (_req, res) => {
|
|
|
13237
13242
|
res.type('application/javascript');
|
|
13238
13243
|
res.sendFile(path.join(__dirname, 'www', 'sw.js'));
|
|
13239
13244
|
});
|
|
13240
|
-
//
|
|
13241
|
-
app.get(
|
|
13242
|
-
res.type('image/png');
|
|
13243
|
-
res.sendFile(path.join(__dirname, 'www', 'apple-touch-icon.png'));
|
|
13244
|
-
});
|
|
13245
|
-
// Conventional iOS probes are fixed public image aliases, never a public directory.
|
|
13246
|
-
app.get(['/apple-touch-icon-precomposed.png', '/apple-touch-icon-180x180.png', '/apple-touch-icon-180x180-precomposed.png'], (_req, res) => {
|
|
13245
|
+
// The versioned path and conventional iOS probes serve the same dedicated icon.
|
|
13246
|
+
app.get(APPLE_TOUCH_ICON_PATHS, (_req, res) => {
|
|
13247
13247
|
res.type('image/png');
|
|
13248
13248
|
res.sendFile(path.join(__dirname, 'www', 'assets', 'icons', 'nexowatt-180.png'));
|
|
13249
13249
|
});
|
|
@@ -27192,6 +27192,9 @@ return res.json(out);
|
|
|
27192
27192
|
const slice = plan.slice(i, i + concurrency);
|
|
27193
27193
|
await Promise.all(slice.map((entry) => applyState(entry)));
|
|
27194
27194
|
}
|
|
27195
|
+
if (this._derivedFlow?.reviewAt && Date.now() >= this._derivedFlow.reviewAt) {
|
|
27196
|
+
this.scheduleDerivedFlowUpdate('measurement-expiry');
|
|
27197
|
+
}
|
|
27195
27198
|
} finally {
|
|
27196
27199
|
this._nwLiveCoreRefreshRunning = false;
|
|
27197
27200
|
}
|
|
@@ -27390,6 +27393,7 @@ return res.json(out);
|
|
|
27390
27393
|
// "Datenpunkte" gemappt wurden. Daher wird im Subscribe-Loop unten auf die lokalen
|
|
27391
27394
|
// Adapter-States (namespace + key) zurückgefallen.
|
|
27392
27395
|
const localUiKeys = [
|
|
27396
|
+
'speicher.dcPvPowerW',
|
|
27393
27397
|
'tarif.statusText', 'tarif.intentStatusText', 'tarif.intentSnapshotAgeMs', 'tarif.intentSnapshotFresh', 'tarif.statusJson',
|
|
27394
27398
|
'tarif.speicherIntentW', 'tarif.speicherIntentStatus', 'tarif.speicherIntentGrund',
|
|
27395
27399
|
'tarif.speicherRequestW', 'tarif.speicherRequestQuelle', 'tarif.speicherRequestGrund',
|
|
@@ -28675,9 +28679,10 @@ return res.json(out);
|
|
|
28675
28679
|
// Nach einem Update kann der neu angelegte totalPowerW-State kurz 0 W enthalten,
|
|
28676
28680
|
// während die bereits vorhandenen Brutto-States noch den echten Farmfluss zeigen.
|
|
28677
28681
|
// Erst nach mindestens einer ausgewerteten Leistungsquelle ist totalPowerW führend.
|
|
28678
|
-
const
|
|
28679
|
-
|
|
28680
|
-
|
|
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'];
|
|
28681
28686
|
const chargeW = signedW === null ? null : signedW < 0 ? Math.abs(signedW) : 0;
|
|
28682
28687
|
const dischargeW = signedW === null ? null : signedW > 0 ? signedW : 0;
|
|
28683
28688
|
|
|
@@ -28708,6 +28713,7 @@ return res.json(out);
|
|
|
28708
28713
|
totalPowerW: signedW === null ? null : Math.round(signedW),
|
|
28709
28714
|
chargeW: chargeW === null ? null : Math.round(chargeW),
|
|
28710
28715
|
dischargeW: dischargeW === null ? null : Math.round(dischargeW),
|
|
28716
|
+
powerSourceKeys,
|
|
28711
28717
|
grossChargeW: Math.round(grossChargeW),
|
|
28712
28718
|
grossDischargeW: Math.round(grossDischargeW),
|
|
28713
28719
|
pvTotalW: Math.round(pvTotalW),
|
|
@@ -28842,6 +28848,7 @@ return res.json(out);
|
|
|
28842
28848
|
const maxAgeMs = opts.maxAgeMs === undefined ? this._nwLiveInputMaxAgeMs() : opts.maxAgeMs;
|
|
28843
28849
|
const deadbandW = Number.isFinite(Number(opts.deadbandW)) ? Math.max(0, Number(opts.deadbandW)) : 25;
|
|
28844
28850
|
const strictStale = opts.strictStale === true;
|
|
28851
|
+
const observe = opts.observe === true;
|
|
28845
28852
|
|
|
28846
28853
|
const dps = (this.config && this.config.datapoints && typeof this.config.datapoints === 'object') ? this.config.datapoints : {};
|
|
28847
28854
|
/**
|
|
@@ -28873,11 +28880,10 @@ return res.json(out);
|
|
|
28873
28880
|
* Zusammenhang: Teil von Adapterkern: Lifecycle, Webserver, API, States, EMS-Engine; Aufrufstellen und abhängige States/APIs beim Ändern mitprüfen.
|
|
28874
28881
|
* TypeScript: Parameter, Rückgabewert und verwendete Config-/State-Objekte später explizit typisieren.
|
|
28875
28882
|
*/
|
|
28876
|
-
const readMapped = (key
|
|
28877
|
-
|
|
28878
|
-
|
|
28879
|
-
|
|
28880
|
-
: 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);
|
|
28881
28887
|
};
|
|
28882
28888
|
/**
|
|
28883
28889
|
* Code-Teil: ageInfo
|
|
@@ -28913,6 +28919,7 @@ return res.json(out);
|
|
|
28913
28919
|
fromSigned: true,
|
|
28914
28920
|
mirror: opts2.mirror !== false,
|
|
28915
28921
|
derived: false,
|
|
28922
|
+
observedAt: opts2.observedAt ?? null,
|
|
28916
28923
|
staleMs: ageInfo(),
|
|
28917
28924
|
};
|
|
28918
28925
|
};
|
|
@@ -28991,10 +28998,13 @@ return res.json(out);
|
|
|
28991
28998
|
const sfEnabled = !!(farmMetrics && farmMetrics.active);
|
|
28992
28999
|
if (farmSelectedForControl) {
|
|
28993
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;
|
|
28994
29005
|
if (signed !== null && Number.isFinite(signed)) {
|
|
28995
|
-
//
|
|
28996
|
-
//
|
|
28997
|
-
// 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.
|
|
28998
29008
|
if (Math.abs(signed) <= deadbandW) signed = 0;
|
|
28999
29009
|
const c = signed < 0 ? Math.abs(signed) : 0;
|
|
29000
29010
|
const d = signed > 0 ? signed : 0;
|
|
@@ -29007,6 +29017,7 @@ return res.json(out);
|
|
|
29007
29017
|
fromSigned: true,
|
|
29008
29018
|
derived: false,
|
|
29009
29019
|
mirror: true,
|
|
29020
|
+
observedAt: observation?.ts ?? null,
|
|
29010
29021
|
grossChargeW: farmMetrics.grossChargeW,
|
|
29011
29022
|
grossDischargeW: farmMetrics.grossDischargeW,
|
|
29012
29023
|
staleMs: {
|
|
@@ -29036,15 +29047,23 @@ return res.json(out);
|
|
|
29036
29047
|
};
|
|
29037
29048
|
}
|
|
29038
29049
|
|
|
29039
|
-
const
|
|
29040
|
-
const
|
|
29041
|
-
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;
|
|
29042
29056
|
|
|
29043
29057
|
// Beide Split-Felder auf denselben DP gemappt = tatsächlich ein signed DP.
|
|
29044
|
-
if (sameChargeDischargeId
|
|
29045
|
-
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 });
|
|
29046
29061
|
}
|
|
29047
29062
|
|
|
29063
|
+
const completeSplit = chargeSample !== null && dischargeSample !== null;
|
|
29064
|
+
if (observe && !completeSplit && batterySample) {
|
|
29065
|
+
return fromSigned(batterySample.value, 'batterySigned', { observedAt: batterySample.ts });
|
|
29066
|
+
}
|
|
29048
29067
|
// Getrennte Lade-/Entlade-DPs sind autoritativ. Eine fehlende Seite wird als 0 W
|
|
29049
29068
|
// behandelt; sie wird nicht durch Bilanzwerte ersetzt. Das schützt Historie und
|
|
29050
29069
|
// Regelung vor verfälschten Speicherwerten bei konstantem/stalem 0-Wert.
|
|
@@ -29074,19 +29093,20 @@ return res.json(out);
|
|
|
29074
29093
|
fromSigned: false,
|
|
29075
29094
|
derived: false,
|
|
29076
29095
|
mirror: false,
|
|
29096
|
+
observedAt: observe && completeSplit ? Math.min(chargeSample?.ts ?? now, dischargeSample?.ts ?? now) : null,
|
|
29077
29097
|
staleMs: ageInfo(),
|
|
29078
29098
|
};
|
|
29079
29099
|
}
|
|
29080
29100
|
|
|
29081
29101
|
// Signed Batterie-DP ist der Fallback, wenn keine Split-DPs einen Wert liefern.
|
|
29082
29102
|
if (batterySigned !== null) {
|
|
29083
|
-
return fromSigned(batterySigned, 'batterySigned', {
|
|
29103
|
+
return fromSigned(batterySigned, 'batterySigned', { observedAt: batterySample?.ts });
|
|
29084
29104
|
}
|
|
29085
29105
|
|
|
29086
29106
|
// Rechen-Fallback nur, wenn überhaupt kein Speicher-DP konfiguriert ist.
|
|
29087
29107
|
// Wenn ein Speicher-DP konfiguriert, aber aktuell nicht lesbar ist, zeigen wir keinen
|
|
29088
29108
|
// geratenen Wert, damit Historie/Regelung nicht verfälscht werden.
|
|
29089
|
-
if (!anyStorageMapped) {
|
|
29109
|
+
if (!anyStorageMapped && !observe) {
|
|
29090
29110
|
const derived = fromBalance();
|
|
29091
29111
|
if (derived) return derived;
|
|
29092
29112
|
}
|
|
@@ -30808,33 +30828,59 @@ return res.json(out);
|
|
|
30808
30828
|
* Zusammenhang: Teil von Adapterkern: Lifecycle, Webserver, API, States, EMS-Engine; Aufrufstellen und abhängige States/APIs beim Ändern mitprüfen.
|
|
30809
30829
|
* TypeScript: Parameter, Rückgabewert und verwendete Config-/State-Objekte später explizit typisieren.
|
|
30810
30830
|
*/
|
|
30811
|
-
_nwResolveGridImportExportFromCache() {
|
|
30831
|
+
_nwResolveGridImportExportFromCache(opts = {}) {
|
|
30812
30832
|
const gridBuyMapped = this._nwHasMappedDatapoint('gridBuyPower');
|
|
30813
30833
|
const gridSellMapped = this._nwHasMappedDatapoint('gridSellPower');
|
|
30814
30834
|
const gridNetMapped = this._nwHasMappedDatapoint('gridPointPower');
|
|
30815
|
-
const
|
|
30816
|
-
const
|
|
30835
|
+
const observe = opts.observe === true;
|
|
30836
|
+
const now = opts.now ?? Date.now();
|
|
30837
|
+
const maxAgeMs = opts.maxAgeMs ?? this._nwLiveInputMaxAgeMs();
|
|
30817
30838
|
const canonicalRec = this.stateCache && this.stateCache['ems.gridMeasurementFresh'];
|
|
30818
30839
|
const canonicalAge = canonicalRec ? this._nwGetCacheAgeMs('ems.gridMeasurementFresh', now) : null;
|
|
30819
|
-
const canonicalKnown = !!(canonicalRec && canonicalAge !== null && canonicalAge <= Math.max(maxAgeMs, 15000));
|
|
30840
|
+
const canonicalKnown = !observe && !!(canonicalRec && canonicalAge !== null && canonicalAge <= Math.max(maxAgeMs, 15000));
|
|
30820
30841
|
const readFresh = (key, mapped) => mapped ? this._nwGetNumberFromCacheFresh(key, maxAgeMs, null, now) : null;
|
|
30821
|
-
|
|
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({
|
|
30822
30855
|
maxAgeMs,
|
|
30823
|
-
canonicalKnown,
|
|
30824
|
-
canonicalFresh: canonicalKnown && typeof canonicalRec.value === 'boolean' ? canonicalRec.value : null,
|
|
30825
|
-
|
|
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),
|
|
30826
30861
|
canonicalSource: this.stateCache?.['ems.gridPowerSource']?.value,
|
|
30827
|
-
canonicalStatus: this.stateCache?.['ems.gridMeasurementStatus']?.value,
|
|
30828
|
-
gridNetRaw: readFresh('gridPointPower', gridNetMapped),
|
|
30829
|
-
gridBuyRaw: readFresh('gridBuyPower', gridBuyMapped),
|
|
30830
|
-
gridSellRaw: readFresh('gridSellPower', gridSellMapped),
|
|
30831
|
-
gridBuyTs: this.stateCache?.gridBuyPower?.ts,
|
|
30832
|
-
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,
|
|
30833
30868
|
maxSkewMs: this.config?.diagnostics?.nvpMaxSkewMs,
|
|
30834
30869
|
gridBuyMapped,
|
|
30835
30870
|
gridSellMapped,
|
|
30836
30871
|
gridNetMapped,
|
|
30837
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 };
|
|
30838
30884
|
}
|
|
30839
30885
|
|
|
30840
30886
|
/**
|
|
@@ -31129,7 +31175,7 @@ return res.json(out);
|
|
|
31129
31175
|
gridSellW,
|
|
31130
31176
|
hasGrid,
|
|
31131
31177
|
} = this._nwResolveGridImportExportFromCache();
|
|
31132
|
-
const historyCoreMaxAgeMs =
|
|
31178
|
+
const historyCoreMaxAgeMs = this._nwLiveInputMaxAgeMs();
|
|
31133
31179
|
// History samples are observations, not a refresh of the last cached value.
|
|
31134
31180
|
// Missing timestamps, stale values and missing measurements remain gaps.
|
|
31135
31181
|
const readHistory = (key, maxAgeMs = historyCoreMaxAgeMs) => {
|
|
@@ -31157,8 +31203,9 @@ return res.json(out);
|
|
|
31157
31203
|
? this._nwGetStorageControlAuthority()
|
|
31158
31204
|
: { selectedTopology: 'none', writerActive: false };
|
|
31159
31205
|
const selectedStorageTopologyHist = String(storageAuthorityHist.selectedTopology || 'none');
|
|
31160
|
-
const storageFlowHist = this._nwResolveBatteryFlowFromCache({ now, strictStale: true });
|
|
31161
|
-
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);
|
|
31162
31209
|
const farmPowerAge = storageFlowHist.staleMs && numericMeasurement(storageFlowHist.staleMs.farmPower);
|
|
31163
31210
|
const farmPowerStale = selectedStorageTopologyHist === 'farm'
|
|
31164
31211
|
&& (farmPowerAge === null || farmPowerAge === undefined || farmPowerAge > historyCoreMaxAgeMs);
|
|
@@ -31209,28 +31256,32 @@ return res.json(out);
|
|
|
31209
31256
|
&& this.config.storage
|
|
31210
31257
|
&& String(this.config.storage.coupling || '').trim().toLowerCase() === 'dc');
|
|
31211
31258
|
|
|
31212
|
-
if (!pvTotalFromDerived && sfEnabled
|
|
31213
|
-
|
|
31214
|
-
|
|
31215
|
-
|
|
31216
|
-
now,
|
|
31217
|
-
|
|
31218
|
-
|
|
31219
|
-
|
|
31220
|
-
|
|
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
|
+
}
|
|
31221
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();
|
|
31222
31271
|
const dcValueW = readHistory('speicher.dcPvPowerW');
|
|
31223
|
-
if (
|
|
31224
|
-
const
|
|
31225
|
-
if (pvTotal
|
|
31226
|
-
else
|
|
31227
|
-
const pvAbs = Math.abs(pvTotal);
|
|
31228
|
-
const relDiff = Math.abs(pvAbs - dcAbs) / Math.max(1, dcAbs);
|
|
31229
|
-
pvTotal = relDiff < 0.05 ? Math.max(pvAbs, dcAbs) : (pvAbs + dcAbs);
|
|
31230
|
-
}
|
|
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);
|
|
31231
31276
|
}
|
|
31232
31277
|
}
|
|
31233
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
|
+
|
|
31234
31285
|
// Ohne expliziten Energiefluss-Override folgt die Historie weiterhin der
|
|
31235
31286
|
// aktiven Speichertopologie. Ein vorhandener, gueltiger Override bleibt aber
|
|
31236
31287
|
// autoritativ und wird nicht durch Writer-/App-Lifecycle auf null gesetzt.
|
|
@@ -31243,7 +31294,7 @@ return res.json(out);
|
|
|
31243
31294
|
}
|
|
31244
31295
|
}
|
|
31245
31296
|
|
|
31246
|
-
let loadTotal = Number.isFinite(loadW)
|
|
31297
|
+
let loadTotal = Number.isFinite(loadW) && loadW >= 0 ? loadW : null;
|
|
31247
31298
|
const chg = Number.isFinite(chgW) ? Math.max(0, chgW) : null;
|
|
31248
31299
|
const dchg = Number.isFinite(dchgW) ? Math.max(0, dchgW) : null;
|
|
31249
31300
|
const evAbs = Number.isFinite(evW) ? Math.abs(evW) : null;
|
|
@@ -32550,23 +32601,43 @@ return res.json(out);
|
|
|
32550
32601
|
scheduleDerivedFlowUpdate(reason = '') {
|
|
32551
32602
|
if (this._nwShuttingDown) return;
|
|
32552
32603
|
// Throttle derived calculations to avoid excessive state writes on high-frequency meters.
|
|
32553
|
-
const
|
|
32554
|
-
|
|
32555
|
-
|
|
32556
|
-
|
|
32557
|
-
|
|
32558
|
-
|
|
32559
|
-
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;
|
|
32560
32611
|
|
|
32561
|
-
const
|
|
32562
|
-
const delay =
|
|
32612
|
+
const now = Date.now();
|
|
32613
|
+
const delay = Math.max(0, (flow.minIntervalMs ?? 250) - (now - (flow.lastRunMs ?? 0)));
|
|
32563
32614
|
|
|
32564
|
-
|
|
32565
|
-
this._nwSetTimeout(() => {
|
|
32566
|
-
|
|
32567
|
-
|
|
32568
|
-
|
|
32569
|
-
|
|
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
|
+
}
|
|
32570
32641
|
}, delay);
|
|
32571
32642
|
}
|
|
32572
32643
|
/**
|
|
@@ -32575,14 +32646,32 @@ return res.json(out);
|
|
|
32575
32646
|
* Zusammenhang: Teil von Adapterkern: Lifecycle, Webserver, API, States, EMS-Engine; Aufrufstellen und abhängige States/APIs beim Ändern mitprüfen.
|
|
32576
32647
|
* TypeScript: Parameter, Rückgabewert und verwendete Config-/State-Objekte später explizit typisieren.
|
|
32577
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
|
+
|
|
32578
32663
|
async updateDerivedFlowStates(reason = '') {
|
|
32579
32664
|
// Building consumption can be derived from the power balance at NVP:
|
|
32580
32665
|
// load = (PV + other production) + gridImport + batteryDischarge - gridExport - batteryCharge
|
|
32581
32666
|
// If no direct house meter (consumptionTotal) is configured, we use this as fallback for the UI.
|
|
32582
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());
|
|
32583
32673
|
const ts = Date.now();
|
|
32584
|
-
const
|
|
32585
|
-
const liveMaxAgeMs = Math.max(10000, (configuredAgeSec !== null && configuredAgeSec > 0 ? configuredAgeSec : 60) * 1000);
|
|
32674
|
+
const liveMaxAgeMs = this._nwLiveInputMaxAgeMs();
|
|
32586
32675
|
const inputTimes = [];
|
|
32587
32676
|
const pvTimes = [];
|
|
32588
32677
|
const producerTimes = [];
|
|
@@ -32595,23 +32684,19 @@ return res.json(out);
|
|
|
32595
32684
|
};
|
|
32596
32685
|
const oldestTime = (times) => times.length ? Math.min(...times) : ts;
|
|
32597
32686
|
|
|
32598
|
-
// Keep PV-inverter auto-cache reasonably fresh (cheap no-op when not due)
|
|
32599
|
-
await this._derivedRefreshPvInvertersCache(false);
|
|
32600
|
-
|
|
32601
32687
|
const pvPowerMapped = this._nwHasMappedDatapoint('pvPower');
|
|
32602
32688
|
const prodTotalMapped = this._nwHasMappedDatapoint('productionTotal');
|
|
32603
32689
|
const consumptionMapped = this._nwHasMappedDatapoint('consumptionTotal');
|
|
32604
32690
|
|
|
32605
32691
|
// --- Grid ---
|
|
32606
32692
|
const {
|
|
32607
|
-
gridBuyRaw,
|
|
32608
|
-
gridSellRaw,
|
|
32609
32693
|
gridNetRaw,
|
|
32610
32694
|
gridBuyW,
|
|
32611
32695
|
gridSellW,
|
|
32612
32696
|
hasGrid,
|
|
32613
32697
|
src: gridSrc,
|
|
32614
|
-
|
|
32698
|
+
observedAt: gridObservedAt,
|
|
32699
|
+
} = this._nwResolveGridImportExportFromCache({ now: ts, maxAgeMs: liveMaxAgeMs, observe: true });
|
|
32615
32700
|
|
|
32616
32701
|
// --- Storage ---
|
|
32617
32702
|
// Normalize storage power centrally:
|
|
@@ -32619,7 +32704,7 @@ return res.json(out);
|
|
|
32619
32704
|
// settings.flowInvertBattery flips that signed value before splitting.
|
|
32620
32705
|
// Separate charge/discharge datapoints remain supported, but stale/legacy mirrored
|
|
32621
32706
|
// values must not make the UI or derived balance show both directions at once.
|
|
32622
|
-
const storageFlow = this._nwResolveBatteryFlowFromCache({ now: ts, strictStale: true, maxAgeMs: liveMaxAgeMs });
|
|
32707
|
+
const storageFlow = this._nwResolveBatteryFlowFromCache({ now: ts, strictStale: true, maxAgeMs: liveMaxAgeMs, observe: true });
|
|
32623
32708
|
const chargeW = Math.max(0, Number(storageFlow.chargeW) || 0);
|
|
32624
32709
|
const dischargeW = Math.max(0, Number(storageFlow.dischargeW) || 0);
|
|
32625
32710
|
const storageSrc = storageFlow.src || 'missing';
|
|
@@ -32676,9 +32761,7 @@ return res.json(out);
|
|
|
32676
32761
|
} else {
|
|
32677
32762
|
// Auto: sum all PV_INVERTER devices from nexowatt-devices
|
|
32678
32763
|
const pvAuto = this._derivedFlow?.auto?.pvInverters;
|
|
32679
|
-
|
|
32680
|
-
const staleMs = Math.max(10 * 1000, (Number.isFinite(staleSec) ? staleSec : 60) * 1000);
|
|
32681
|
-
|
|
32764
|
+
pvBaseSourceIds = [];
|
|
32682
32765
|
let sum = 0;
|
|
32683
32766
|
let used = 0;
|
|
32684
32767
|
let offline = 0;
|
|
@@ -32690,7 +32773,7 @@ return res.json(out);
|
|
|
32690
32773
|
|
|
32691
32774
|
const connected = (cRec && cRec.val !== undefined) ? !!cRec.val : true;
|
|
32692
32775
|
const isOffline = (oRec && oRec.val !== undefined) ? !!oRec.val : false;
|
|
32693
|
-
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;
|
|
32694
32777
|
|
|
32695
32778
|
if (!connected || isOffline || !ageOk || (pRec?.q !== undefined && pRec.q !== 0)) {
|
|
32696
32779
|
offline++;
|
|
@@ -32739,8 +32822,24 @@ return res.json(out);
|
|
|
32739
32822
|
let pvDcIncluded = false;
|
|
32740
32823
|
let pvFarmMerge = null;
|
|
32741
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);
|
|
32742
32832
|
|
|
32743
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
|
+
}
|
|
32744
32843
|
pvFarmMerge = this._nwMergeStorageFarmPvWithBase(pvAcW, {
|
|
32745
32844
|
now: ts,
|
|
32746
32845
|
metrics: farmMetrics,
|
|
@@ -32755,24 +32854,30 @@ return res.json(out);
|
|
|
32755
32854
|
if (pvFarmMerge.farmFallbackUsed && pvSource === 'missing') pvSource = 'farm:pv-sources';
|
|
32756
32855
|
else if (pvFarmMerge.farmAddedW > 0) pvSource = pvSource === 'missing' ? 'farm:pv-sources' : `${pvSource}+farm`;
|
|
32757
32856
|
} else if (singleStorageDcEnabled) {
|
|
32758
|
-
const
|
|
32759
|
-
|
|
32760
|
-
|
|
32761
|
-
|
|
32762
|
-
|
|
32763
|
-
|
|
32764
|
-
|
|
32765
|
-
|
|
32766
|
-
|
|
32767
|
-
|
|
32768
|
-
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;
|
|
32769
32867
|
} else {
|
|
32770
|
-
|
|
32771
|
-
|
|
32772
|
-
|
|
32773
|
-
pvTotalW =
|
|
32868
|
+
pvDcW = Math.abs(dc);
|
|
32869
|
+
pvDcSource = 'storage:dc';
|
|
32870
|
+
if (duplicate && sitePvValid) {
|
|
32871
|
+
pvTotalW = pvAcW;
|
|
32872
|
+
} else {
|
|
32774
32873
|
pvDcIncluded = true;
|
|
32874
|
+
pvTotalW = pvAcW + pvDcW;
|
|
32875
|
+
if (!sitePvValid && (!sitePvExpected || dcCoversMissingSite)) {
|
|
32876
|
+
pvObserved = true;
|
|
32877
|
+
pvSource = pvDcSource;
|
|
32878
|
+
}
|
|
32775
32879
|
}
|
|
32880
|
+
pvBaseSourceIds.push(dcId);
|
|
32776
32881
|
}
|
|
32777
32882
|
}
|
|
32778
32883
|
}
|
|
@@ -32837,33 +32942,13 @@ return res.json(out);
|
|
|
32837
32942
|
|
|
32838
32943
|
// A balance is usable only with all configured contributors observed.
|
|
32839
32944
|
// Never refresh an old measurement through this periodic calculation.
|
|
32840
|
-
|
|
32841
|
-
if (
|
|
32842
|
-
if (gridSrc === 'net-fresh') gridObserved = readLive('gridPointPower', gridTimes) !== null;
|
|
32843
|
-
else if (String(gridSrc).startsWith('split-')) {
|
|
32844
|
-
const buyRequired = this._nwHasMappedDatapoint('gridBuyPower');
|
|
32845
|
-
const sellRequired = this._nwHasMappedDatapoint('gridSellPower');
|
|
32846
|
-
const buy = buyRequired ? readLive('gridBuyPower', gridTimes) : 0;
|
|
32847
|
-
const sell = sellRequired ? readLive('gridSellPower', gridTimes) : 0;
|
|
32848
|
-
gridObserved = (buyRequired || sellRequired) && buy !== null && sell !== null;
|
|
32849
|
-
} else gridObserved = readLive('ems.gridPowerRawW', gridTimes) !== null;
|
|
32850
|
-
}
|
|
32945
|
+
const gridObserved = hasGrid && Number.isFinite(gridObservedAt);
|
|
32946
|
+
if (gridObserved) gridTimes.push(gridObservedAt);
|
|
32851
32947
|
const storageConfigured = selectedStorageTopologyLive !== 'none'
|
|
32852
32948
|
|| ['batteryPower', 'storageChargePower', 'storageDischargePower', 'storageSoc'].some(key => this._nwHasMappedDatapoint(key));
|
|
32853
|
-
|
|
32854
|
-
|
|
32855
|
-
|
|
32856
|
-
} else if (storageSrc === 'batterySigned') storageObserved = readLive('batteryPower', storageTimes) !== null;
|
|
32857
|
-
else if (storageSrc === 'sameChargeDischargeSigned') storageObserved = readLive('storageChargePower', storageTimes) !== null;
|
|
32858
|
-
else if (String(storageSrc).startsWith('chargeDischarge')) {
|
|
32859
|
-
storageObserved = ['storageChargePower', 'storageDischargePower'].every(key => !this._nwHasMappedDatapoint(key) || readLive(key, storageTimes) !== null);
|
|
32860
|
-
}
|
|
32861
|
-
const autoPvConfigured = (this._derivedFlow?.auto?.pvInverters?.list || []).length > 0;
|
|
32862
|
-
const pvConfigured = pvPowerMapped || prodTotalMapped || autoPvConfigured || sfEnabled || singleStorageDcEnabled;
|
|
32863
|
-
let pvObserved = !pvConfigured || (pvSource !== 'missing' && !pvSource.includes('incomplete'));
|
|
32864
|
-
if (sfEnabled && (pvFarmMerge?.farmAddedW > 0 || pvFarmMerge?.farmFallbackUsed)) {
|
|
32865
|
-
pvObserved = pvObserved && readLive('storageFarm.totalPvPowerW', pvTimes) !== null;
|
|
32866
|
-
}
|
|
32949
|
+
const measuredStorage = Number.isFinite(storageFlow.observedAt);
|
|
32950
|
+
const storageObserved = measuredStorage || !storageConfigured;
|
|
32951
|
+
if (measuredStorage) storageTimes.push(storageFlow.observedAt);
|
|
32867
32952
|
inputTimes.push(...pvTimes, ...producerTimes, ...gridTimes, ...storageTimes);
|
|
32868
32953
|
const balanceObserved = gridObserved && storageObserved && pvObserved && !missingProducer;
|
|
32869
32954
|
const loadTotalW = directLoadTotalW !== null ? directLoadTotalW
|
|
@@ -32898,6 +32983,9 @@ return res.json(out);
|
|
|
32898
32983
|
const loadTotalRound = loadTotalW !== null ? Math.round(loadTotalW) : null;
|
|
32899
32984
|
const loadRestRound = loadRestW !== null ? Math.round(loadRestW) : null;
|
|
32900
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;
|
|
32901
32989
|
|
|
32902
32990
|
const tsShadow = this._nwRunEnergyFlowTsShadowComparison({
|
|
32903
32991
|
ts,
|
|
@@ -32968,38 +33056,35 @@ return res.json(out);
|
|
|
32968
33056
|
: 'js-runtime';
|
|
32969
33057
|
const energyFlowProductiveTsActive = energyFlowSourceState === 'ts-candidate' || energyFlowSourceState === 'ts-normal';
|
|
32970
33058
|
const energyFlowLiveTestState = this._nwEnergyFlowTsLiveTestStateFromSwitch(effectiveEnergyFlow.switchState || {});
|
|
32971
|
-
const tsSwitchJsonText = JSON.stringify(effectiveEnergyFlow.switchState || {});
|
|
32972
|
-
const tsCandidateJsonText = JSON.stringify(effectiveEnergyFlow.candidate || {});
|
|
32973
|
-
const tsFixedSourceJsonText = JSON.stringify((effectiveEnergyFlow.switchState && effectiveEnergyFlow.switchState.fixedSourceState) || {});
|
|
32974
33059
|
try {
|
|
32975
33060
|
if (this._derivedFlow?.last?.energyFlowSource !== energyFlowSourceState) {
|
|
32976
|
-
this._derivedFlow.last.energyFlowSource = energyFlowSourceState;
|
|
32977
33061
|
await this.setStateAsync('derived.core.building.energyFlowSource', { val: energyFlowSourceState, ack: true });
|
|
33062
|
+
this._derivedFlow.last.energyFlowSource = energyFlowSourceState;
|
|
32978
33063
|
}
|
|
32979
33064
|
if (this._derivedFlow?.last?.tsLiveTestState !== energyFlowLiveTestState) {
|
|
32980
|
-
this._derivedFlow.last.tsLiveTestState = energyFlowLiveTestState;
|
|
32981
33065
|
await this.setStateAsync('derived.core.building.tsLiveTestState', { val: energyFlowLiveTestState, ack: true });
|
|
33066
|
+
this._derivedFlow.last.tsLiveTestState = energyFlowLiveTestState;
|
|
32982
33067
|
}
|
|
32983
33068
|
if (this._derivedFlow?.last?.tsProductiveActive !== energyFlowProductiveTsActive) {
|
|
32984
|
-
this._derivedFlow.last.tsProductiveActive = energyFlowProductiveTsActive;
|
|
32985
33069
|
await this.setStateAsync('derived.core.building.tsProductiveActive', { val: energyFlowProductiveTsActive, ack: true });
|
|
33070
|
+
this._derivedFlow.last.tsProductiveActive = energyFlowProductiveTsActive;
|
|
32986
33071
|
}
|
|
32987
33072
|
} catch (_eTsLiveState) {}
|
|
32988
33073
|
|
|
32989
33074
|
// --- Update adapter states (for App-Center mapping / debugging) ---
|
|
32990
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 });
|
|
32991
33077
|
this._derivedFlow.last.loadTimestamp = loadTimestamp;
|
|
32992
33078
|
this._derivedFlow.last.loadTotalW = publishLoadTotalRound;
|
|
32993
|
-
await this.setStateAsync('derived.core.building.loadTotalW', { val: publishLoadTotalRound, ack: true, ts: loadTimestamp });
|
|
32994
33079
|
}
|
|
32995
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 });
|
|
32996
33082
|
this._derivedFlow.last.restTimestamp = restTimestamp;
|
|
32997
33083
|
this._derivedFlow.last.loadRestW = publishLoadRestRound;
|
|
32998
|
-
await this.setStateAsync('derived.core.building.loadRestW', { val: publishLoadRestRound, ack: true, ts: restTimestamp });
|
|
32999
33084
|
}
|
|
33000
33085
|
if (this._derivedFlow?.last?.loadSource !== loadTotalSource) {
|
|
33001
|
-
this._derivedFlow.last.loadSource = loadTotalSource;
|
|
33002
33086
|
await this.setStateAsync('derived.core.building.loadSource', { val: loadTotalSource, ack: true });
|
|
33087
|
+
this._derivedFlow.last.loadSource = loadTotalSource;
|
|
33003
33088
|
}
|
|
33004
33089
|
|
|
33005
33090
|
const pvAcRound = Math.round(pvAcW);
|
|
@@ -33008,27 +33093,27 @@ return res.json(out);
|
|
|
33008
33093
|
|
|
33009
33094
|
const publishPvAcW = pvObserved ? pvAcRound : null;
|
|
33010
33095
|
if (this._derivedFlow?.last?.pvAcW !== publishPvAcW || this._derivedFlow?.last?.pvTimestamp !== oldestTime(pvTimes)) {
|
|
33011
|
-
this._derivedFlow.last.pvAcW = publishPvAcW;
|
|
33012
33096
|
await this.setStateAsync('derived.core.pv.acW', { val: publishPvAcW, ack: true, ts: oldestTime(pvTimes) });
|
|
33097
|
+
this._derivedFlow.last.pvAcW = publishPvAcW;
|
|
33013
33098
|
}
|
|
33014
33099
|
const publishPvDcW = pvObserved ? pvDcRound : null;
|
|
33015
33100
|
if (this._derivedFlow?.last?.pvDcW !== publishPvDcW || this._derivedFlow?.last?.pvTimestamp !== oldestTime(pvTimes)) {
|
|
33016
|
-
this._derivedFlow.last.pvDcW = publishPvDcW;
|
|
33017
33101
|
await this.setStateAsync('derived.core.pv.dcW', { val: publishPvDcW, ack: true, ts: oldestTime(pvTimes) });
|
|
33102
|
+
this._derivedFlow.last.pvDcW = publishPvDcW;
|
|
33018
33103
|
}
|
|
33019
33104
|
const publishPvTotalW = pvObserved ? pvTotalRound : null;
|
|
33020
33105
|
if (this._derivedFlow?.last?.pvTotalW !== publishPvTotalW || this._derivedFlow?.last?.pvTimestamp !== oldestTime(pvTimes)) {
|
|
33021
|
-
this._derivedFlow.last.pvTotalW = publishPvTotalW;
|
|
33022
33106
|
await this.setStateAsync('derived.core.pv.totalW', { val: publishPvTotalW, ack: true, ts: oldestTime(pvTimes) });
|
|
33107
|
+
this._derivedFlow.last.pvTotalW = publishPvTotalW;
|
|
33023
33108
|
}
|
|
33024
33109
|
|
|
33025
33110
|
this._derivedFlow.last.pvTimestamp = oldestTime(pvTimes);
|
|
33026
33111
|
const publishExtraW = missingProducer ? null : Math.round(producerSumW);
|
|
33027
33112
|
const producerTimestamp = oldestTime(producerTimes);
|
|
33028
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 });
|
|
33029
33115
|
this._derivedFlow.last.extraProductionW = publishExtraW;
|
|
33030
33116
|
this._derivedFlow.last.extraTimestamp = producerTimestamp;
|
|
33031
|
-
await this.setStateAsync('derived.core.production.extraW', { val: publishExtraW, ack: true, ts: producerTimestamp });
|
|
33032
33117
|
}
|
|
33033
33118
|
this.updateValue('derived.core.production.extraW', publishExtraW, producerTimestamp, { raw: false });
|
|
33034
33119
|
|
|
@@ -33036,24 +33121,24 @@ return res.json(out);
|
|
|
33036
33121
|
const pvCapacityLimitRound = Math.round(pvPlausibility.capacityLimitW);
|
|
33037
33122
|
const pvDuplicateSuppressedRound = Math.round(pvDuplicateSuppressedW);
|
|
33038
33123
|
if (this._derivedFlow?.last?.pvRawTotalW !== pvRawTotalRound) {
|
|
33039
|
-
this._derivedFlow.last.pvRawTotalW = pvRawTotalRound;
|
|
33040
33124
|
await this.setStateAsync('derived.core.pv.rawTotalW', { val: pvRawTotalRound, ack: true });
|
|
33125
|
+
this._derivedFlow.last.pvRawTotalW = pvRawTotalRound;
|
|
33041
33126
|
}
|
|
33042
33127
|
if (this._derivedFlow?.last?.pvCapacityLimitW !== pvCapacityLimitRound) {
|
|
33043
|
-
this._derivedFlow.last.pvCapacityLimitW = pvCapacityLimitRound;
|
|
33044
33128
|
await this.setStateAsync('derived.core.pv.capacityLimitW', { val: pvCapacityLimitRound, ack: true });
|
|
33129
|
+
this._derivedFlow.last.pvCapacityLimitW = pvCapacityLimitRound;
|
|
33045
33130
|
}
|
|
33046
33131
|
if (this._derivedFlow?.last?.pvDuplicateSuppressedW !== pvDuplicateSuppressedRound) {
|
|
33047
|
-
this._derivedFlow.last.pvDuplicateSuppressedW = pvDuplicateSuppressedRound;
|
|
33048
33132
|
await this.setStateAsync('derived.core.pv.duplicateSuppressedW', { val: pvDuplicateSuppressedRound, ack: true });
|
|
33133
|
+
this._derivedFlow.last.pvDuplicateSuppressedW = pvDuplicateSuppressedRound;
|
|
33049
33134
|
}
|
|
33050
33135
|
if (this._derivedFlow?.last?.pvPlausibilityCapped !== pvPlausibility.capped) {
|
|
33051
|
-
this._derivedFlow.last.pvPlausibilityCapped = pvPlausibility.capped;
|
|
33052
33136
|
await this.setStateAsync('derived.core.pv.plausibilityCapped', { val: !!pvPlausibility.capped, ack: true });
|
|
33137
|
+
this._derivedFlow.last.pvPlausibilityCapped = pvPlausibility.capped;
|
|
33053
33138
|
}
|
|
33054
33139
|
if (this._derivedFlow?.last?.pvSource !== pvSource) {
|
|
33055
|
-
this._derivedFlow.last.pvSource = pvSource;
|
|
33056
33140
|
await this.setStateAsync('derived.core.pv.source', { val: pvSource, ack: true });
|
|
33141
|
+
this._derivedFlow.last.pvSource = pvSource;
|
|
33057
33142
|
}
|
|
33058
33143
|
|
|
33059
33144
|
// Die abgeleiteten Kernwerte werden zusätzlich in den API-/SSE-Cache gespiegelt.
|
|
@@ -33062,6 +33147,8 @@ return res.json(out);
|
|
|
33062
33147
|
this.updateValue('derived.core.building.loadTotalW', publishLoadTotalRound, loadTimestamp, { raw: false });
|
|
33063
33148
|
this.updateValue('derived.core.building.loadRestW', publishLoadRestRound, restTimestamp, { raw: false });
|
|
33064
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 });
|
|
33065
33152
|
this.updateValue('derived.core.pv.acW', pvObserved ? pvAcRound : null, oldestTime(pvTimes), { raw: false });
|
|
33066
33153
|
this.updateValue('derived.core.pv.dcW', pvObserved ? pvDcRound : null, oldestTime(pvTimes), { raw: false });
|
|
33067
33154
|
this.updateValue('derived.core.pv.totalW', pvObserved ? pvTotalRound : null, oldestTime(pvTimes), { raw: false });
|
|
@@ -33083,8 +33170,8 @@ return res.json(out);
|
|
|
33083
33170
|
this.updateValue('derived.core.building.quality', quality, ts, { raw: false });
|
|
33084
33171
|
|
|
33085
33172
|
if (this._derivedFlow?.last?.quality !== quality) {
|
|
33086
|
-
this._derivedFlow.last.quality = quality;
|
|
33087
33173
|
await this.setStateAsync('derived.core.building.quality', { val: quality, ack: true });
|
|
33174
|
+
this._derivedFlow.last.quality = quality;
|
|
33088
33175
|
}
|
|
33089
33176
|
|
|
33090
33177
|
// Diagnostics payload (throttled)
|
|
@@ -33093,7 +33180,6 @@ return res.json(out);
|
|
|
33093
33180
|
const lastDiag = Number(this._derivedFlow?.diagLastMs) || 0;
|
|
33094
33181
|
if (!this._derivedFlow) this._derivedFlow = {};
|
|
33095
33182
|
if ((ts - lastDiag) >= diagEveryMs) {
|
|
33096
|
-
this._derivedFlow.diagLastMs = ts;
|
|
33097
33183
|
const payload = {
|
|
33098
33184
|
ts,
|
|
33099
33185
|
reason,
|
|
@@ -33159,9 +33245,13 @@ return res.json(out);
|
|
|
33159
33245
|
const json = JSON.stringify(payload);
|
|
33160
33246
|
await this.setStateAsync('derived.core.building.inputsJson', { val: json, ack: true });
|
|
33161
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) || {});
|
|
33162
33251
|
await this.setStateAsync('derived.core.building.tsSwitchJson', { val: tsSwitchJsonText, ack: true });
|
|
33163
33252
|
await this.setStateAsync('derived.core.building.tsCandidateJson', { val: tsCandidateJsonText, ack: true });
|
|
33164
33253
|
await this.setStateAsync('derived.core.building.tsFixedSourceJson', { val: tsFixedSourceJsonText, ack: true });
|
|
33254
|
+
this._derivedFlow.diagLastMs = ts;
|
|
33165
33255
|
}
|
|
33166
33256
|
} catch (_e) {}
|
|
33167
33257
|
|
|
@@ -33170,13 +33260,13 @@ return res.json(out);
|
|
|
33170
33260
|
// derive them from the signed NVP datapoint (Import + / Export -).
|
|
33171
33261
|
const gridBuyMapped = this._nwHasMappedDatapoint('gridBuyPower');
|
|
33172
33262
|
const gridSellMapped = this._nwHasMappedDatapoint('gridSellPower');
|
|
33173
|
-
if (gridObserved && gridNetRaw !== null &&
|
|
33263
|
+
if (gridObserved && gridNetRaw !== null && !gridBuyMapped) {
|
|
33174
33264
|
const cur = Number(this.stateCache?.gridBuyPower?.value);
|
|
33175
33265
|
if (!Number.isFinite(cur) || cur !== gridBuyRound || this.stateCache?.gridBuyPower?.ts !== oldestTime(gridTimes)) {
|
|
33176
33266
|
this.updateValue('gridBuyPower', publishGridBuyRound, oldestTime(gridTimes), { raw: false });
|
|
33177
33267
|
}
|
|
33178
33268
|
}
|
|
33179
|
-
if (gridObserved && gridNetRaw !== null &&
|
|
33269
|
+
if (gridObserved && gridNetRaw !== null && !gridSellMapped) {
|
|
33180
33270
|
const cur = Number(this.stateCache?.gridSellPower?.value);
|
|
33181
33271
|
if (!Number.isFinite(cur) || cur !== gridSellRound || this.stateCache?.gridSellPower?.ts !== oldestTime(gridTimes)) {
|
|
33182
33272
|
this.updateValue('gridSellPower', publishGridSellRound, oldestTime(gridTimes), { raw: false });
|
|
@@ -34219,18 +34309,20 @@ return res.json(out);
|
|
|
34219
34309
|
|
|
34220
34310
|
this.stateCache[key] = { value, ts, ...(opts.q !== undefined ? { q: opts.q } : {}) };
|
|
34221
34311
|
|
|
34222
|
-
|
|
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];
|
|
34223
34315
|
|
|
34224
34316
|
// derived EVCS aggregates
|
|
34225
34317
|
try {
|
|
34226
34318
|
if (/^evcs\.\d+\.powerW$/.test(key)) {
|
|
34227
34319
|
const count = Math.max(0, Math.round(Number(this.evcsCount || 0) || 0));
|
|
34228
|
-
const maxAgeMs =
|
|
34320
|
+
const maxAgeMs = this._nwLiveInputMaxAgeMs();
|
|
34229
34321
|
const keys = Array.from({ length: Math.min(count, 1024) }, (_, index) => `evcs.${index + 1}.powerW`);
|
|
34230
34322
|
const observation = sumFlowMeasurements(this.stateCache, keys, Date.now(), maxAgeMs);
|
|
34231
34323
|
const aggregate = observation || { value: null, ts: Date.now() };
|
|
34232
34324
|
this.stateCache['evcs.totalPowerW'] = aggregate;
|
|
34233
|
-
payload['evcs.totalPowerW'] = aggregate;
|
|
34325
|
+
if (payload) payload['evcs.totalPowerW'] = aggregate;
|
|
34234
34326
|
this.setStateAsync('evcs.totalPowerW', { val: aggregate.value, ts: aggregate.ts, ack: true }).catch(() => {});
|
|
34235
34327
|
}
|
|
34236
34328
|
|
|
@@ -34249,14 +34341,14 @@ return res.json(out);
|
|
|
34249
34341
|
base = total;
|
|
34250
34342
|
this.stateCache[baseD] = { value: baseDate, ts };
|
|
34251
34343
|
this.stateCache[baseK] = { value: base, ts };
|
|
34252
|
-
payload[baseD] = this.stateCache[baseD];
|
|
34253
|
-
payload[baseK] = this.stateCache[baseK];
|
|
34344
|
+
if (payload) payload[baseD] = this.stateCache[baseD];
|
|
34345
|
+
if (payload) payload[baseK] = this.stateCache[baseK];
|
|
34254
34346
|
this.setStateAsync(baseD, baseDate, true).catch(()=>{});
|
|
34255
34347
|
this.setStateAsync(baseK, base, true).catch(()=>{});
|
|
34256
34348
|
}
|
|
34257
34349
|
const dayKwh = Math.max(0, total - base);
|
|
34258
34350
|
this.stateCache[`evcs.${idx}.energyDayKwh`] = { value: dayKwh, ts };
|
|
34259
|
-
payload[`evcs.${idx}.energyDayKwh`] = this.stateCache[`evcs.${idx}.energyDayKwh`];
|
|
34351
|
+
if (payload) payload[`evcs.${idx}.energyDayKwh`] = this.stateCache[`evcs.${idx}.energyDayKwh`];
|
|
34260
34352
|
this.setStateAsync(`evcs.${idx}.energyDayKwh`, dayKwh, true).catch(()=>{});
|
|
34261
34353
|
}
|
|
34262
34354
|
} catch(_e) {}
|
|
@@ -34266,14 +34358,15 @@ return res.json(out);
|
|
|
34266
34358
|
|
|
34267
34359
|
// Derived / calculated live values (e.g. building consumption fallback for UI)
|
|
34268
34360
|
try {
|
|
34269
|
-
const isTrigger =
|
|
34361
|
+
const isTrigger = key === 'speicher.dcPvPowerW' || key.startsWith('storageFarm.') || (opts.raw !== false && (
|
|
34270
34362
|
key === 'gridBuyPower' || key === 'gridSellPower' || key === 'gridPointPower' ||
|
|
34271
34363
|
key === 'pvPower' || key === 'productionTotal' ||
|
|
34272
34364
|
key === 'storageChargePower' || key === 'storageDischargePower' || key === 'batteryPower' ||
|
|
34273
|
-
key === '
|
|
34365
|
+
key === 'consumptionTotal' || key === 'consumptionEvcs' ||
|
|
34366
|
+
key === 'settings.flowInvertBattery' || key === 'settings.flowInvertGrid' || key === 'settings.deviceStaleTimeoutSec' ||
|
|
34274
34367
|
/^producer\d+Power$/.test(key) || /^consumer\d+Power$/.test(key) ||
|
|
34275
|
-
/^evcs\.\d+\.powerW$/.test(key) || key === 'evcs.totalPowerW'
|
|
34276
|
-
|
|
34368
|
+
/^evcs\.\d+\.powerW$/.test(key) || key === 'evcs.totalPowerW'
|
|
34369
|
+
));
|
|
34277
34370
|
if (isTrigger) this.scheduleDerivedFlowUpdate(`key:${key}`);
|
|
34278
34371
|
} catch (_e3) {}
|
|
34279
34372
|
|
|
@@ -34282,18 +34375,15 @@ return res.json(out);
|
|
|
34282
34375
|
// RC88_SSE_IDLE_ZERO_ALLOCATION: without connected dashboards there is
|
|
34283
34376
|
// nothing to batch or serialize. Avoid a permanent 120-ms timer/allocation
|
|
34284
34377
|
// chain on headless customer systems.
|
|
34285
|
-
if (!
|
|
34286
|
-
this._ssePendingPayload =
|
|
34378
|
+
if (!payload) {
|
|
34379
|
+
this._ssePendingPayload = null;
|
|
34287
34380
|
return;
|
|
34288
34381
|
}
|
|
34289
|
-
if (!this._ssePendingPayload) this._ssePendingPayload = {};
|
|
34290
|
-
Object.assign(this._ssePendingPayload, payload);
|
|
34291
|
-
|
|
34292
34382
|
if (!this._sseFlushTimer) {
|
|
34293
34383
|
const batchMs = (this.config && Number(this.config.sseBatchMs)) || 120;
|
|
34294
34384
|
this._sseFlushTimer = this._nwSetTimeout(() => {
|
|
34295
|
-
const p = this._ssePendingPayload
|
|
34296
|
-
this._ssePendingPayload =
|
|
34385
|
+
const p = this._ssePendingPayload;
|
|
34386
|
+
this._ssePendingPayload = null;
|
|
34297
34387
|
this._sseFlushTimer = null;
|
|
34298
34388
|
if (!p || !Object.keys(p).length) return;
|
|
34299
34389
|
|
|
@@ -34349,7 +34439,7 @@ return res.json(out);
|
|
|
34349
34439
|
try { this.sseClients.clear(); } catch (_e2) {}
|
|
34350
34440
|
}
|
|
34351
34441
|
} catch (_e3) {}
|
|
34352
|
-
try { this._ssePendingPayload =
|
|
34442
|
+
try { this._ssePendingPayload = null; } catch (_e4) {}
|
|
34353
34443
|
}
|
|
34354
34444
|
/**
|
|
34355
34445
|
* Code-Teil: _nwCloseServer
|
|
@@ -34521,7 +34611,7 @@ return res.json(out);
|
|
|
34521
34611
|
} catch (_eSmartHomePulse) {}
|
|
34522
34612
|
try {
|
|
34523
34613
|
if (this._derivedFlow) this._derivedFlow.pending = false;
|
|
34524
|
-
this._ssePendingPayload =
|
|
34614
|
+
this._ssePendingPayload = null;
|
|
34525
34615
|
} catch (_ePending) {}
|
|
34526
34616
|
cleanup.capture(() => this._nwCloseSseClients());
|
|
34527
34617
|
|