iobroker.eos-admin 9.0.31 → 9.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NEXOWATT_EOS_BUILD_INFO.json +10 -11
- package/README.md +7 -7
- package/adminWww/.vite/manifest.json +233 -224
- package/adminWww/NEXOWATT_EOS_FRONTEND_MANIFEST.json +13897 -13887
- package/adminWww/assets/AccessTime-CuR73YC3.js +1 -0
- package/adminWww/assets/{AdapterUpdateDialog-UhaQHyF1.js → AdapterUpdateDialog-5L75o18m.js} +5 -5
- package/adminWww/assets/{Adapters-Di3sM_ky.js → Adapters-FcghjF7E.js} +5 -5
- package/adminWww/assets/ConfigManager-BnHarBfH.js +1 -0
- package/adminWww/assets/Enums-BjLbLLQL.js +92 -0
- package/adminWww/assets/Fields-DDE1hVOa.js +1 -0
- package/adminWww/assets/Files-CDjnR4q6.js +1 -0
- package/adminWww/assets/{Hosts-DXjTE0pX.js → Hosts-CJKQaNrD.js} +6 -6
- package/adminWww/assets/Instances-DZNl369k.js +4 -0
- package/adminWww/assets/Intro-CjAmMGDB.js +2 -0
- package/adminWww/assets/KeyboardArrowRight-ifvmV1ZL.js +1 -0
- package/adminWww/assets/{Logs-DTo6XJF_.js → Logs-rUAV7SwM.js} +2 -2
- package/adminWww/assets/MoreHoriz-CS7nODK8.js +1 -0
- package/adminWww/assets/{Objects-DyEBMDK6.js → Objects-CqOH6rT_.js} +4 -4
- package/adminWww/assets/Overview-BOtXqsMy.js +3 -0
- package/adminWww/assets/Pageview-wzrLQZ-j.js +1 -0
- package/adminWww/assets/PersonOff-YtHcY0sV.js +1 -0
- package/adminWww/assets/Star-D8VNXawT.js +1 -0
- package/adminWww/assets/State-C8ncThop.js +1 -0
- package/adminWww/assets/UsedResources-lUYJqy4F.js +2 -0
- package/adminWww/assets/Users-CK1Cax82.js +1 -0
- package/adminWww/assets/ViewCompact-D7bHgn99.js +1 -0
- package/adminWww/assets/ViewSidebar-CjClbCI5.js +1 -0
- package/adminWww/assets/WifiTethering-DJ9VO12W.js +1 -0
- package/adminWww/assets/{bootstrap-BQ4OzwbT.js → bootstrap-CC0Qr-kr.js} +25 -25
- package/adminWww/assets/date-fns-BtR4dG_j.js +1 -0
- package/adminWww/assets/en-US-BjjaEI6N.js +1 -0
- package/adminWww/assets/{hostInit-CGSSNegd.js → hostInit-DqGL6nY8.js} +1 -1
- package/adminWww/assets/icons-material-07rWS63O.js +1 -0
- package/adminWww/assets/{index-C4CShixx.js → index-BhhkToP2.js} +2 -2
- package/adminWww/assets/{installSVGRenderer-DeaOAT3W.js → installSVGRenderer-B4-7lSQZ.js} +1 -1
- package/adminWww/assets/isSameWeek-WMSJR5Qs.js +1 -0
- package/adminWww/assets/locale-DN6Bdkdt.js +1 -0
- package/adminWww/assets/{mf-entry-bootstrap-0-c5733c2d.js → mf-entry-bootstrap-0-1afd2287.js} +2 -2
- package/adminWww/assets/sentry-CPzCHrwe.js +1 -0
- package/adminWww/assets/setYear-DDSuW45e.js +1 -0
- package/adminWww/index.html +23 -23
- package/adminWww/mf-manifest.json +1 -1
- package/adminWww/mf-stats.json +1 -1
- package/adminWww/{remoteEntry-eos-9.0.31.js → remoteEntry-eos-9.0.34.js} +1 -1
- package/adminWww/remoteEntry.js +1 -1
- package/build/lib/eosDeviceEmsPlan.js +285 -9
- package/build/lib/eosDeviceEmsPlan.js.map +1 -1
- package/build/lib/eosDeviceEmsService.js +29 -2
- package/build/lib/eosDeviceEmsService.js.map +1 -1
- package/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/reports/unified-9.0.34/PRUEFBERICHT.md +40 -0
- package/docs/reports/unified-9.0.34/PRUEFERGEBNISSE.json +112 -0
- package/docs/reports/unified-9.0.34/raw/INDEX.json +137 -0
- package/docs/reports/unified-9.0.34/raw/backend.log +5 -0
- package/docs/reports/unified-9.0.34/raw/dashboard-interval.json +108 -0
- package/docs/reports/unified-9.0.34/raw/fixtures-verification.log +44 -0
- package/docs/reports/unified-9.0.34/raw/frontend.log +152 -0
- package/docs/reports/unified-9.0.34/raw/installer.log +26 -0
- package/docs/reports/unified-9.0.34/raw/lint.log +45 -0
- package/docs/reports/unified-9.0.34/raw/mira-dashboard-browser.json +1 -0
- package/docs/reports/unified-9.0.34/raw/mira-devices-browser.log +9 -0
- package/docs/reports/unified-9.0.34/raw/mira-memory-process.json +379 -0
- package/docs/reports/unified-9.0.34/raw/modules.log +5 -0
- package/docs/reports/unified-9.0.34/raw/node22-mira.log +216 -0
- package/docs/reports/unified-9.0.34/raw/node22-protocol-to-ems.log +8 -0
- package/docs/reports/unified-9.0.34/raw/node22-tests-final.log +17850 -0
- package/docs/reports/unified-9.0.34/raw/node22-version.log +1 -0
- package/docs/reports/unified-9.0.34/raw/node24-mira.log +40 -0
- package/docs/reports/unified-9.0.34/raw/node24-protocol-to-ems.log +6 -0
- package/docs/reports/unified-9.0.34/raw/node24-tests-final.log +2973 -0
- package/docs/reports/unified-9.0.34/raw/node24-version.log +1 -0
- package/docs/reports/unified-9.0.34/raw/protocol-to-ems.cjs +364 -0
- package/docs/reports/unified-9.0.34/raw/release-metadata.log +13 -0
- package/docs/reports/unified-9.0.34/raw/sbom.log +8 -0
- package/docs/reports/unified-9.0.34/raw/typecheck.log +5 -0
- package/docs/reports/unified-9.0.34/raw/ui-runtime.log +8 -0
- package/docs/start/START_HIER_9.0.32.md +16 -0
- package/docs/start/START_HIER_9.0.33.md +32 -0
- package/docs/start/START_HIER_9.0.34.md +25 -0
- package/io-package.json +16 -16
- package/modules/devices/admin/alias-contract-v1.json +22 -0
- package/modules/devices/admin/ems-assignment.js +6 -1
- package/modules/devices/admin/host-bridge.js +2 -0
- package/modules/devices/admin/index.html +16 -0
- package/modules/devices/admin/index_m.js +168 -9
- package/modules/devices/admin/templates.json +976 -0
- package/modules/devices/checks/emsAssignment.check.js +52 -2
- package/modules/devices/index.js +5 -1
- package/modules/devices/lib/alias-contract-v1.json +22 -0
- package/modules/devices/lib/deviceRuntime.js +17 -7
- package/modules/devices/lib/drivers/modbus.js +1 -1
- package/modules/devices/lib/drivers/modbusRtuBus.js +7 -1
- package/modules/devices/lib/drivers/ovumMira.js +148 -0
- package/modules/devices/lib/ovumMiraAliases.js +61 -0
- package/modules/devices/lib/ovumMiraConnection.js +32 -0
- package/modules/devices/lib/templates.json +976 -0
- package/modules/devices/test/aliasContractV1.test.js +4 -4
- package/modules/devices/test/deviceAliasSemantics.test.js +2 -2
- package/modules/devices/test/fixtures/approved-additive-templates.json +3 -1
- package/modules/devices/test/ovumMiraPairing.test.js +76 -0
- package/modules/devices/test/ovumMiraTemplates.test.js +110 -0
- package/modules/devices/test/ovumMiraTransport.test.js +162 -0
- package/package.json +10 -5
- package/release-manifests/unified/build-environment.cdx.json +7 -7
- package/release-manifests/unified/files.json +302 -180
- 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 +281 -28
- package/release-manifests/unified/runtime.cdx.json +28 -28
- package/release-manifests/unified/validation.json +15 -15
- package/tools/eos-release-manifest.cjs +2 -2
- package/ui/ems/consumers/ovum-mira.js +164 -0
- 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/para14a.js +3 -2
- package/ui/ems/modules/prime-mover-control.js +141 -29
- package/ui/ems/modules/stage-a-diagnostics.js +4 -2
- 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/modules/thermal-control.js +91 -10
- 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/installer-lifecycle.js +11 -2
- 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 +313 -188
- package/ui/package.json +4 -3
- package/ui/www/app.js +238 -100
- package/ui/www/ems-apps.js +30 -10
- package/ui/www/index.html +1 -0
- package/ui/www/licenses/smarthome-markdown-components.json +156 -156
- 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/assets/AddLink-0L0E-LsA.js +0 -1
- package/adminWww/assets/ColorLens-DA51K29x.js +0 -1
- package/adminWww/assets/ConfigManager-C2naRwDl.js +0 -1
- package/adminWww/assets/Enums-B9ucB-qg.js +0 -92
- package/adminWww/assets/Fields-DN41WFbp.js +0 -1
- package/adminWww/assets/FileCopy-B16lEuur.js +0 -1
- package/adminWww/assets/Files-C3PbbeNR.js +0 -1
- package/adminWww/assets/Instances-PKvEjDNQ.js +0 -4
- package/adminWww/assets/Intro-BnYMjDZr.js +0 -2
- package/adminWww/assets/Lens-9lkeoWGk.js +0 -1
- package/adminWww/assets/LinearScale-Be5h2beh.js +0 -1
- package/adminWww/assets/North-C2whbHM-.js +0 -1
- package/adminWww/assets/Overview-CWLYuqZx.js +0 -3
- package/adminWww/assets/PersonOff-DqBq0Fho.js +0 -1
- package/adminWww/assets/PlaylistAdd-O8k92YBd.js +0 -1
- package/adminWww/assets/State-Ca9_Ke_c.js +0 -1
- package/adminWww/assets/UsedResources-20bsoxmj.js +0 -2
- package/adminWww/assets/Users-yZyZX-18.js +0 -1
- package/adminWww/assets/date-fns-C1dqkno9.js +0 -1
- package/adminWww/assets/icons-material-C3PNaipj.js +0 -1
- package/adminWww/assets/isSameWeek-Crh37s7U.js +0 -1
- package/adminWww/assets/isWithinInterval-Bo1WiDfq.js +0 -1
- package/adminWww/assets/locale-hLcz_Xh2.js +0 -1
- package/adminWww/assets/sentry-DwQQLI7N.js +0 -1
- package/adminWww/assets/startOfWeek-DJph8SIW.js +0 -1
package/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:2316c9c2553f364bf54c35a456deb0345dc306a146b2d649e6c341b77f0413b2
|
|
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');
|
|
@@ -175,6 +176,16 @@ const {
|
|
|
175
176
|
} = require('./lib/smarthome-contract');
|
|
176
177
|
|
|
177
178
|
// Abschnitt: Kleine HTTP-/Auth-Helfer. Diese Funktionen werden von Login-, Lizenz- und Installer-Endpunkten genutzt.
|
|
179
|
+
/** The MIRA controller accepts PV requests only after device commissioning.
|
|
180
|
+
* Quick controls change EMS intent. They never address MIRA registers directly.
|
|
181
|
+
*/
|
|
182
|
+
function miraFlowControlReady(device) {
|
|
183
|
+
return device?.ovumMira === true && device.enabled === true && device.miraSourcesConfirmed === true
|
|
184
|
+
&& Number.isSafeInteger(device.maxPowerW) && device.maxPowerW > 0
|
|
185
|
+
&& [device.miraPvStatusId, device.miraPvStatusReadId, device.miraPowerTargetId, device.miraPowerTargetReadId]
|
|
186
|
+
.every(id => typeof id === 'string' && id.trim().length > 0);
|
|
187
|
+
}
|
|
188
|
+
|
|
178
189
|
/**
|
|
179
190
|
* Code-Teil: parseCookies
|
|
180
191
|
* Zweck: Parst Rohdaten in ein sicheres internes Format.
|
|
@@ -294,7 +305,7 @@ class NexoWattVis extends HostedAdapter {
|
|
|
294
305
|
});
|
|
295
306
|
this.sseClients = this._nwSseGuard.clients;
|
|
296
307
|
// Batch SSE updates to prevent UI freezes on frequent state updates
|
|
297
|
-
this._ssePendingPayload =
|
|
308
|
+
this._ssePendingPayload = null;
|
|
298
309
|
this._sseFlushTimer = null;
|
|
299
310
|
this.server = null;
|
|
300
311
|
this._serverSockets = new Set();
|
|
@@ -557,7 +568,7 @@ class NexoWattVis extends HostedAdapter {
|
|
|
557
568
|
} catch (_e) {}
|
|
558
569
|
// A pending coalesced patch is disposable: every browser receives a full
|
|
559
570
|
// current snapshot after reconnect/resync, while EMS control is untouched.
|
|
560
|
-
try { this._ssePendingPayload =
|
|
571
|
+
try { this._ssePendingPayload = null; } catch (_e) {}
|
|
561
572
|
try {
|
|
562
573
|
if (removed > 0) {
|
|
563
574
|
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 +580,7 @@ class NexoWattVis extends HostedAdapter {
|
|
|
569
580
|
/** Memory guard: final cleanup before the emergency restart safety net. */
|
|
570
581
|
_nwPrepareControlledRestart(sample) {
|
|
571
582
|
try { this._nwCloseSseClients(); } catch (_e) {}
|
|
572
|
-
try { this._ssePendingPayload =
|
|
583
|
+
try { this._ssePendingPayload = null; } catch (_e) {}
|
|
573
584
|
try {
|
|
574
585
|
this.log.error(`[memory-guard] preparing controlled restart at ${Math.round(Number(sample?.ratio || 0) * 1000) / 10}% heap usage`);
|
|
575
586
|
} catch (_e) {}
|
|
@@ -4985,7 +4996,7 @@ class NexoWattVis extends HostedAdapter {
|
|
|
4985
4996
|
assertReady();
|
|
4986
4997
|
if (typeof this._bridge.deviceEmsPlan !== 'function') throw new Error('EOS_DEVICE_EMS_UNAVAILABLE');
|
|
4987
4998
|
const effective = this.nwApplyInstallerPatchToRuntimeConfig(this.config || {}, this._nwInstallerConfigPatch || {});
|
|
4988
|
-
const allowedApps = ['charging', 'storage', 'storagefarm'].filter(id => this._nwLicenseAllowsAppId(id));
|
|
4999
|
+
const allowedApps = ['charging', 'storage', 'storagefarm', 'thermal'].filter(id => this._nwLicenseAllowsAppId(id));
|
|
4989
5000
|
const plan = await this._bridge.deviceEmsPlan({ config: effective, devices, allowedApps });
|
|
4990
5001
|
assertReady();
|
|
4991
5002
|
if (!plan.changed && !this._nwDeviceEmsApplyPending) return { changed: false, statuses: plan.statuses };
|
|
@@ -6575,9 +6586,7 @@ class NexoWattVis extends HostedAdapter {
|
|
|
6575
6586
|
//
|
|
6576
6587
|
// The timeout is configurable in the end-user settings page (Einstellungen).
|
|
6577
6588
|
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));
|
|
6589
|
+
const staleMs = this._nwLiveInputMaxAgeMs();
|
|
6581
6590
|
|
|
6582
6591
|
// Local read cache (per tick) to avoid repeating getForeignStateAsync calls.
|
|
6583
6592
|
const _stCache = new Map();
|
|
@@ -6753,7 +6762,7 @@ class NexoWattVis extends HostedAdapter {
|
|
|
6753
6762
|
|
|
6754
6763
|
const st = await getState(sid);
|
|
6755
6764
|
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
|
|
6765
|
+
if (opts.display === true && ((st.q !== undefined && st.q !== 0) || !Number.isFinite(st.ts) || st.ts <= 0 || st.ts > now)) return NaN;
|
|
6757
6766
|
|
|
6758
6767
|
// IMPORTANT: We intentionally do NOT apply stale filtering here.
|
|
6759
6768
|
// Some devices update SoC or power only sporadically; the UI should still show
|
|
@@ -6808,6 +6817,7 @@ class NexoWattVis extends HostedAdapter {
|
|
|
6808
6817
|
let totalCharge = 0;
|
|
6809
6818
|
let totalDischarge = 0;
|
|
6810
6819
|
const batteryFlowSources = new Set();
|
|
6820
|
+
const physicalBatteryTimes = [];
|
|
6811
6821
|
let totalPvAc = 0;
|
|
6812
6822
|
let totalPvDc = 0;
|
|
6813
6823
|
let totalPvUnknown = 0;
|
|
@@ -7372,13 +7382,13 @@ class NexoWattVis extends HostedAdapter {
|
|
|
7372
7382
|
const pvAgeMs = (stPv && typeof stPv.ts === 'number' && Number.isFinite(stPv.ts))
|
|
7373
7383
|
? Math.max(0, now - Number(stPv.ts))
|
|
7374
7384
|
: null;
|
|
7375
|
-
const
|
|
7376
|
-
const
|
|
7385
|
+
const pvValue = !explicitOffline ? await readNumber(pvSourceId, 'power', { allowStale: false, display: true }) : NaN;
|
|
7386
|
+
const pvFresh = Number.isFinite(pvValue);
|
|
7377
7387
|
const pvAbs = Number.isFinite(pvValue) ? Math.max(0, Math.abs(pvValue)) : 0;
|
|
7378
7388
|
status.pvSourceOnline = !!pvFresh;
|
|
7379
7389
|
if (pvAgeMs !== null) status.pvSourceAgeSec = Math.floor(pvAgeMs / 1000);
|
|
7380
7390
|
if (pvFresh && Number.isFinite(pvValue)) status.pvPowerW = pvAbs;
|
|
7381
|
-
const displayPv =
|
|
7391
|
+
const displayPv = pvValue;
|
|
7382
7392
|
// Gepunktete Geräte-IDs enden erst vor `.aliases.`, nicht am ersten Punkt.
|
|
7383
7393
|
// Unbekannte manuelle Pfade bleiben exakte Quellen statt geratenen Geräteklassen.
|
|
7384
7394
|
const aliasDeviceBase = pvSourceId.match(/^(.*\.devices\..+?)\.aliases(?:\.|$)/)?.[1];
|
|
@@ -7500,6 +7510,8 @@ class NexoWattVis extends HostedAdapter {
|
|
|
7500
7510
|
Math.max(0, invDchg ? -discharge : discharge) - Math.max(0, invChg ? -charge : charge);
|
|
7501
7511
|
}
|
|
7502
7512
|
if (Number.isFinite(physicalPower)) {
|
|
7513
|
+
const observedIds = batteryFlowId ? [batteryFlowId] : signedFeedbackUsable ? [signedId] : [chgId, dchgId].filter(Boolean);
|
|
7514
|
+
for (const id of observedIds) physicalBatteryTimes.push((await getState(id)).ts);
|
|
7503
7515
|
status.batteryFlowPowerW = physicalPower;
|
|
7504
7516
|
overviewMember.batteryPowerW = physicalPower;
|
|
7505
7517
|
if (duplicateBatteryFlow) status.batteryFlowDuplicate = true;
|
|
@@ -7561,7 +7573,10 @@ class NexoWattVis extends HostedAdapter {
|
|
|
7561
7573
|
const totalBatteryPowerState = farmOverview.battery.netW;
|
|
7562
7574
|
const totalChargeState = Math.round(totalCharge);
|
|
7563
7575
|
const totalDischargeState = Math.round(totalDischarge);
|
|
7564
|
-
const
|
|
7576
|
+
const pvComplete = pvSourcesOnline > 0 && pvSourcesOnline === pvSourceRows.length;
|
|
7577
|
+
const totalPvState = pvComplete ? Math.round(totalPv) : null;
|
|
7578
|
+
const pvPowerTs = pvComplete ? Math.min(...pvSourceRows.map(row => now - row.ageMs)) : now;
|
|
7579
|
+
const batteryPowerTs = totalBatteryPowerState !== null && physicalBatteryTimes.length ? Math.min(...physicalBatteryTimes) : now;
|
|
7565
7580
|
const totalPvAcState = Math.round(totalPvAc);
|
|
7566
7581
|
const totalPvDcState = Math.round(totalPvDc);
|
|
7567
7582
|
const totalPvUnknownState = Math.round(totalPvUnknown);
|
|
@@ -7576,9 +7591,9 @@ class NexoWattVis extends HostedAdapter {
|
|
|
7576
7591
|
await writeDerived('storageFarm.socSourcesOnline', { val: socSourcesOnline, ack: true });
|
|
7577
7592
|
await writeDerived('storageFarm.socDegraded', { val: !!socDegraded, ack: true });
|
|
7578
7593
|
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 });
|
|
7594
|
+
await writeDerived('storageFarm.totalBatteryPowerW', { val: totalBatteryPowerState, ack: true, ts: batteryPowerTs });
|
|
7595
|
+
await writeDerived('storageFarm.totalBatteryChargePowerW', { val: farmOverview.battery.chargeW, ack: true, ts: batteryPowerTs });
|
|
7596
|
+
await writeDerived('storageFarm.totalBatteryDischargePowerW', { val: farmOverview.battery.dischargeW, ack: true, ts: batteryPowerTs });
|
|
7582
7597
|
await writeDerived('storageFarm.displayMeanSoc', { val: farmOverview.soc.meanPct, ack: true });
|
|
7583
7598
|
await writeDerived('storageFarm.totalCapacityKWh', { val: farmOverview.capacity.totalKWh, ack: true });
|
|
7584
7599
|
await writeDerived('storageFarm.overviewJson', { val: farmOverviewJson, ack: true });
|
|
@@ -7586,7 +7601,7 @@ class NexoWattVis extends HostedAdapter {
|
|
|
7586
7601
|
await writeDerived('storageFarm.powerSourcesOnline', { val: powerSourcesOnline, ack: true });
|
|
7587
7602
|
await writeDerived('storageFarm.totalChargePowerW', { val: totalChargeState, ack: true });
|
|
7588
7603
|
await writeDerived('storageFarm.totalDischargePowerW', { val: totalDischargeState, ack: true });
|
|
7589
|
-
await writeDerived('storageFarm.totalPvPowerW', { val: totalPvState, ack: true });
|
|
7604
|
+
await writeDerived('storageFarm.totalPvPowerW', { val: totalPvState, ack: true, ts: pvPowerTs });
|
|
7590
7605
|
await writeDerived('storageFarm.totalPvAcPowerW', { val: totalPvAcState, ack: true });
|
|
7591
7606
|
await writeDerived('storageFarm.totalPvDcPowerW', { val: totalPvDcState, ack: true });
|
|
7592
7607
|
await writeDerived('storageFarm.totalPvUnknownPowerW', { val: totalPvUnknownState, ack: true });
|
|
@@ -7616,9 +7631,9 @@ class NexoWattVis extends HostedAdapter {
|
|
|
7616
7631
|
this.updateValue('storageFarm.socSourcesOnline', socSourcesOnline, now);
|
|
7617
7632
|
this.updateValue('storageFarm.socDegraded', !!socDegraded, now);
|
|
7618
7633
|
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,
|
|
7634
|
+
this.updateValue('storageFarm.totalBatteryPowerW', totalBatteryPowerState, batteryPowerTs);
|
|
7635
|
+
this.updateValue('storageFarm.totalBatteryChargePowerW', farmOverview.battery.chargeW, batteryPowerTs);
|
|
7636
|
+
this.updateValue('storageFarm.totalBatteryDischargePowerW', farmOverview.battery.dischargeW, batteryPowerTs);
|
|
7622
7637
|
this.updateValue('storageFarm.displayMeanSoc', farmOverview.soc.meanPct, now);
|
|
7623
7638
|
this.updateValue('storageFarm.totalCapacityKWh', farmOverview.capacity.totalKWh, now);
|
|
7624
7639
|
this.updateValue('storageFarm.overviewJson', farmOverviewJson, now);
|
|
@@ -7626,7 +7641,7 @@ class NexoWattVis extends HostedAdapter {
|
|
|
7626
7641
|
this.updateValue('storageFarm.powerSourcesOnline', powerSourcesOnline, now);
|
|
7627
7642
|
this.updateValue('storageFarm.totalChargePowerW', totalChargeState, now);
|
|
7628
7643
|
this.updateValue('storageFarm.totalDischargePowerW', totalDischargeState, now);
|
|
7629
|
-
this.updateValue('storageFarm.totalPvPowerW', totalPvState,
|
|
7644
|
+
this.updateValue('storageFarm.totalPvPowerW', totalPvState, pvPowerTs);
|
|
7630
7645
|
this.updateValue('storageFarm.totalPvAcPowerW', totalPvAcState, now);
|
|
7631
7646
|
this.updateValue('storageFarm.totalPvDcPowerW', totalPvDcState, now);
|
|
7632
7647
|
this.updateValue('storageFarm.totalPvUnknownPowerW', totalPvUnknownState, now);
|
|
@@ -23421,10 +23436,10 @@ app.get('/config', async (req, res) => {
|
|
|
23421
23436
|
// Wir geben bewusst nur Metadaten (Name + Slot + gemappt?) zurück – keine Fremd-State-IDs.
|
|
23422
23437
|
flowSlots: (() => {
|
|
23423
23438
|
// Energy-flow: optional slots
|
|
23424
|
-
// Consumers: max
|
|
23439
|
+
// Consumers: max 10
|
|
23425
23440
|
// Producers: reduced to max 5
|
|
23426
23441
|
const SLOT_COUNT_BY_KIND = {
|
|
23427
|
-
consumers:
|
|
23442
|
+
consumers: 10,
|
|
23428
23443
|
producers: 5,
|
|
23429
23444
|
};
|
|
23430
23445
|
const dps = (cfg && cfg.datapoints && typeof cfg.datapoints === 'object') ? cfg.datapoints : {};
|
|
@@ -23620,6 +23635,18 @@ app.get('/config', async (req, res) => {
|
|
|
23620
23635
|
if (!dev) dev = tlist.find(r => r && Math.round(Number(r.slot ?? r.consumerSlot ?? 0)) === idx) || null;
|
|
23621
23636
|
const holdMin = Math.max(0, Math.round(Number(t.manualHoldMin ?? 20)));
|
|
23622
23637
|
meta.manualHoldMin = holdMin;
|
|
23638
|
+
if (dev?.ovumMira === true) {
|
|
23639
|
+
meta.controlKind = 'thermal';
|
|
23640
|
+
meta.ovumMira = true;
|
|
23641
|
+
meta.enabled = miraFlowControlReady(dev) && slotType === 'heatPump';
|
|
23642
|
+
meta.hasSwitch = false;
|
|
23643
|
+
meta.hasSetpoint = false;
|
|
23644
|
+
meta.hasSgReady = false;
|
|
23645
|
+
meta.hasBoost = meta.enabled && dev.boostEnabled !== false;
|
|
23646
|
+
meta.boostMinutes = meta.hasBoost ? Math.max(0, Number(dev.boostDurationMin ?? 30)) : null;
|
|
23647
|
+
meta.max = dev.maxPowerW;
|
|
23648
|
+
return meta;
|
|
23649
|
+
}
|
|
23623
23650
|
if (dev && dev.boostEnabled !== false && enabled) {
|
|
23624
23651
|
meta.hasBoost = true;
|
|
23625
23652
|
const mins = Math.max(0, Math.round(Number(dev.boostDurationMin ?? 30)));
|
|
@@ -25618,6 +25645,13 @@ settingsConfig: {
|
|
|
25618
25645
|
};
|
|
25619
25646
|
|
|
25620
25647
|
// Boost override – local runtime override, no direct foreign DP.
|
|
25648
|
+
const miraDevice = kind === 'consumers' ? resolveThermalDev() : null;
|
|
25649
|
+
if (miraDevice?.ovumMira === true) {
|
|
25650
|
+
if (slotType !== 'heatPump' || !cfg.enableThermalControl || !miraFlowControlReady(miraDevice)) {
|
|
25651
|
+
return res.status(409).json({ ok: false, error: 'not_ready' });
|
|
25652
|
+
}
|
|
25653
|
+
if (prop === 'setpoint' || prop === 'switch') return res.status(409).json({ ok: false, error: 'ems_owned' });
|
|
25654
|
+
}
|
|
25621
25655
|
if (prop === 'boost') {
|
|
25622
25656
|
if (kind !== 'consumers') return res.status(400).json({ ok: false, error: 'bad request' });
|
|
25623
25657
|
const idLocal = `c${idx}`;
|
|
@@ -26319,7 +26353,8 @@ settingsConfig: {
|
|
|
26319
26353
|
const effectiveMode = (userMode !== 'inherit') ? userMode : cfgMode;
|
|
26320
26354
|
|
|
26321
26355
|
out.thermal = {
|
|
26322
|
-
available: true,
|
|
26356
|
+
available: dev.ovumMira === true ? miraFlowControlReady(dev) && slotType === 'heatPump' : true,
|
|
26357
|
+
ovumMira: dev.ovumMira === true,
|
|
26323
26358
|
cfgEnabled: !!cfgEnabled,
|
|
26324
26359
|
cfgMode,
|
|
26325
26360
|
userEnabled: !!userEnabled,
|
|
@@ -26329,8 +26364,8 @@ settingsConfig: {
|
|
|
26329
26364
|
modes: [
|
|
26330
26365
|
{ value: 'inherit', label: 'System' },
|
|
26331
26366
|
{ value: 'pvAuto', label: 'Auto (PV)' },
|
|
26332
|
-
{ value: 'manual', label: 'Manuell' },
|
|
26333
|
-
{ value: 'off', label: 'Aus' },
|
|
26367
|
+
{ value: 'manual', label: dev.ovumMira === true ? 'Geräteregelung' : 'Manuell' },
|
|
26368
|
+
{ value: 'off', label: dev.ovumMira === true ? 'PV-Anforderung aus' : 'Aus' },
|
|
26334
26369
|
],
|
|
26335
26370
|
};
|
|
26336
26371
|
}
|
|
@@ -27187,6 +27222,9 @@ return res.json(out);
|
|
|
27187
27222
|
const slice = plan.slice(i, i + concurrency);
|
|
27188
27223
|
await Promise.all(slice.map((entry) => applyState(entry)));
|
|
27189
27224
|
}
|
|
27225
|
+
if (this._derivedFlow?.reviewAt && Date.now() >= this._derivedFlow.reviewAt) {
|
|
27226
|
+
this.scheduleDerivedFlowUpdate('measurement-expiry');
|
|
27227
|
+
}
|
|
27190
27228
|
} finally {
|
|
27191
27229
|
this._nwLiveCoreRefreshRunning = false;
|
|
27192
27230
|
}
|
|
@@ -27385,6 +27423,7 @@ return res.json(out);
|
|
|
27385
27423
|
// "Datenpunkte" gemappt wurden. Daher wird im Subscribe-Loop unten auf die lokalen
|
|
27386
27424
|
// Adapter-States (namespace + key) zurückgefallen.
|
|
27387
27425
|
const localUiKeys = [
|
|
27426
|
+
'speicher.dcPvPowerW',
|
|
27388
27427
|
'tarif.statusText', 'tarif.intentStatusText', 'tarif.intentSnapshotAgeMs', 'tarif.intentSnapshotFresh', 'tarif.statusJson',
|
|
27389
27428
|
'tarif.speicherIntentW', 'tarif.speicherIntentStatus', 'tarif.speicherIntentGrund',
|
|
27390
27429
|
'tarif.speicherRequestW', 'tarif.speicherRequestQuelle', 'tarif.speicherRequestGrund',
|
|
@@ -28670,9 +28709,10 @@ return res.json(out);
|
|
|
28670
28709
|
// Nach einem Update kann der neu angelegte totalPowerW-State kurz 0 W enthalten,
|
|
28671
28710
|
// während die bereits vorhandenen Brutto-States noch den echten Farmfluss zeigen.
|
|
28672
28711
|
// Erst nach mindestens einer ausgewerteten Leistungsquelle ist totalPowerW führend.
|
|
28673
|
-
const
|
|
28674
|
-
|
|
28675
|
-
|
|
28712
|
+
const useLegacySigned = signedState !== null && (powerSourcesTotal > 0 || (grossChargeW <= 0 && grossDischargeW <= 0));
|
|
28713
|
+
const signedW = hasBatteryFlow ? batteryFlowState : useLegacySigned ? signedState : grossDischargeW - grossChargeW;
|
|
28714
|
+
const powerSourceKeys = hasBatteryFlow ? ['storageFarm.totalBatteryPowerW']
|
|
28715
|
+
: useLegacySigned ? ['storageFarm.totalPowerW'] : ['storageFarm.totalChargePowerW', 'storageFarm.totalDischargePowerW'];
|
|
28676
28716
|
const chargeW = signedW === null ? null : signedW < 0 ? Math.abs(signedW) : 0;
|
|
28677
28717
|
const dischargeW = signedW === null ? null : signedW > 0 ? signedW : 0;
|
|
28678
28718
|
|
|
@@ -28703,6 +28743,7 @@ return res.json(out);
|
|
|
28703
28743
|
totalPowerW: signedW === null ? null : Math.round(signedW),
|
|
28704
28744
|
chargeW: chargeW === null ? null : Math.round(chargeW),
|
|
28705
28745
|
dischargeW: dischargeW === null ? null : Math.round(dischargeW),
|
|
28746
|
+
powerSourceKeys,
|
|
28706
28747
|
grossChargeW: Math.round(grossChargeW),
|
|
28707
28748
|
grossDischargeW: Math.round(grossDischargeW),
|
|
28708
28749
|
pvTotalW: Math.round(pvTotalW),
|
|
@@ -28837,6 +28878,7 @@ return res.json(out);
|
|
|
28837
28878
|
const maxAgeMs = opts.maxAgeMs === undefined ? this._nwLiveInputMaxAgeMs() : opts.maxAgeMs;
|
|
28838
28879
|
const deadbandW = Number.isFinite(Number(opts.deadbandW)) ? Math.max(0, Number(opts.deadbandW)) : 25;
|
|
28839
28880
|
const strictStale = opts.strictStale === true;
|
|
28881
|
+
const observe = opts.observe === true;
|
|
28840
28882
|
|
|
28841
28883
|
const dps = (this.config && this.config.datapoints && typeof this.config.datapoints === 'object') ? this.config.datapoints : {};
|
|
28842
28884
|
/**
|
|
@@ -28868,11 +28910,10 @@ return res.json(out);
|
|
|
28868
28910
|
* Zusammenhang: Teil von Adapterkern: Lifecycle, Webserver, API, States, EMS-Engine; Aufrufstellen und abhängige States/APIs beim Ändern mitprüfen.
|
|
28869
28911
|
* TypeScript: Parameter, Rückgabewert und verwendete Config-/State-Objekte später explizit typisieren.
|
|
28870
28912
|
*/
|
|
28871
|
-
const readMapped = (key
|
|
28872
|
-
|
|
28873
|
-
|
|
28874
|
-
|
|
28875
|
-
: this._nwGetNumberFromCacheFresh(key, strictStale ? maxAgeMs : null, null, now);
|
|
28913
|
+
const readMapped = (key) => this._nwGetRawNumberFromCache(key, strictStale ? maxAgeMs : null, null, now);
|
|
28914
|
+
const observeMapped = (key) => {
|
|
28915
|
+
// A normalized display mirror cannot supply a physical observation.
|
|
28916
|
+
return readFlowMeasurement(this._nwRawValueCache, key, now, maxAgeMs);
|
|
28876
28917
|
};
|
|
28877
28918
|
/**
|
|
28878
28919
|
* Code-Teil: ageInfo
|
|
@@ -28908,6 +28949,7 @@ return res.json(out);
|
|
|
28908
28949
|
fromSigned: true,
|
|
28909
28950
|
mirror: opts2.mirror !== false,
|
|
28910
28951
|
derived: false,
|
|
28952
|
+
observedAt: opts2.observedAt ?? null,
|
|
28911
28953
|
staleMs: ageInfo(),
|
|
28912
28954
|
};
|
|
28913
28955
|
};
|
|
@@ -28986,10 +29028,13 @@ return res.json(out);
|
|
|
28986
29028
|
const sfEnabled = !!(farmMetrics && farmMetrics.active);
|
|
28987
29029
|
if (farmSelectedForControl) {
|
|
28988
29030
|
let signed = farmMetrics ? numericMeasurement(farmMetrics.totalPowerW) : null;
|
|
29031
|
+
// Converter/dispatch power is not a measurement of a hybrid battery.
|
|
29032
|
+
const observation = observe && farmMetrics
|
|
29033
|
+
? readFlowMeasurement(this.stateCache, 'storageFarm.totalBatteryPowerW', now, maxAgeMs) : null;
|
|
29034
|
+
if (observe) signed = observation?.value ?? null;
|
|
28989
29035
|
if (signed !== null && Number.isFinite(signed)) {
|
|
28990
|
-
//
|
|
28991
|
-
//
|
|
28992
|
-
// Anzeige-Invert darf diesen kanonischen Farmwert nicht ein zweites Mal drehen.
|
|
29036
|
+
// Die Batterie-Nettoleistung der Farm ist bereits pro Speicher normalisiert
|
|
29037
|
+
// (+ Entladen, - Laden) und darf nicht nochmals invertiert werden.
|
|
28993
29038
|
if (Math.abs(signed) <= deadbandW) signed = 0;
|
|
28994
29039
|
const c = signed < 0 ? Math.abs(signed) : 0;
|
|
28995
29040
|
const d = signed > 0 ? signed : 0;
|
|
@@ -29002,6 +29047,7 @@ return res.json(out);
|
|
|
29002
29047
|
fromSigned: true,
|
|
29003
29048
|
derived: false,
|
|
29004
29049
|
mirror: true,
|
|
29050
|
+
observedAt: observation?.ts ?? null,
|
|
29005
29051
|
grossChargeW: farmMetrics.grossChargeW,
|
|
29006
29052
|
grossDischargeW: farmMetrics.grossDischargeW,
|
|
29007
29053
|
staleMs: {
|
|
@@ -29031,15 +29077,23 @@ return res.json(out);
|
|
|
29031
29077
|
};
|
|
29032
29078
|
}
|
|
29033
29079
|
|
|
29034
|
-
const
|
|
29035
|
-
const
|
|
29036
|
-
const
|
|
29080
|
+
const batterySample = observe && batteryMapped ? observeMapped('batteryPower') : null;
|
|
29081
|
+
const chargeSample = observe && chargeMapped ? observeMapped('storageChargePower') : null;
|
|
29082
|
+
const dischargeSample = observe && dischargeMapped ? observeMapped('storageDischargePower') : null;
|
|
29083
|
+
const batterySigned = batteryMapped ? (observe ? batterySample?.value ?? null : readMapped('batteryPower')) : null;
|
|
29084
|
+
const chargeRaw = chargeMapped ? (observe ? chargeSample?.value ?? null : readMapped('storageChargePower')) : null;
|
|
29085
|
+
const dischargeRaw = dischargeMapped ? (observe ? dischargeSample?.value ?? null : readMapped('storageDischargePower')) : null;
|
|
29037
29086
|
|
|
29038
29087
|
// Beide Split-Felder auf denselben DP gemappt = tatsächlich ein signed DP.
|
|
29039
|
-
if (sameChargeDischargeId
|
|
29040
|
-
return fromSigned(chargeRaw, 'sameChargeDischargeSigned', {
|
|
29088
|
+
if (sameChargeDischargeId) {
|
|
29089
|
+
if (chargeRaw !== null) return fromSigned(chargeRaw, 'sameChargeDischargeSigned', { observedAt: chargeSample?.ts });
|
|
29090
|
+
if (observe && dischargeSample) return fromSigned(dischargeSample.value, 'sameChargeDischargeSigned', { observedAt: dischargeSample.ts });
|
|
29041
29091
|
}
|
|
29042
29092
|
|
|
29093
|
+
const completeSplit = chargeSample !== null && dischargeSample !== null;
|
|
29094
|
+
if (observe && !completeSplit && batterySample) {
|
|
29095
|
+
return fromSigned(batterySample.value, 'batterySigned', { observedAt: batterySample.ts });
|
|
29096
|
+
}
|
|
29043
29097
|
// Getrennte Lade-/Entlade-DPs sind autoritativ. Eine fehlende Seite wird als 0 W
|
|
29044
29098
|
// behandelt; sie wird nicht durch Bilanzwerte ersetzt. Das schützt Historie und
|
|
29045
29099
|
// Regelung vor verfälschten Speicherwerten bei konstantem/stalem 0-Wert.
|
|
@@ -29069,19 +29123,20 @@ return res.json(out);
|
|
|
29069
29123
|
fromSigned: false,
|
|
29070
29124
|
derived: false,
|
|
29071
29125
|
mirror: false,
|
|
29126
|
+
observedAt: observe && completeSplit ? Math.min(chargeSample?.ts ?? now, dischargeSample?.ts ?? now) : null,
|
|
29072
29127
|
staleMs: ageInfo(),
|
|
29073
29128
|
};
|
|
29074
29129
|
}
|
|
29075
29130
|
|
|
29076
29131
|
// Signed Batterie-DP ist der Fallback, wenn keine Split-DPs einen Wert liefern.
|
|
29077
29132
|
if (batterySigned !== null) {
|
|
29078
|
-
return fromSigned(batterySigned, 'batterySigned', {
|
|
29133
|
+
return fromSigned(batterySigned, 'batterySigned', { observedAt: batterySample?.ts });
|
|
29079
29134
|
}
|
|
29080
29135
|
|
|
29081
29136
|
// Rechen-Fallback nur, wenn überhaupt kein Speicher-DP konfiguriert ist.
|
|
29082
29137
|
// Wenn ein Speicher-DP konfiguriert, aber aktuell nicht lesbar ist, zeigen wir keinen
|
|
29083
29138
|
// geratenen Wert, damit Historie/Regelung nicht verfälscht werden.
|
|
29084
|
-
if (!anyStorageMapped) {
|
|
29139
|
+
if (!anyStorageMapped && !observe) {
|
|
29085
29140
|
const derived = fromBalance();
|
|
29086
29141
|
if (derived) return derived;
|
|
29087
29142
|
}
|
|
@@ -30803,33 +30858,59 @@ return res.json(out);
|
|
|
30803
30858
|
* Zusammenhang: Teil von Adapterkern: Lifecycle, Webserver, API, States, EMS-Engine; Aufrufstellen und abhängige States/APIs beim Ändern mitprüfen.
|
|
30804
30859
|
* TypeScript: Parameter, Rückgabewert und verwendete Config-/State-Objekte später explizit typisieren.
|
|
30805
30860
|
*/
|
|
30806
|
-
_nwResolveGridImportExportFromCache() {
|
|
30861
|
+
_nwResolveGridImportExportFromCache(opts = {}) {
|
|
30807
30862
|
const gridBuyMapped = this._nwHasMappedDatapoint('gridBuyPower');
|
|
30808
30863
|
const gridSellMapped = this._nwHasMappedDatapoint('gridSellPower');
|
|
30809
30864
|
const gridNetMapped = this._nwHasMappedDatapoint('gridPointPower');
|
|
30810
|
-
const
|
|
30811
|
-
const
|
|
30865
|
+
const observe = opts.observe === true;
|
|
30866
|
+
const now = opts.now ?? Date.now();
|
|
30867
|
+
const maxAgeMs = opts.maxAgeMs ?? this._nwLiveInputMaxAgeMs();
|
|
30812
30868
|
const canonicalRec = this.stateCache && this.stateCache['ems.gridMeasurementFresh'];
|
|
30813
30869
|
const canonicalAge = canonicalRec ? this._nwGetCacheAgeMs('ems.gridMeasurementFresh', now) : null;
|
|
30814
|
-
const canonicalKnown = !!(canonicalRec && canonicalAge !== null && canonicalAge <= Math.max(maxAgeMs, 15000));
|
|
30870
|
+
const canonicalKnown = !observe && !!(canonicalRec && canonicalAge !== null && canonicalAge <= Math.max(maxAgeMs, 15000));
|
|
30815
30871
|
const readFresh = (key, mapped) => mapped ? this._nwGetNumberFromCacheFresh(key, maxAgeMs, null, now) : null;
|
|
30816
|
-
|
|
30872
|
+
const observeMapped = (key, mapped) => observe && mapped ? readFlowMeasurement(this._nwRawValueCache, key, now, maxAgeMs) : null;
|
|
30873
|
+
const signed = observeMapped('gridPointPower', gridNetMapped);
|
|
30874
|
+
const buy = observeMapped('gridBuyPower', gridBuyMapped);
|
|
30875
|
+
const sell = observeMapped('gridSellPower', gridSellMapped);
|
|
30876
|
+
const localNvp = observe ? this._nvpFreshnessSnapshot : null;
|
|
30877
|
+
const latestPhysicalTs = Math.max(signed?.ts ?? 0, buy?.ts ?? 0, sell?.ts ?? 0);
|
|
30878
|
+
const nvpUnavailable = localNvp?.usable === false && Number.isFinite(localNvp.ts)
|
|
30879
|
+
&& localNvp.ts <= now && now - localNvp.ts <= Math.min(maxAgeMs, 15000)
|
|
30880
|
+
&& (localNvp.connected === false || latestPhysicalTs <= localNvp.ts);
|
|
30881
|
+
const invert = observe && this.config?.settings?.flowInvertGrid === true;
|
|
30882
|
+
const measuredImport = invert ? sell : buy;
|
|
30883
|
+
const measuredExport = invert ? buy : sell;
|
|
30884
|
+
const resolved = resolveNvpDisplay({
|
|
30817
30885
|
maxAgeMs,
|
|
30818
|
-
canonicalKnown,
|
|
30819
|
-
canonicalFresh: canonicalKnown && typeof canonicalRec.value === 'boolean' ? canonicalRec.value : null,
|
|
30820
|
-
|
|
30886
|
+
canonicalKnown: canonicalKnown || nvpUnavailable,
|
|
30887
|
+
canonicalFresh: nvpUnavailable ? false : canonicalKnown && typeof canonicalRec.value === 'boolean' ? canonicalRec.value : null,
|
|
30888
|
+
// The EMS mirror carries its publication time, so it cannot establish
|
|
30889
|
+
// the age of a physical sample for an observed building balance.
|
|
30890
|
+
canonicalNetW: observe ? null : this._nwGetNumberFromCacheFresh('ems.gridPowerRawW', maxAgeMs, null, now),
|
|
30821
30891
|
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,
|
|
30892
|
+
canonicalStatus: nvpUnavailable ? localNvp.status : this.stateCache?.['ems.gridMeasurementStatus']?.value,
|
|
30893
|
+
gridNetRaw: observe ? (signed ? (invert ? -signed.value : signed.value) : null) : readFresh('gridPointPower', gridNetMapped),
|
|
30894
|
+
gridBuyRaw: observe ? measuredImport?.value ?? null : readFresh('gridBuyPower', gridBuyMapped),
|
|
30895
|
+
gridSellRaw: observe ? measuredExport?.value ?? null : readFresh('gridSellPower', gridSellMapped),
|
|
30896
|
+
gridBuyTs: observe ? measuredImport?.ts : this.stateCache?.gridBuyPower?.ts,
|
|
30897
|
+
gridSellTs: observe ? measuredExport?.ts : this.stateCache?.gridSellPower?.ts,
|
|
30828
30898
|
maxSkewMs: this.config?.diagnostics?.nvpMaxSkewMs,
|
|
30829
30899
|
gridBuyMapped,
|
|
30830
30900
|
gridSellMapped,
|
|
30831
30901
|
gridNetMapped,
|
|
30832
30902
|
});
|
|
30903
|
+
if (!observe) return resolved;
|
|
30904
|
+
|
|
30905
|
+
let observedAt = null;
|
|
30906
|
+
const splitComplete = (!gridBuyMapped || buy !== null) && (!gridSellMapped || sell !== null);
|
|
30907
|
+
if (resolved.sampleSource === 'signed') observedAt = signed.ts;
|
|
30908
|
+
else if (splitComplete) {
|
|
30909
|
+
if (resolved.sampleSource === 'split') observedAt = Math.min(measuredImport.ts, measuredExport.ts);
|
|
30910
|
+
else if (resolved.sampleSource === 'import') observedAt = measuredImport.ts;
|
|
30911
|
+
else if (resolved.sampleSource === 'export') observedAt = measuredExport.ts;
|
|
30912
|
+
}
|
|
30913
|
+
return { ...resolved, observedAt };
|
|
30833
30914
|
}
|
|
30834
30915
|
|
|
30835
30916
|
/**
|
|
@@ -31124,7 +31205,7 @@ return res.json(out);
|
|
|
31124
31205
|
gridSellW,
|
|
31125
31206
|
hasGrid,
|
|
31126
31207
|
} = this._nwResolveGridImportExportFromCache();
|
|
31127
|
-
const historyCoreMaxAgeMs =
|
|
31208
|
+
const historyCoreMaxAgeMs = this._nwLiveInputMaxAgeMs();
|
|
31128
31209
|
// History samples are observations, not a refresh of the last cached value.
|
|
31129
31210
|
// Missing timestamps, stale values and missing measurements remain gaps.
|
|
31130
31211
|
const readHistory = (key, maxAgeMs = historyCoreMaxAgeMs) => {
|
|
@@ -31152,8 +31233,9 @@ return res.json(out);
|
|
|
31152
31233
|
? this._nwGetStorageControlAuthority()
|
|
31153
31234
|
: { selectedTopology: 'none', writerActive: false };
|
|
31154
31235
|
const selectedStorageTopologyHist = String(storageAuthorityHist.selectedTopology || 'none');
|
|
31155
|
-
const storageFlowHist = this._nwResolveBatteryFlowFromCache({ now, strictStale: true });
|
|
31156
|
-
const storageMissing =
|
|
31236
|
+
const storageFlowHist = this._nwResolveBatteryFlowFromCache({ now, strictStale: true, observe: true, maxAgeMs: historyCoreMaxAgeMs });
|
|
31237
|
+
const storageMissing = !Number.isFinite(storageFlowHist.observedAt)
|
|
31238
|
+
|| ['missing', 'mapped-missing', 'storageFarm-missing-power', 'storageFarm-unavailable'].includes(storageFlowHist.src);
|
|
31157
31239
|
const farmPowerAge = storageFlowHist.staleMs && numericMeasurement(storageFlowHist.staleMs.farmPower);
|
|
31158
31240
|
const farmPowerStale = selectedStorageTopologyHist === 'farm'
|
|
31159
31241
|
&& (farmPowerAge === null || farmPowerAge === undefined || farmPowerAge > historyCoreMaxAgeMs);
|
|
@@ -31204,28 +31286,32 @@ return res.json(out);
|
|
|
31204
31286
|
&& this.config.storage
|
|
31205
31287
|
&& String(this.config.storage.coupling || '').trim().toLowerCase() === 'dc');
|
|
31206
31288
|
|
|
31207
|
-
if (!pvTotalFromDerived && sfEnabled
|
|
31208
|
-
|
|
31209
|
-
|
|
31210
|
-
|
|
31211
|
-
now,
|
|
31212
|
-
|
|
31213
|
-
|
|
31214
|
-
|
|
31215
|
-
|
|
31289
|
+
if (!pvTotalFromDerived && sfEnabled) {
|
|
31290
|
+
const farmPv = readHistory('storageFarm.totalPvPowerW');
|
|
31291
|
+
if (farmPv !== null && typeof this._nwMergeStorageFarmPvWithBase === 'function') {
|
|
31292
|
+
const baseSourceId = String(historyDps.pvPower || historyDps.productionTotal || '').trim();
|
|
31293
|
+
const merged = this._nwMergeStorageFarmPvWithBase(pvTotal ?? 0, { now, metrics: farmMetricsHist, baseSourceId });
|
|
31294
|
+
pvTotal = baseSourceId && pvW === null ? null : Math.max(0, merged.totalW);
|
|
31295
|
+
} else if ((readHistory('storageFarm.pvSourcesTotal') ?? 0) > 0 || farmMetricsHist.pvSources?.length) {
|
|
31296
|
+
pvTotal = null;
|
|
31297
|
+
}
|
|
31216
31298
|
} else if (!pvTotalFromDerived && singleStorageDcEnabled) {
|
|
31299
|
+
const dcId = String(nwNormalizeStorageDatapointsConfig(this.config.storage).dcPvPowerObjectId || historyDps.storagePvPower || '').trim();
|
|
31300
|
+
const acId = String(historyDps.pvPower || historyDps.productionTotal || '').trim();
|
|
31217
31301
|
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
|
-
}
|
|
31302
|
+
if (dcId) {
|
|
31303
|
+
const sameSource = !!acId && nwPhysicalPvSourceKey(acId) === nwPhysicalPvSourceKey(dcId);
|
|
31304
|
+
if (sameSource) pvTotal = pvW ?? (dcValueW === null ? null : Math.abs(dcValueW));
|
|
31305
|
+
else pvTotal = dcValueW === null || (acId && pvW === null) ? null : (pvTotal ?? 0) + Math.abs(dcValueW);
|
|
31226
31306
|
}
|
|
31227
31307
|
}
|
|
31228
31308
|
|
|
31309
|
+
// The live balance explicitly rejected a partial source set. History must
|
|
31310
|
+
// not reconstruct a plausible sum from only the remaining generation meters.
|
|
31311
|
+
const canonicalPv = Object.getOwnPropertyDescriptor(this.stateCache || {}, 'derived.core.pv.totalW');
|
|
31312
|
+
if (canonicalPv && 'value' in canonicalPv && canonicalPv.value && typeof canonicalPv.value === 'object'
|
|
31313
|
+
&& Object.getOwnPropertyDescriptor(canonicalPv.value, 'value')?.value === null) pvTotal = null;
|
|
31314
|
+
|
|
31229
31315
|
// Ohne expliziten Energiefluss-Override folgt die Historie weiterhin der
|
|
31230
31316
|
// aktiven Speichertopologie. Ein vorhandener, gueltiger Override bleibt aber
|
|
31231
31317
|
// autoritativ und wird nicht durch Writer-/App-Lifecycle auf null gesetzt.
|
|
@@ -31238,7 +31324,7 @@ return res.json(out);
|
|
|
31238
31324
|
}
|
|
31239
31325
|
}
|
|
31240
31326
|
|
|
31241
|
-
let loadTotal = Number.isFinite(loadW)
|
|
31327
|
+
let loadTotal = Number.isFinite(loadW) && loadW >= 0 ? loadW : null;
|
|
31242
31328
|
const chg = Number.isFinite(chgW) ? Math.max(0, chgW) : null;
|
|
31243
31329
|
const dchg = Number.isFinite(dchgW) ? Math.max(0, dchgW) : null;
|
|
31244
31330
|
const evAbs = Number.isFinite(evW) ? Math.abs(evW) : null;
|
|
@@ -32545,23 +32631,43 @@ return res.json(out);
|
|
|
32545
32631
|
scheduleDerivedFlowUpdate(reason = '') {
|
|
32546
32632
|
if (this._nwShuttingDown) return;
|
|
32547
32633
|
// Throttle derived calculations to avoid excessive state writes on high-frequency meters.
|
|
32548
|
-
const
|
|
32549
|
-
|
|
32550
|
-
|
|
32551
|
-
|
|
32552
|
-
|
|
32553
|
-
|
|
32554
|
-
if (
|
|
32634
|
+
const flow = this._derivedFlow;
|
|
32635
|
+
flow.lastReason = reason;
|
|
32636
|
+
if (flow.running) {
|
|
32637
|
+
flow.rerun = true;
|
|
32638
|
+
return;
|
|
32639
|
+
}
|
|
32640
|
+
if (flow.pending) return;
|
|
32555
32641
|
|
|
32556
|
-
const
|
|
32557
|
-
const delay =
|
|
32642
|
+
const now = Date.now();
|
|
32643
|
+
const delay = Math.max(0, (flow.minIntervalMs ?? 250) - (now - (flow.lastRunMs ?? 0)));
|
|
32558
32644
|
|
|
32559
|
-
|
|
32560
|
-
this._nwSetTimeout(() => {
|
|
32561
|
-
|
|
32562
|
-
|
|
32563
|
-
|
|
32564
|
-
|
|
32645
|
+
flow.pending = true;
|
|
32646
|
+
this._nwSetTimeout(async () => {
|
|
32647
|
+
flow.pending = false;
|
|
32648
|
+
flow.running = true;
|
|
32649
|
+
flow.lastRunMs = Date.now();
|
|
32650
|
+
try {
|
|
32651
|
+
await this.updateDerivedFlowStates(flow.lastReason || 'scheduled');
|
|
32652
|
+
if (flow.retryTimer) this._nwClearTimeout(flow.retryTimer);
|
|
32653
|
+
flow.retryTimer = null;
|
|
32654
|
+
flow.retryDelayMs = 0;
|
|
32655
|
+
} catch (e) {
|
|
32656
|
+
this.log.debug(`[derivedFlow] ${e?.message || e}`);
|
|
32657
|
+
if (!this._nwShuttingDown && !flow.retryTimer) {
|
|
32658
|
+
flow.retryDelayMs = Math.min(30000, (flow.retryDelayMs || 500) * 2);
|
|
32659
|
+
flow.retryTimer = this._nwSetTimeout(() => {
|
|
32660
|
+
flow.retryTimer = null;
|
|
32661
|
+
this.scheduleDerivedFlowUpdate('publication-retry');
|
|
32662
|
+
}, flow.retryDelayMs);
|
|
32663
|
+
}
|
|
32664
|
+
} finally {
|
|
32665
|
+
flow.running = false;
|
|
32666
|
+
if (flow.rerun) {
|
|
32667
|
+
flow.rerun = false;
|
|
32668
|
+
this.scheduleDerivedFlowUpdate(flow.lastReason);
|
|
32669
|
+
}
|
|
32670
|
+
}
|
|
32565
32671
|
}, delay);
|
|
32566
32672
|
}
|
|
32567
32673
|
/**
|
|
@@ -32570,14 +32676,32 @@ return res.json(out);
|
|
|
32570
32676
|
* Zusammenhang: Teil von Adapterkern: Lifecycle, Webserver, API, States, EMS-Engine; Aufrufstellen und abhängige States/APIs beim Ändern mitprüfen.
|
|
32571
32677
|
* TypeScript: Parameter, Rückgabewert und verwendete Config-/State-Objekte später explizit typisieren.
|
|
32572
32678
|
*/
|
|
32679
|
+
async _nwMissingTemplatePvSource(key, id, now) {
|
|
32680
|
+
if (!id || id !== nwDefaultFlowMappings[key] || this.stateCache?.[key]) return false;
|
|
32681
|
+
// An untouched example mapping may have no ioBroker object at all. A real
|
|
32682
|
+
// meter, a previous observation, and a database error all keep it required.
|
|
32683
|
+
const previous = this._nwTemplatePvCheck;
|
|
32684
|
+
if (previous?.id === id && previous.until > now) return previous.absent;
|
|
32685
|
+
try {
|
|
32686
|
+
const object = await this.getForeignObjectAsync(id);
|
|
32687
|
+
const absent = object === null || object === undefined;
|
|
32688
|
+
this._nwTemplatePvCheck = { id, absent, until: now + 60000 };
|
|
32689
|
+
return absent && !this.stateCache?.[key];
|
|
32690
|
+
} catch { return false; }
|
|
32691
|
+
}
|
|
32692
|
+
|
|
32573
32693
|
async updateDerivedFlowStates(reason = '') {
|
|
32574
32694
|
// Building consumption can be derived from the power balance at NVP:
|
|
32575
32695
|
// load = (PV + other production) + gridImport + batteryDischarge - gridExport - batteryCharge
|
|
32576
32696
|
// If no direct house meter (consumptionTotal) is configured, we use this as fallback for the UI.
|
|
32577
32697
|
|
|
32698
|
+
// Take the measurement snapshot after asynchronous inventory/metadata reads.
|
|
32699
|
+
await this._derivedRefreshPvInvertersCache(false);
|
|
32700
|
+
const pvMeterKey = this._nwHasMappedDatapoint('pvPower') ? 'pvPower' : 'productionTotal';
|
|
32701
|
+
const pvMeterId = String(this.config?.datapoints?.[pvMeterKey] || '').trim();
|
|
32702
|
+
const missingTemplatePv = await this._nwMissingTemplatePvSource(pvMeterKey, pvMeterId, Date.now());
|
|
32578
32703
|
const ts = Date.now();
|
|
32579
|
-
const
|
|
32580
|
-
const liveMaxAgeMs = Math.max(10000, (configuredAgeSec !== null && configuredAgeSec > 0 ? configuredAgeSec : 60) * 1000);
|
|
32704
|
+
const liveMaxAgeMs = this._nwLiveInputMaxAgeMs();
|
|
32581
32705
|
const inputTimes = [];
|
|
32582
32706
|
const pvTimes = [];
|
|
32583
32707
|
const producerTimes = [];
|
|
@@ -32590,23 +32714,19 @@ return res.json(out);
|
|
|
32590
32714
|
};
|
|
32591
32715
|
const oldestTime = (times) => times.length ? Math.min(...times) : ts;
|
|
32592
32716
|
|
|
32593
|
-
// Keep PV-inverter auto-cache reasonably fresh (cheap no-op when not due)
|
|
32594
|
-
await this._derivedRefreshPvInvertersCache(false);
|
|
32595
|
-
|
|
32596
32717
|
const pvPowerMapped = this._nwHasMappedDatapoint('pvPower');
|
|
32597
32718
|
const prodTotalMapped = this._nwHasMappedDatapoint('productionTotal');
|
|
32598
32719
|
const consumptionMapped = this._nwHasMappedDatapoint('consumptionTotal');
|
|
32599
32720
|
|
|
32600
32721
|
// --- Grid ---
|
|
32601
32722
|
const {
|
|
32602
|
-
gridBuyRaw,
|
|
32603
|
-
gridSellRaw,
|
|
32604
32723
|
gridNetRaw,
|
|
32605
32724
|
gridBuyW,
|
|
32606
32725
|
gridSellW,
|
|
32607
32726
|
hasGrid,
|
|
32608
32727
|
src: gridSrc,
|
|
32609
|
-
|
|
32728
|
+
observedAt: gridObservedAt,
|
|
32729
|
+
} = this._nwResolveGridImportExportFromCache({ now: ts, maxAgeMs: liveMaxAgeMs, observe: true });
|
|
32610
32730
|
|
|
32611
32731
|
// --- Storage ---
|
|
32612
32732
|
// Normalize storage power centrally:
|
|
@@ -32614,7 +32734,7 @@ return res.json(out);
|
|
|
32614
32734
|
// settings.flowInvertBattery flips that signed value before splitting.
|
|
32615
32735
|
// Separate charge/discharge datapoints remain supported, but stale/legacy mirrored
|
|
32616
32736
|
// 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 });
|
|
32737
|
+
const storageFlow = this._nwResolveBatteryFlowFromCache({ now: ts, strictStale: true, maxAgeMs: liveMaxAgeMs, observe: true });
|
|
32618
32738
|
const chargeW = Math.max(0, Number(storageFlow.chargeW) || 0);
|
|
32619
32739
|
const dischargeW = Math.max(0, Number(storageFlow.dischargeW) || 0);
|
|
32620
32740
|
const storageSrc = storageFlow.src || 'missing';
|
|
@@ -32671,9 +32791,7 @@ return res.json(out);
|
|
|
32671
32791
|
} else {
|
|
32672
32792
|
// Auto: sum all PV_INVERTER devices from nexowatt-devices
|
|
32673
32793
|
const pvAuto = this._derivedFlow?.auto?.pvInverters;
|
|
32674
|
-
|
|
32675
|
-
const staleMs = Math.max(10 * 1000, (Number.isFinite(staleSec) ? staleSec : 60) * 1000);
|
|
32676
|
-
|
|
32794
|
+
pvBaseSourceIds = [];
|
|
32677
32795
|
let sum = 0;
|
|
32678
32796
|
let used = 0;
|
|
32679
32797
|
let offline = 0;
|
|
@@ -32685,7 +32803,7 @@ return res.json(out);
|
|
|
32685
32803
|
|
|
32686
32804
|
const connected = (cRec && cRec.val !== undefined) ? !!cRec.val : true;
|
|
32687
32805
|
const isOffline = (oRec && oRec.val !== undefined) ? !!oRec.val : false;
|
|
32688
|
-
const ageOk = (pRec && Number.isFinite(Number(pRec.ts))) ? ((ts - Number(pRec.ts)) <=
|
|
32806
|
+
const ageOk = (pRec && Number.isFinite(Number(pRec.ts))) ? ((ts - Number(pRec.ts)) <= liveMaxAgeMs) : false;
|
|
32689
32807
|
|
|
32690
32808
|
if (!connected || isOffline || !ageOk || (pRec?.q !== undefined && pRec.q !== 0)) {
|
|
32691
32809
|
offline++;
|
|
@@ -32734,8 +32852,24 @@ return res.json(out);
|
|
|
32734
32852
|
let pvDcIncluded = false;
|
|
32735
32853
|
let pvFarmMerge = null;
|
|
32736
32854
|
let pvTotalW = pvAcW;
|
|
32855
|
+
const siteMeterExpected = (pvPowerMapped || prodTotalMapped) && (!missingTemplatePv || !!this.stateCache?.[pvMeterKey]);
|
|
32856
|
+
const sitePvExpected = siteMeterExpected || !!this._derivedFlow?.auto?.pvInverters?.list?.length;
|
|
32857
|
+
const siteKey = nwPhysicalPvSourceKey(pvMeterId) || pvMeterId.toLowerCase();
|
|
32858
|
+
// A collection of other inverters cannot prove the output of a failed site meter.
|
|
32859
|
+
const sitePvValid = pvSource !== 'missing' && !pvSource.includes('incomplete')
|
|
32860
|
+
&& (!siteMeterExpected || pvAcRaw !== null || pvBaseSourceIds.some(id => (nwPhysicalPvSourceKey(id) || id.toLowerCase()) === siteKey));
|
|
32861
|
+
let pvObserved = sitePvValid || (!sitePvExpected && !missingTemplatePv);
|
|
32737
32862
|
|
|
32738
32863
|
if (sfEnabled && typeof this._nwMergeStorageFarmPvWithBase === 'function') {
|
|
32864
|
+
const farmPvExpected = (this._nwGetNumberFromCache('storageFarm.pvSourcesTotal') ?? 0) > 0 || !!farmMetrics.pvSources?.length;
|
|
32865
|
+
const farmPvSample = farmPvExpected ? readLive('storageFarm.totalPvPowerW', pvTimes) : null;
|
|
32866
|
+
const farmPvValid = farmPvSample !== null;
|
|
32867
|
+
if (farmPvExpected) {
|
|
32868
|
+
const farmCoversSite = siteMeterExpected && !this._derivedFlow?.auto?.pvInverters?.list?.length
|
|
32869
|
+
&& farmMetrics.pvSources?.some(row => row.online === true && (nwPhysicalPvSourceKey(row.id) || String(row.id).toLowerCase()) === siteKey);
|
|
32870
|
+
pvObserved = (!sitePvExpected || sitePvValid || farmCoversSite) && farmPvValid;
|
|
32871
|
+
if ((!sitePvExpected || farmCoversSite) && farmPvValid) pvSource = 'farm:pv-sources';
|
|
32872
|
+
}
|
|
32739
32873
|
pvFarmMerge = this._nwMergeStorageFarmPvWithBase(pvAcW, {
|
|
32740
32874
|
now: ts,
|
|
32741
32875
|
metrics: farmMetrics,
|
|
@@ -32750,24 +32884,30 @@ return res.json(out);
|
|
|
32750
32884
|
if (pvFarmMerge.farmFallbackUsed && pvSource === 'missing') pvSource = 'farm:pv-sources';
|
|
32751
32885
|
else if (pvFarmMerge.farmAddedW > 0) pvSource = pvSource === 'missing' ? 'farm:pv-sources' : `${pvSource}+farm`;
|
|
32752
32886
|
} else if (singleStorageDcEnabled) {
|
|
32753
|
-
const
|
|
32754
|
-
|
|
32755
|
-
|
|
32756
|
-
|
|
32757
|
-
|
|
32758
|
-
|
|
32759
|
-
|
|
32760
|
-
|
|
32761
|
-
|
|
32762
|
-
|
|
32763
|
-
if (pvSource === 'missing') pvSource = pvDcSource;
|
|
32887
|
+
const dcId = String(nwNormalizeStorageDatapointsConfig(this.config.storage).dcPvPowerObjectId
|
|
32888
|
+
|| this._nwStorageMeasurementFallback?.datapoints?.dcPvPowerObjectId
|
|
32889
|
+
|| this._nwStorageMeasurementFallback?.dcPvPowerObjectId || this.config.datapoints?.storagePvPower || '').trim();
|
|
32890
|
+
if (dcId) {
|
|
32891
|
+
const dcKey = nwPhysicalPvSourceKey(dcId) || dcId.toLowerCase();
|
|
32892
|
+
const duplicate = pvBaseSourceIds.some(id => (nwPhysicalPvSourceKey(id) || id.toLowerCase()) === dcKey);
|
|
32893
|
+
const dcCoversMissingSite = dcKey === siteKey && !this._derivedFlow?.auto?.pvInverters?.list?.length;
|
|
32894
|
+
const dc = readLive('speicher.dcPvPowerW', pvTimes);
|
|
32895
|
+
if (dc === null) {
|
|
32896
|
+
if (!duplicate || !sitePvValid) pvObserved = false;
|
|
32764
32897
|
} else {
|
|
32765
|
-
|
|
32766
|
-
|
|
32767
|
-
|
|
32768
|
-
pvTotalW =
|
|
32898
|
+
pvDcW = Math.abs(dc);
|
|
32899
|
+
pvDcSource = 'storage:dc';
|
|
32900
|
+
if (duplicate && sitePvValid) {
|
|
32901
|
+
pvTotalW = pvAcW;
|
|
32902
|
+
} else {
|
|
32769
32903
|
pvDcIncluded = true;
|
|
32904
|
+
pvTotalW = pvAcW + pvDcW;
|
|
32905
|
+
if (!sitePvValid && (!sitePvExpected || dcCoversMissingSite)) {
|
|
32906
|
+
pvObserved = true;
|
|
32907
|
+
pvSource = pvDcSource;
|
|
32908
|
+
}
|
|
32770
32909
|
}
|
|
32910
|
+
pvBaseSourceIds.push(dcId);
|
|
32771
32911
|
}
|
|
32772
32912
|
}
|
|
32773
32913
|
}
|
|
@@ -32832,33 +32972,13 @@ return res.json(out);
|
|
|
32832
32972
|
|
|
32833
32973
|
// A balance is usable only with all configured contributors observed.
|
|
32834
32974
|
// 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
|
-
}
|
|
32975
|
+
const gridObserved = hasGrid && Number.isFinite(gridObservedAt);
|
|
32976
|
+
if (gridObserved) gridTimes.push(gridObservedAt);
|
|
32846
32977
|
const storageConfigured = selectedStorageTopologyLive !== 'none'
|
|
32847
32978
|
|| ['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
|
-
}
|
|
32979
|
+
const measuredStorage = Number.isFinite(storageFlow.observedAt);
|
|
32980
|
+
const storageObserved = measuredStorage || !storageConfigured;
|
|
32981
|
+
if (measuredStorage) storageTimes.push(storageFlow.observedAt);
|
|
32862
32982
|
inputTimes.push(...pvTimes, ...producerTimes, ...gridTimes, ...storageTimes);
|
|
32863
32983
|
const balanceObserved = gridObserved && storageObserved && pvObserved && !missingProducer;
|
|
32864
32984
|
const loadTotalW = directLoadTotalW !== null ? directLoadTotalW
|
|
@@ -32893,6 +33013,9 @@ return res.json(out);
|
|
|
32893
33013
|
const loadTotalRound = loadTotalW !== null ? Math.round(loadTotalW) : null;
|
|
32894
33014
|
const loadRestRound = loadRestW !== null ? Math.round(loadRestW) : null;
|
|
32895
33015
|
const restTimestamp = Math.min(loadTimestamp, oldestTime(restTimes));
|
|
33016
|
+
this._derivedFlow.reviewAt = inputTimes.length || directTimes.length || restTimes.length
|
|
33017
|
+
? Math.min(oldestTime(inputTimes), oldestTime(directTimes), oldestTime(restTimes)) + liveMaxAgeMs + 1
|
|
33018
|
+
: 0;
|
|
32896
33019
|
|
|
32897
33020
|
const tsShadow = this._nwRunEnergyFlowTsShadowComparison({
|
|
32898
33021
|
ts,
|
|
@@ -32963,38 +33086,35 @@ return res.json(out);
|
|
|
32963
33086
|
: 'js-runtime';
|
|
32964
33087
|
const energyFlowProductiveTsActive = energyFlowSourceState === 'ts-candidate' || energyFlowSourceState === 'ts-normal';
|
|
32965
33088
|
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
33089
|
try {
|
|
32970
33090
|
if (this._derivedFlow?.last?.energyFlowSource !== energyFlowSourceState) {
|
|
32971
|
-
this._derivedFlow.last.energyFlowSource = energyFlowSourceState;
|
|
32972
33091
|
await this.setStateAsync('derived.core.building.energyFlowSource', { val: energyFlowSourceState, ack: true });
|
|
33092
|
+
this._derivedFlow.last.energyFlowSource = energyFlowSourceState;
|
|
32973
33093
|
}
|
|
32974
33094
|
if (this._derivedFlow?.last?.tsLiveTestState !== energyFlowLiveTestState) {
|
|
32975
|
-
this._derivedFlow.last.tsLiveTestState = energyFlowLiveTestState;
|
|
32976
33095
|
await this.setStateAsync('derived.core.building.tsLiveTestState', { val: energyFlowLiveTestState, ack: true });
|
|
33096
|
+
this._derivedFlow.last.tsLiveTestState = energyFlowLiveTestState;
|
|
32977
33097
|
}
|
|
32978
33098
|
if (this._derivedFlow?.last?.tsProductiveActive !== energyFlowProductiveTsActive) {
|
|
32979
|
-
this._derivedFlow.last.tsProductiveActive = energyFlowProductiveTsActive;
|
|
32980
33099
|
await this.setStateAsync('derived.core.building.tsProductiveActive', { val: energyFlowProductiveTsActive, ack: true });
|
|
33100
|
+
this._derivedFlow.last.tsProductiveActive = energyFlowProductiveTsActive;
|
|
32981
33101
|
}
|
|
32982
33102
|
} catch (_eTsLiveState) {}
|
|
32983
33103
|
|
|
32984
33104
|
// --- Update adapter states (for App-Center mapping / debugging) ---
|
|
32985
33105
|
if (this._derivedFlow?.last?.loadTotalW !== publishLoadTotalRound || this._derivedFlow?.last?.loadTimestamp !== loadTimestamp) {
|
|
33106
|
+
await this.setStateAsync('derived.core.building.loadTotalW', { val: publishLoadTotalRound, ack: true, ts: loadTimestamp });
|
|
32986
33107
|
this._derivedFlow.last.loadTimestamp = loadTimestamp;
|
|
32987
33108
|
this._derivedFlow.last.loadTotalW = publishLoadTotalRound;
|
|
32988
|
-
await this.setStateAsync('derived.core.building.loadTotalW', { val: publishLoadTotalRound, ack: true, ts: loadTimestamp });
|
|
32989
33109
|
}
|
|
32990
33110
|
if (this._derivedFlow?.last?.loadRestW !== publishLoadRestRound || this._derivedFlow?.last?.restTimestamp !== restTimestamp) {
|
|
33111
|
+
await this.setStateAsync('derived.core.building.loadRestW', { val: publishLoadRestRound, ack: true, ts: restTimestamp });
|
|
32991
33112
|
this._derivedFlow.last.restTimestamp = restTimestamp;
|
|
32992
33113
|
this._derivedFlow.last.loadRestW = publishLoadRestRound;
|
|
32993
|
-
await this.setStateAsync('derived.core.building.loadRestW', { val: publishLoadRestRound, ack: true, ts: restTimestamp });
|
|
32994
33114
|
}
|
|
32995
33115
|
if (this._derivedFlow?.last?.loadSource !== loadTotalSource) {
|
|
32996
|
-
this._derivedFlow.last.loadSource = loadTotalSource;
|
|
32997
33116
|
await this.setStateAsync('derived.core.building.loadSource', { val: loadTotalSource, ack: true });
|
|
33117
|
+
this._derivedFlow.last.loadSource = loadTotalSource;
|
|
32998
33118
|
}
|
|
32999
33119
|
|
|
33000
33120
|
const pvAcRound = Math.round(pvAcW);
|
|
@@ -33003,27 +33123,27 @@ return res.json(out);
|
|
|
33003
33123
|
|
|
33004
33124
|
const publishPvAcW = pvObserved ? pvAcRound : null;
|
|
33005
33125
|
if (this._derivedFlow?.last?.pvAcW !== publishPvAcW || this._derivedFlow?.last?.pvTimestamp !== oldestTime(pvTimes)) {
|
|
33006
|
-
this._derivedFlow.last.pvAcW = publishPvAcW;
|
|
33007
33126
|
await this.setStateAsync('derived.core.pv.acW', { val: publishPvAcW, ack: true, ts: oldestTime(pvTimes) });
|
|
33127
|
+
this._derivedFlow.last.pvAcW = publishPvAcW;
|
|
33008
33128
|
}
|
|
33009
33129
|
const publishPvDcW = pvObserved ? pvDcRound : null;
|
|
33010
33130
|
if (this._derivedFlow?.last?.pvDcW !== publishPvDcW || this._derivedFlow?.last?.pvTimestamp !== oldestTime(pvTimes)) {
|
|
33011
|
-
this._derivedFlow.last.pvDcW = publishPvDcW;
|
|
33012
33131
|
await this.setStateAsync('derived.core.pv.dcW', { val: publishPvDcW, ack: true, ts: oldestTime(pvTimes) });
|
|
33132
|
+
this._derivedFlow.last.pvDcW = publishPvDcW;
|
|
33013
33133
|
}
|
|
33014
33134
|
const publishPvTotalW = pvObserved ? pvTotalRound : null;
|
|
33015
33135
|
if (this._derivedFlow?.last?.pvTotalW !== publishPvTotalW || this._derivedFlow?.last?.pvTimestamp !== oldestTime(pvTimes)) {
|
|
33016
|
-
this._derivedFlow.last.pvTotalW = publishPvTotalW;
|
|
33017
33136
|
await this.setStateAsync('derived.core.pv.totalW', { val: publishPvTotalW, ack: true, ts: oldestTime(pvTimes) });
|
|
33137
|
+
this._derivedFlow.last.pvTotalW = publishPvTotalW;
|
|
33018
33138
|
}
|
|
33019
33139
|
|
|
33020
33140
|
this._derivedFlow.last.pvTimestamp = oldestTime(pvTimes);
|
|
33021
33141
|
const publishExtraW = missingProducer ? null : Math.round(producerSumW);
|
|
33022
33142
|
const producerTimestamp = oldestTime(producerTimes);
|
|
33023
33143
|
if (this._derivedFlow.last.extraProductionW !== publishExtraW || this._derivedFlow.last.extraTimestamp !== producerTimestamp) {
|
|
33144
|
+
await this.setStateAsync('derived.core.production.extraW', { val: publishExtraW, ack: true, ts: producerTimestamp });
|
|
33024
33145
|
this._derivedFlow.last.extraProductionW = publishExtraW;
|
|
33025
33146
|
this._derivedFlow.last.extraTimestamp = producerTimestamp;
|
|
33026
|
-
await this.setStateAsync('derived.core.production.extraW', { val: publishExtraW, ack: true, ts: producerTimestamp });
|
|
33027
33147
|
}
|
|
33028
33148
|
this.updateValue('derived.core.production.extraW', publishExtraW, producerTimestamp, { raw: false });
|
|
33029
33149
|
|
|
@@ -33031,24 +33151,24 @@ return res.json(out);
|
|
|
33031
33151
|
const pvCapacityLimitRound = Math.round(pvPlausibility.capacityLimitW);
|
|
33032
33152
|
const pvDuplicateSuppressedRound = Math.round(pvDuplicateSuppressedW);
|
|
33033
33153
|
if (this._derivedFlow?.last?.pvRawTotalW !== pvRawTotalRound) {
|
|
33034
|
-
this._derivedFlow.last.pvRawTotalW = pvRawTotalRound;
|
|
33035
33154
|
await this.setStateAsync('derived.core.pv.rawTotalW', { val: pvRawTotalRound, ack: true });
|
|
33155
|
+
this._derivedFlow.last.pvRawTotalW = pvRawTotalRound;
|
|
33036
33156
|
}
|
|
33037
33157
|
if (this._derivedFlow?.last?.pvCapacityLimitW !== pvCapacityLimitRound) {
|
|
33038
|
-
this._derivedFlow.last.pvCapacityLimitW = pvCapacityLimitRound;
|
|
33039
33158
|
await this.setStateAsync('derived.core.pv.capacityLimitW', { val: pvCapacityLimitRound, ack: true });
|
|
33159
|
+
this._derivedFlow.last.pvCapacityLimitW = pvCapacityLimitRound;
|
|
33040
33160
|
}
|
|
33041
33161
|
if (this._derivedFlow?.last?.pvDuplicateSuppressedW !== pvDuplicateSuppressedRound) {
|
|
33042
|
-
this._derivedFlow.last.pvDuplicateSuppressedW = pvDuplicateSuppressedRound;
|
|
33043
33162
|
await this.setStateAsync('derived.core.pv.duplicateSuppressedW', { val: pvDuplicateSuppressedRound, ack: true });
|
|
33163
|
+
this._derivedFlow.last.pvDuplicateSuppressedW = pvDuplicateSuppressedRound;
|
|
33044
33164
|
}
|
|
33045
33165
|
if (this._derivedFlow?.last?.pvPlausibilityCapped !== pvPlausibility.capped) {
|
|
33046
|
-
this._derivedFlow.last.pvPlausibilityCapped = pvPlausibility.capped;
|
|
33047
33166
|
await this.setStateAsync('derived.core.pv.plausibilityCapped', { val: !!pvPlausibility.capped, ack: true });
|
|
33167
|
+
this._derivedFlow.last.pvPlausibilityCapped = pvPlausibility.capped;
|
|
33048
33168
|
}
|
|
33049
33169
|
if (this._derivedFlow?.last?.pvSource !== pvSource) {
|
|
33050
|
-
this._derivedFlow.last.pvSource = pvSource;
|
|
33051
33170
|
await this.setStateAsync('derived.core.pv.source', { val: pvSource, ack: true });
|
|
33171
|
+
this._derivedFlow.last.pvSource = pvSource;
|
|
33052
33172
|
}
|
|
33053
33173
|
|
|
33054
33174
|
// Die abgeleiteten Kernwerte werden zusätzlich in den API-/SSE-Cache gespiegelt.
|
|
@@ -33057,6 +33177,8 @@ return res.json(out);
|
|
|
33057
33177
|
this.updateValue('derived.core.building.loadTotalW', publishLoadTotalRound, loadTimestamp, { raw: false });
|
|
33058
33178
|
this.updateValue('derived.core.building.loadRestW', publishLoadRestRound, restTimestamp, { raw: false });
|
|
33059
33179
|
this.updateValue('derived.core.building.loadSource', loadTotalSource, ts, { raw: false });
|
|
33180
|
+
this.updateValue('derived.core.grid.netW', gridObserved ? gridNetRaw : null, gridObservedAt ?? ts, { raw: false });
|
|
33181
|
+
this.updateValue('derived.core.storage.netW', measuredStorage ? dischargeW - chargeW : null, storageFlow.observedAt ?? ts, { raw: false });
|
|
33060
33182
|
this.updateValue('derived.core.pv.acW', pvObserved ? pvAcRound : null, oldestTime(pvTimes), { raw: false });
|
|
33061
33183
|
this.updateValue('derived.core.pv.dcW', pvObserved ? pvDcRound : null, oldestTime(pvTimes), { raw: false });
|
|
33062
33184
|
this.updateValue('derived.core.pv.totalW', pvObserved ? pvTotalRound : null, oldestTime(pvTimes), { raw: false });
|
|
@@ -33078,8 +33200,8 @@ return res.json(out);
|
|
|
33078
33200
|
this.updateValue('derived.core.building.quality', quality, ts, { raw: false });
|
|
33079
33201
|
|
|
33080
33202
|
if (this._derivedFlow?.last?.quality !== quality) {
|
|
33081
|
-
this._derivedFlow.last.quality = quality;
|
|
33082
33203
|
await this.setStateAsync('derived.core.building.quality', { val: quality, ack: true });
|
|
33204
|
+
this._derivedFlow.last.quality = quality;
|
|
33083
33205
|
}
|
|
33084
33206
|
|
|
33085
33207
|
// Diagnostics payload (throttled)
|
|
@@ -33088,7 +33210,6 @@ return res.json(out);
|
|
|
33088
33210
|
const lastDiag = Number(this._derivedFlow?.diagLastMs) || 0;
|
|
33089
33211
|
if (!this._derivedFlow) this._derivedFlow = {};
|
|
33090
33212
|
if ((ts - lastDiag) >= diagEveryMs) {
|
|
33091
|
-
this._derivedFlow.diagLastMs = ts;
|
|
33092
33213
|
const payload = {
|
|
33093
33214
|
ts,
|
|
33094
33215
|
reason,
|
|
@@ -33154,9 +33275,13 @@ return res.json(out);
|
|
|
33154
33275
|
const json = JSON.stringify(payload);
|
|
33155
33276
|
await this.setStateAsync('derived.core.building.inputsJson', { val: json, ack: true });
|
|
33156
33277
|
this.updateValue('derived.core.building.inputsJson', json, ts, { raw: false });
|
|
33278
|
+
const tsSwitchJsonText = JSON.stringify(effectiveEnergyFlow.switchState || {});
|
|
33279
|
+
const tsCandidateJsonText = JSON.stringify(effectiveEnergyFlow.candidate || {});
|
|
33280
|
+
const tsFixedSourceJsonText = JSON.stringify((effectiveEnergyFlow.switchState && effectiveEnergyFlow.switchState.fixedSourceState) || {});
|
|
33157
33281
|
await this.setStateAsync('derived.core.building.tsSwitchJson', { val: tsSwitchJsonText, ack: true });
|
|
33158
33282
|
await this.setStateAsync('derived.core.building.tsCandidateJson', { val: tsCandidateJsonText, ack: true });
|
|
33159
33283
|
await this.setStateAsync('derived.core.building.tsFixedSourceJson', { val: tsFixedSourceJsonText, ack: true });
|
|
33284
|
+
this._derivedFlow.diagLastMs = ts;
|
|
33160
33285
|
}
|
|
33161
33286
|
} catch (_e) {}
|
|
33162
33287
|
|
|
@@ -33165,13 +33290,13 @@ return res.json(out);
|
|
|
33165
33290
|
// derive them from the signed NVP datapoint (Import + / Export -).
|
|
33166
33291
|
const gridBuyMapped = this._nwHasMappedDatapoint('gridBuyPower');
|
|
33167
33292
|
const gridSellMapped = this._nwHasMappedDatapoint('gridSellPower');
|
|
33168
|
-
if (gridObserved && gridNetRaw !== null &&
|
|
33293
|
+
if (gridObserved && gridNetRaw !== null && !gridBuyMapped) {
|
|
33169
33294
|
const cur = Number(this.stateCache?.gridBuyPower?.value);
|
|
33170
33295
|
if (!Number.isFinite(cur) || cur !== gridBuyRound || this.stateCache?.gridBuyPower?.ts !== oldestTime(gridTimes)) {
|
|
33171
33296
|
this.updateValue('gridBuyPower', publishGridBuyRound, oldestTime(gridTimes), { raw: false });
|
|
33172
33297
|
}
|
|
33173
33298
|
}
|
|
33174
|
-
if (gridObserved && gridNetRaw !== null &&
|
|
33299
|
+
if (gridObserved && gridNetRaw !== null && !gridSellMapped) {
|
|
33175
33300
|
const cur = Number(this.stateCache?.gridSellPower?.value);
|
|
33176
33301
|
if (!Number.isFinite(cur) || cur !== gridSellRound || this.stateCache?.gridSellPower?.ts !== oldestTime(gridTimes)) {
|
|
33177
33302
|
this.updateValue('gridSellPower', publishGridSellRound, oldestTime(gridTimes), { raw: false });
|
|
@@ -34214,18 +34339,20 @@ return res.json(out);
|
|
|
34214
34339
|
|
|
34215
34340
|
this.stateCache[key] = { value, ts, ...(opts.q !== undefined ? { q: opts.q } : {}) };
|
|
34216
34341
|
|
|
34217
|
-
|
|
34342
|
+
// Allocate one patch per delivery batch, and none while no dashboard is listening.
|
|
34343
|
+
const payload = this.sseClients?.size ? (this._ssePendingPayload ??= Object.create(null)) : null;
|
|
34344
|
+
if (payload) payload[key] = this.stateCache[key];
|
|
34218
34345
|
|
|
34219
34346
|
// derived EVCS aggregates
|
|
34220
34347
|
try {
|
|
34221
34348
|
if (/^evcs\.\d+\.powerW$/.test(key)) {
|
|
34222
34349
|
const count = Math.max(0, Math.round(Number(this.evcsCount || 0) || 0));
|
|
34223
|
-
const maxAgeMs =
|
|
34350
|
+
const maxAgeMs = this._nwLiveInputMaxAgeMs();
|
|
34224
34351
|
const keys = Array.from({ length: Math.min(count, 1024) }, (_, index) => `evcs.${index + 1}.powerW`);
|
|
34225
34352
|
const observation = sumFlowMeasurements(this.stateCache, keys, Date.now(), maxAgeMs);
|
|
34226
34353
|
const aggregate = observation || { value: null, ts: Date.now() };
|
|
34227
34354
|
this.stateCache['evcs.totalPowerW'] = aggregate;
|
|
34228
|
-
payload['evcs.totalPowerW'] = aggregate;
|
|
34355
|
+
if (payload) payload['evcs.totalPowerW'] = aggregate;
|
|
34229
34356
|
this.setStateAsync('evcs.totalPowerW', { val: aggregate.value, ts: aggregate.ts, ack: true }).catch(() => {});
|
|
34230
34357
|
}
|
|
34231
34358
|
|
|
@@ -34244,14 +34371,14 @@ return res.json(out);
|
|
|
34244
34371
|
base = total;
|
|
34245
34372
|
this.stateCache[baseD] = { value: baseDate, ts };
|
|
34246
34373
|
this.stateCache[baseK] = { value: base, ts };
|
|
34247
|
-
payload[baseD] = this.stateCache[baseD];
|
|
34248
|
-
payload[baseK] = this.stateCache[baseK];
|
|
34374
|
+
if (payload) payload[baseD] = this.stateCache[baseD];
|
|
34375
|
+
if (payload) payload[baseK] = this.stateCache[baseK];
|
|
34249
34376
|
this.setStateAsync(baseD, baseDate, true).catch(()=>{});
|
|
34250
34377
|
this.setStateAsync(baseK, base, true).catch(()=>{});
|
|
34251
34378
|
}
|
|
34252
34379
|
const dayKwh = Math.max(0, total - base);
|
|
34253
34380
|
this.stateCache[`evcs.${idx}.energyDayKwh`] = { value: dayKwh, ts };
|
|
34254
|
-
payload[`evcs.${idx}.energyDayKwh`] = this.stateCache[`evcs.${idx}.energyDayKwh`];
|
|
34381
|
+
if (payload) payload[`evcs.${idx}.energyDayKwh`] = this.stateCache[`evcs.${idx}.energyDayKwh`];
|
|
34255
34382
|
this.setStateAsync(`evcs.${idx}.energyDayKwh`, dayKwh, true).catch(()=>{});
|
|
34256
34383
|
}
|
|
34257
34384
|
} catch(_e) {}
|
|
@@ -34261,14 +34388,15 @@ return res.json(out);
|
|
|
34261
34388
|
|
|
34262
34389
|
// Derived / calculated live values (e.g. building consumption fallback for UI)
|
|
34263
34390
|
try {
|
|
34264
|
-
const isTrigger =
|
|
34391
|
+
const isTrigger = key === 'speicher.dcPvPowerW' || key.startsWith('storageFarm.') || (opts.raw !== false && (
|
|
34265
34392
|
key === 'gridBuyPower' || key === 'gridSellPower' || key === 'gridPointPower' ||
|
|
34266
34393
|
key === 'pvPower' || key === 'productionTotal' ||
|
|
34267
34394
|
key === 'storageChargePower' || key === 'storageDischargePower' || key === 'batteryPower' ||
|
|
34268
|
-
key === '
|
|
34395
|
+
key === 'consumptionTotal' || key === 'consumptionEvcs' ||
|
|
34396
|
+
key === 'settings.flowInvertBattery' || key === 'settings.flowInvertGrid' || key === 'settings.deviceStaleTimeoutSec' ||
|
|
34269
34397
|
/^producer\d+Power$/.test(key) || /^consumer\d+Power$/.test(key) ||
|
|
34270
|
-
/^evcs\.\d+\.powerW$/.test(key) || key === 'evcs.totalPowerW'
|
|
34271
|
-
|
|
34398
|
+
/^evcs\.\d+\.powerW$/.test(key) || key === 'evcs.totalPowerW'
|
|
34399
|
+
));
|
|
34272
34400
|
if (isTrigger) this.scheduleDerivedFlowUpdate(`key:${key}`);
|
|
34273
34401
|
} catch (_e3) {}
|
|
34274
34402
|
|
|
@@ -34277,18 +34405,15 @@ return res.json(out);
|
|
|
34277
34405
|
// RC88_SSE_IDLE_ZERO_ALLOCATION: without connected dashboards there is
|
|
34278
34406
|
// nothing to batch or serialize. Avoid a permanent 120-ms timer/allocation
|
|
34279
34407
|
// chain on headless customer systems.
|
|
34280
|
-
if (!
|
|
34281
|
-
this._ssePendingPayload =
|
|
34408
|
+
if (!payload) {
|
|
34409
|
+
this._ssePendingPayload = null;
|
|
34282
34410
|
return;
|
|
34283
34411
|
}
|
|
34284
|
-
if (!this._ssePendingPayload) this._ssePendingPayload = {};
|
|
34285
|
-
Object.assign(this._ssePendingPayload, payload);
|
|
34286
|
-
|
|
34287
34412
|
if (!this._sseFlushTimer) {
|
|
34288
34413
|
const batchMs = (this.config && Number(this.config.sseBatchMs)) || 120;
|
|
34289
34414
|
this._sseFlushTimer = this._nwSetTimeout(() => {
|
|
34290
|
-
const p = this._ssePendingPayload
|
|
34291
|
-
this._ssePendingPayload =
|
|
34415
|
+
const p = this._ssePendingPayload;
|
|
34416
|
+
this._ssePendingPayload = null;
|
|
34292
34417
|
this._sseFlushTimer = null;
|
|
34293
34418
|
if (!p || !Object.keys(p).length) return;
|
|
34294
34419
|
|
|
@@ -34344,7 +34469,7 @@ return res.json(out);
|
|
|
34344
34469
|
try { this.sseClients.clear(); } catch (_e2) {}
|
|
34345
34470
|
}
|
|
34346
34471
|
} catch (_e3) {}
|
|
34347
|
-
try { this._ssePendingPayload =
|
|
34472
|
+
try { this._ssePendingPayload = null; } catch (_e4) {}
|
|
34348
34473
|
}
|
|
34349
34474
|
/**
|
|
34350
34475
|
* Code-Teil: _nwCloseServer
|
|
@@ -34516,7 +34641,7 @@ return res.json(out);
|
|
|
34516
34641
|
} catch (_eSmartHomePulse) {}
|
|
34517
34642
|
try {
|
|
34518
34643
|
if (this._derivedFlow) this._derivedFlow.pending = false;
|
|
34519
|
-
this._ssePendingPayload =
|
|
34644
|
+
this._ssePendingPayload = null;
|
|
34520
34645
|
} catch (_ePending) {}
|
|
34521
34646
|
cleanup.capture(() => this._nwCloseSseClients());
|
|
34522
34647
|
|