iobroker.nexowatt-ui 0.8.97 → 0.8.99
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/ems/modules/charging-management.js +651 -26
- package/ems/modules/core-limits.js +413 -18
- package/ems/modules/heating-rod-control.js +58 -28
- package/ems/modules/storage-control.js +760 -67
- package/ems/modules/thermal-control.js +32 -8
- package/io-package.json +5 -5
- package/package.json +2 -1
- package/www/manifest.webmanifest +2 -2
- package/www/sw.js +2 -2
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* AUTO-GENERATED RUNTIME FILE - NICHT MANUELL BEARBEITEN.
|
|
3
3
|
*
|
|
4
4
|
* Quelle: src-ts/runtime-executables/ems/modules/charging-management.ts
|
|
5
|
-
* Quell-Hash: sha256:
|
|
5
|
+
* Quell-Hash: sha256:1025dc730540f20cd2e4bcd4cc52a666acbab06392d2206f509ff65809deaaf8
|
|
6
6
|
* Erzeugung: npm run sync:ts-runtime-executables
|
|
7
7
|
*
|
|
8
8
|
* Zweck:
|
|
@@ -178,6 +178,319 @@ function clamp(n, min, max) {
|
|
|
178
178
|
if (Number.isFinite(max)) n = Math.min(max, n);
|
|
179
179
|
return n;
|
|
180
180
|
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Code-Teil: computePvManagedDemandIntentW
|
|
184
|
+
* Zweck: Ermittelt den PV-Anteil eines aktiven Ladebedarfs unabhaengig von
|
|
185
|
+
* kurzzeitigem Zaehler-/Hystereseversatz. PV-only reserviert den kompletten
|
|
186
|
+
* Bedarf; Min+PV reserviert nur den Anteil oberhalb der konfigurierten
|
|
187
|
+
* Mindestleistung. Normal-/Boost-Laden erzeugt keinen PV-Intent.
|
|
188
|
+
*/
|
|
189
|
+
function computePvManagedDemandIntentW(modeRaw, demandReserveW, minPowerW = 0) {
|
|
190
|
+
const mode = String(modeRaw || '').trim().toLowerCase();
|
|
191
|
+
const demandW = Math.max(0, Number(demandReserveW) || 0);
|
|
192
|
+
const minW = Math.max(0, Number(minPowerW) || 0);
|
|
193
|
+
if (mode === 'pv') return demandW;
|
|
194
|
+
if (mode === 'minpv') return Math.max(0, demandW - Math.min(demandW, minW));
|
|
195
|
+
return 0;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Code-Teil: computeEvcsPvBudgetReservationW
|
|
200
|
+
* Zweck: Vereint tatsaechlich verwendeten PV-Anteil und aktiven PV-Ladeintent
|
|
201
|
+
* zu einer stabilen zentralen EVCS-Reservierung. Die Reservierung wird immer
|
|
202
|
+
* durch Gesamtbedarf und den kundenseitigen EVCS-Allocation-Cap begrenzt.
|
|
203
|
+
* Ein flackerndes pvAvailable-Hysteresesignal darf sie nicht auf 0 setzen.
|
|
204
|
+
*/
|
|
205
|
+
function computeEvcsPvBudgetReservationW({
|
|
206
|
+
reserveW = 0,
|
|
207
|
+
demandW = null,
|
|
208
|
+
pendingDemandW = 0,
|
|
209
|
+
actualPvW = 0,
|
|
210
|
+
intentPvW = 0,
|
|
211
|
+
pendingIntentPvW = 0,
|
|
212
|
+
allocationCapW = 0,
|
|
213
|
+
} = {}) {
|
|
214
|
+
// `reserveW` bildet die bereits physisch/kommandierte Ladeleistung ab.
|
|
215
|
+
// `demandW` darf zusätzlich einen verbundenen, noch wartenden PV-Ladepunkt
|
|
216
|
+
// enthalten. So kann die zentrale Budgetierung den EVCS-Anteil schon waehrend
|
|
217
|
+
// Startverzoegerung oder Wallbox-Telemetrie-Lag reservieren, ohne ihn als
|
|
218
|
+
// reale Netz-/Gesamtlast zu verbuchen.
|
|
219
|
+
const activeDemandW = Math.max(
|
|
220
|
+
0,
|
|
221
|
+
Number(reserveW) || 0,
|
|
222
|
+
Number.isFinite(Number(demandW)) ? Number(demandW) : 0,
|
|
223
|
+
);
|
|
224
|
+
const pendingW = Math.max(0, Number(pendingDemandW) || 0);
|
|
225
|
+
const totalDemandW = activeDemandW + pendingW;
|
|
226
|
+
const activePvDemandW = Math.max(0, Number(actualPvW) || 0, Number(intentPvW) || 0);
|
|
227
|
+
const pvDemandW = activePvDemandW + Math.max(0, Number(pendingIntentPvW) || 0);
|
|
228
|
+
const capW = Number.isFinite(Number(allocationCapW))
|
|
229
|
+
? Math.max(0, Number(allocationCapW))
|
|
230
|
+
: totalDemandW;
|
|
231
|
+
return Math.max(0, Math.min(totalDemandW, capW, pvDemandW));
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Code-Teil: computePendingPvStartIntentW
|
|
236
|
+
* Zweck: Reserviert den zentral zugeteilten PV-Anteil bereits fuer einen
|
|
237
|
+
* verbundenen PV-/Min+PV-Ladepunkt, bevor dessen reale Leistung oder Sollwert
|
|
238
|
+
* wegen Start-Hysterese, Rampenbegrenzung oder traeger Wallbox-Telemetrie sichtbar
|
|
239
|
+
* wird. Der Wert reduziert nur das zentrale PV-Restbudget; er wird nicht als
|
|
240
|
+
* bereits bezogene Netz-/Gesamtleistung verbucht.
|
|
241
|
+
*
|
|
242
|
+
* Sicherheitsregeln:
|
|
243
|
+
* - Nur installierte, online erreichbare und wirklich verbundene Ladepunkte mit
|
|
244
|
+
* einem beschreibbaren Sollwert duerfen einen Intent erzeugen.
|
|
245
|
+
* - Ein Start-Cooldown oder eine wartende Ziel-SoC-Freigabe blockiert den Intent.
|
|
246
|
+
* - Stations-, Anschluss-, Wallbox- und zentraler PV-Cap bleiben verbindlich.
|
|
247
|
+
* - Bei PV-only muss die technische Mindestleistung erreichbar sein.
|
|
248
|
+
* - Bei Min+PV wird nur der Anteil oberhalb der Mindest-/Netzgrundlast als PV
|
|
249
|
+
* reserviert; dadurch wird kein Netzbudget als vermeintlicher PV-Anteil gebucht.
|
|
250
|
+
*/
|
|
251
|
+
function computePendingPvStartIntentW({
|
|
252
|
+
mode = '',
|
|
253
|
+
enabled = false,
|
|
254
|
+
online = false,
|
|
255
|
+
connected = false,
|
|
256
|
+
controlBasis = 'none',
|
|
257
|
+
status = '',
|
|
258
|
+
startCooldownActive = false,
|
|
259
|
+
goalBlocked = false,
|
|
260
|
+
currentPowerW = 0,
|
|
261
|
+
currentPvIntentW = 0,
|
|
262
|
+
minPowerW = 0,
|
|
263
|
+
technicalMinW = 0,
|
|
264
|
+
maxPowerW = 0,
|
|
265
|
+
totalRemainingW = Number.POSITIVE_INFINITY,
|
|
266
|
+
stationRemainingW = Number.POSITIVE_INFINITY,
|
|
267
|
+
pvRemainingW = 0,
|
|
268
|
+
activityThresholdW = 100,
|
|
269
|
+
} = {}) {
|
|
270
|
+
const normalizedMode = String(mode || '').trim().toLowerCase();
|
|
271
|
+
const isPvOnly = normalizedMode === 'pv';
|
|
272
|
+
const isMinPv = normalizedMode === 'minpv';
|
|
273
|
+
const validControl = String(controlBasis || '').trim().toLowerCase() !== 'none';
|
|
274
|
+
if ((!isPvOnly && !isMinPv) || !enabled || !online || !connected || !validControl || startCooldownActive || goalBlocked) {
|
|
275
|
+
return { intentW: 0, totalDemandW: 0, reason: 'not-eligible' };
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// OCPP/Herstellerstatus trennt ein wartendes EVSE von einem Fahrzeug, das
|
|
279
|
+
// selbst keine Energie anfordert. `SuspendedEVSE` darf reservieren, weil die
|
|
280
|
+
// Wallbox typischerweise auf EMS-Leistung wartet. `SuspendedEV` darf dagegen
|
|
281
|
+
// keinen PV-Anteil fuer ein gerade nicht ladewilliges Fahrzeug blockieren.
|
|
282
|
+
const normalizedStatus = String(status || '').trim().toLowerCase().replace(/[^a-z0-9]+/g, '');
|
|
283
|
+
const suspendedByEvse = normalizedStatus.includes('suspendedevse');
|
|
284
|
+
const suspendedByVehicle = normalizedStatus.includes('suspendedev') && !suspendedByEvse;
|
|
285
|
+
if (suspendedByVehicle) {
|
|
286
|
+
return { intentW: 0, totalDemandW: 0, reason: 'vehicle-not-requesting' };
|
|
287
|
+
}
|
|
288
|
+
const statusCanRequestPower = !normalizedStatus
|
|
289
|
+
|| suspendedByEvse
|
|
290
|
+
|| normalizedStatus.includes('preparing')
|
|
291
|
+
|| normalizedStatus.includes('occupied')
|
|
292
|
+
|| normalizedStatus.includes('reserved')
|
|
293
|
+
|| normalizedStatus.includes('charging');
|
|
294
|
+
if (!statusCanRequestPower) {
|
|
295
|
+
return { intentW: 0, totalDemandW: 0, reason: 'status-not-requesting' };
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const maxW = Math.max(0, Number(maxPowerW) || 0);
|
|
299
|
+
const currentW = Math.max(0, Math.min(maxW, Number(currentPowerW) || 0));
|
|
300
|
+
const currentIntentW = Math.max(0, Number(currentPvIntentW) || 0);
|
|
301
|
+
const minW = Math.max(0, Number(minPowerW) || 0);
|
|
302
|
+
const technicalW = Math.max(minW, Number(technicalMinW) || 0);
|
|
303
|
+
const thresholdW = Math.max(1, Number(activityThresholdW) || 100);
|
|
304
|
+
const totalAvailW = Number.isFinite(Number(totalRemainingW))
|
|
305
|
+
? Math.max(0, Number(totalRemainingW))
|
|
306
|
+
: Number.POSITIVE_INFINITY;
|
|
307
|
+
const stationAvailW = Number.isFinite(Number(stationRemainingW))
|
|
308
|
+
? Math.max(0, Number(stationRemainingW))
|
|
309
|
+
: Number.POSITIVE_INFINITY;
|
|
310
|
+
const pvAvailW = Math.max(0, Number(pvRemainingW) || 0);
|
|
311
|
+
if (maxW <= 0 || pvAvailW <= 0) {
|
|
312
|
+
return { intentW: 0, totalDemandW: 0, reason: 'no-capacity' };
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// Das verbleibende Gesamt-/Stationsbudget beschreibt nur zusaetzliche
|
|
316
|
+
// Leistung, weil die bereits kommandierte Leistung im Hauptlauf zuvor
|
|
317
|
+
// abgezogen wurde. So kann kein Ladepunkt denselben Anschlussanteil doppelt
|
|
318
|
+
// fuer einen aktiven Sollwert und einen Start-Intent verwenden.
|
|
319
|
+
const additionalConnectorW = Math.max(0, maxW - currentW);
|
|
320
|
+
const additionalTotalW = Math.max(0, Math.min(additionalConnectorW, totalAvailW, stationAvailW));
|
|
321
|
+
const potentialTotalW = currentW + additionalTotalW;
|
|
322
|
+
|
|
323
|
+
if (isPvOnly) {
|
|
324
|
+
const isAlreadyActive = currentW >= thresholdW;
|
|
325
|
+
if (!isAlreadyActive && technicalW > 0 && potentialTotalW < technicalW) {
|
|
326
|
+
return { intentW: 0, totalDemandW: 0, reason: 'below-technical-minimum' };
|
|
327
|
+
}
|
|
328
|
+
const desiredPvTotalW = Math.max(0, potentialTotalW);
|
|
329
|
+
const intentGapW = Math.max(0, desiredPvTotalW - currentIntentW);
|
|
330
|
+
const intentW = Math.max(0, Math.min(intentGapW, pvAvailW));
|
|
331
|
+
return {
|
|
332
|
+
intentW,
|
|
333
|
+
totalDemandW: intentW,
|
|
334
|
+
reason: intentW > 0 ? (isAlreadyActive ? 'pv-ramp-intent' : 'pv-start-intent') : 'covered',
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// Min+PV benoetigt zunaechst seine Mindestleistung aus dem normalen
|
|
339
|
+
// Gesamtbudget. Nur die darueber hinaus moegliche Leistung ist PV-Intent.
|
|
340
|
+
if (minW > 0 && potentialTotalW < minW) {
|
|
341
|
+
return { intentW: 0, totalDemandW: 0, reason: 'below-minpv-base' };
|
|
342
|
+
}
|
|
343
|
+
const desiredPvTotalW = Math.max(0, potentialTotalW - Math.min(minW, potentialTotalW));
|
|
344
|
+
const intentGapW = Math.max(0, desiredPvTotalW - currentIntentW);
|
|
345
|
+
const intentW = Math.max(0, Math.min(intentGapW, pvAvailW));
|
|
346
|
+
if (intentW <= 0) {
|
|
347
|
+
return { intentW: 0, totalDemandW: 0, reason: 'covered' };
|
|
348
|
+
}
|
|
349
|
+
const missingBaseW = currentW >= minW ? 0 : Math.max(0, minW - currentW);
|
|
350
|
+
return {
|
|
351
|
+
intentW,
|
|
352
|
+
totalDemandW: Math.max(0, missingBaseW + intentW),
|
|
353
|
+
reason: currentW >= thresholdW ? 'minpv-ramp-intent' : 'minpv-start-intent',
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Code-Teil: computePendingPvStartTotalBudgetW
|
|
359
|
+
* Zweck: Loest den Start-Deadlock zwischen PV-Hysterese und zentraler
|
|
360
|
+
* Budgetreservierung auf.
|
|
361
|
+
*
|
|
362
|
+
* Hintergrund:
|
|
363
|
+
* Der normale EVCS-Sollwert darf waehrend der PV-Startverzoegerung noch 0 W
|
|
364
|
+
* sein. Dadurch kann auch das lokale `remainingW` voruebergehend 0 W melden,
|
|
365
|
+
* obwohl das zentrale EMS bereits einen gueltigen PV- und Gesamt-Grant sieht.
|
|
366
|
+
* Wuerde der Pending-Intent dieses lokale 0-W-Ergebnis verwenden, koennte der
|
|
367
|
+
* Speicher den kompletten PV-Anteil uebernehmen und die Wallbox kaeme nie aus
|
|
368
|
+
* `SuspendedEVSE` heraus.
|
|
369
|
+
*
|
|
370
|
+
* Die Funktion verwendet deshalb fuer den noch nicht gestarteten Ladeanteil
|
|
371
|
+
* den groesseren Wert aus:
|
|
372
|
+
* - lokal verbleibendem Anschluss-/Stationsbudget und
|
|
373
|
+
* - zentralem Gesamt-Grant nach Abzug bereits aktiver EVCS-Leistung.
|
|
374
|
+
*
|
|
375
|
+
* Stations-, Wallbox-, Phasen- und technische Mindestgrenzen werden danach im
|
|
376
|
+
* Pending-Intent weiterhin separat angewendet. Der Wert reserviert nur einen
|
|
377
|
+
* Startwunsch; er wird nicht als bereits gemessener Netzbezug verbucht.
|
|
378
|
+
*/
|
|
379
|
+
function computePendingPvStartTotalBudgetW({
|
|
380
|
+
localRemainingW = 0,
|
|
381
|
+
centralTotalGrantW = null,
|
|
382
|
+
activeDemandW = 0,
|
|
383
|
+
} = {}) {
|
|
384
|
+
const localRaw = Number(localRemainingW);
|
|
385
|
+
const localW = localRaw === Number.POSITIVE_INFINITY
|
|
386
|
+
? Number.POSITIVE_INFINITY
|
|
387
|
+
: (Number.isFinite(localRaw) ? Math.max(0, localRaw) : 0);
|
|
388
|
+
const centralRaw = Number(centralTotalGrantW);
|
|
389
|
+
if (!Number.isFinite(centralRaw)) return localW;
|
|
390
|
+
|
|
391
|
+
const centralAdditionalW = Math.max(0, centralRaw - Math.max(0, Number(activeDemandW) || 0));
|
|
392
|
+
return Math.max(localW, centralAdditionalW);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Code-Teil: resolveChargingPvBudgetControl
|
|
397
|
+
* Zweck: Macht das zentrale EMS-PV-Budget zur autoritativen Quelle fuer PV-
|
|
398
|
+
* und Min+PV-Ladepunkte. Die lokale EVCS-Rekonstruktion bleibt nur Diagnose-
|
|
399
|
+
* und Rueckwaertskompatibilitaets-Fallback, damit Speicher, Wallboxen,
|
|
400
|
+
* Heizstaebe und weitere Verbraucher niemals mit getrennten PV-Budgets regeln.
|
|
401
|
+
*/
|
|
402
|
+
function resolveChargingPvBudgetControl({
|
|
403
|
+
centralBudget = null,
|
|
404
|
+
now = Date.now(),
|
|
405
|
+
maxAgeMs = 30000,
|
|
406
|
+
localRawW = 0,
|
|
407
|
+
localEffectiveW = 0,
|
|
408
|
+
} = {}) {
|
|
409
|
+
const localRaw = Math.max(0, Number(localRawW) || 0);
|
|
410
|
+
const localEffective = Math.max(0, Number(localEffectiveW) || 0);
|
|
411
|
+
const rt = centralBudget && typeof centralBudget === 'object' ? centralBudget : null;
|
|
412
|
+
const ts = rt ? Number(rt.ts) : NaN;
|
|
413
|
+
const ageMs = Number.isFinite(ts) && ts > 0 ? Math.max(0, Number(now) - ts) : null;
|
|
414
|
+
const fresh = ageMs !== null && ageMs <= Math.max(1000, Number(maxAgeMs) || 30000);
|
|
415
|
+
const pvGate = rt && rt.gates && rt.gates.pv && typeof rt.gates.pv === 'object'
|
|
416
|
+
? rt.gates.pv
|
|
417
|
+
: null;
|
|
418
|
+
const allocation = rt && rt.gates && rt.gates.pvAllocation && typeof rt.gates.pvAllocation === 'object'
|
|
419
|
+
? rt.gates.pvAllocation
|
|
420
|
+
: null;
|
|
421
|
+
|
|
422
|
+
if (fresh && pvGate) {
|
|
423
|
+
const gateEffectiveW = Math.max(0, Number(pvGate.effectiveW) || 0);
|
|
424
|
+
const allocationTotalW = allocation && Number.isFinite(Number(allocation.totalW))
|
|
425
|
+
? Math.max(0, Number(allocation.totalW))
|
|
426
|
+
: gateEffectiveW;
|
|
427
|
+
const allocationCapW = allocation && Number.isFinite(Number(allocation.evcsCapW))
|
|
428
|
+
? Math.max(0, Number(allocation.evcsCapW))
|
|
429
|
+
: allocationTotalW;
|
|
430
|
+
const allocationLimitedW = Math.max(0, Math.min(allocationTotalW, allocationCapW));
|
|
431
|
+
const centralGrant = typeof rt.getPvGrant === 'function'
|
|
432
|
+
? rt.getPvGrant({ key: 'evcs', requestedW: allocationLimitedW, maxW: allocationLimitedW })
|
|
433
|
+
: (typeof rt.grant === 'function'
|
|
434
|
+
? rt.grant({ key: 'evcs', requestedW: allocationLimitedW, maxW: allocationLimitedW, pvOnly: true })
|
|
435
|
+
: null);
|
|
436
|
+
const evcsCapW = centralGrant && Number.isFinite(Number(centralGrant.grantW))
|
|
437
|
+
? Math.max(0, Math.min(allocationLimitedW, Number(centralGrant.grantW)))
|
|
438
|
+
: allocationLimitedW;
|
|
439
|
+
return {
|
|
440
|
+
authoritative: true,
|
|
441
|
+
source: 'central-ems-budget',
|
|
442
|
+
ageMs,
|
|
443
|
+
rawW: Math.max(0, Number(pvGate.rawW) || 0),
|
|
444
|
+
totalW: allocationTotalW,
|
|
445
|
+
evcsCapW,
|
|
446
|
+
allocation: allocation || {},
|
|
447
|
+
localRawW: localRaw,
|
|
448
|
+
localEffectiveW: localEffective,
|
|
449
|
+
mismatchW: evcsCapW - localEffective,
|
|
450
|
+
centralGrantW: evcsCapW,
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// In der aktuellen Adaptergeneration ist Core-Limits immer vor dem
|
|
455
|
+
// Lademanagement aktiv. Existiert die zentrale Runtime, ist sie daher auch
|
|
456
|
+
// bei einem kurzzeitig fehlenden/stalen Snapshot die einzige Quelle. Ein
|
|
457
|
+
// Rueckfall auf die lokale EVCS-PV-Rekonstruktion wuerde genau das zweite
|
|
458
|
+
// Parallelbudget erzeugen, das Speicher und Wallbox gegeneinander regeln
|
|
459
|
+
// laesst. In diesem Fehlerfall wird PV-Laden sicher blockiert, bis der Core
|
|
460
|
+
// wieder einen frischen Grant liefert.
|
|
461
|
+
if (rt) {
|
|
462
|
+
return {
|
|
463
|
+
authoritative: true,
|
|
464
|
+
blocked: true,
|
|
465
|
+
source: fresh ? 'central-ems-budget-missing-pv-gate' : 'central-ems-budget-stale-blocked',
|
|
466
|
+
ageMs,
|
|
467
|
+
rawW: 0,
|
|
468
|
+
totalW: 0,
|
|
469
|
+
evcsCapW: 0,
|
|
470
|
+
allocation: allocation || null,
|
|
471
|
+
localRawW: localRaw,
|
|
472
|
+
localEffectiveW: localEffective,
|
|
473
|
+
mismatchW: -localEffective,
|
|
474
|
+
centralGrantW: 0,
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
// Nur fuer sehr alte Laufzeiten ohne Core-Limits bleibt der lokale Wert als
|
|
479
|
+
// Kompatibilitaetsfallback erhalten. Im regulaeren NexoWatt-EMS wird dieser
|
|
480
|
+
// Zweig wegen der festen Modulreihenfolge nicht verwendet.
|
|
481
|
+
return {
|
|
482
|
+
authoritative: false,
|
|
483
|
+
source: 'local-fallback-no-central-budget',
|
|
484
|
+
ageMs,
|
|
485
|
+
rawW: localRaw,
|
|
486
|
+
totalW: localEffective,
|
|
487
|
+
evcsCapW: localEffective,
|
|
488
|
+
allocation: null,
|
|
489
|
+
localRawW: localRaw,
|
|
490
|
+
localEffectiveW: localEffective,
|
|
491
|
+
mismatchW: 0,
|
|
492
|
+
};
|
|
493
|
+
}
|
|
181
494
|
/**
|
|
182
495
|
* Code-Teil: toBool
|
|
183
496
|
* Zweck: Kapselt einen lokalen Verarbeitungsschritt, damit Aufrufer nicht direkt in Detaildaten eingreifen.
|
|
@@ -2527,6 +2840,21 @@ class ChargingManagementModule extends BaseModule {
|
|
|
2527
2840
|
await mk('chargingManagement.control.pvAllocationEvcsCapW', 'PV surplus EVCS allocation cap (W)', 'number', 'value.power');
|
|
2528
2841
|
await mk('chargingManagement.control.pvAllocationUncappedW', 'PV surplus EVCS cap before allocation (W)', 'number', 'value.power');
|
|
2529
2842
|
await mk('chargingManagement.control.pvAllocationStorageActualChargeW', 'Storage actual charge considered for PV allocation (W)', 'number', 'value.power');
|
|
2843
|
+
await mk('chargingManagement.control.pvBudgetSource', 'Authoritative PV budget source', 'string', 'text');
|
|
2844
|
+
await mk('chargingManagement.control.pvBudgetCentralAgeMs', 'Central PV budget age (ms)', 'number', 'value.interval');
|
|
2845
|
+
await mk('chargingManagement.control.pvBudgetCentralTotalW', 'Central total PV budget (W)', 'number', 'value.power');
|
|
2846
|
+
await mk('chargingManagement.control.pvBudgetCentralEvcsCapW', 'Central EVCS PV allocation cap (W)', 'number', 'value.power');
|
|
2847
|
+
await mk('chargingManagement.control.pvBudgetLocalEstimateW', 'Local EVCS PV estimate for diagnostics (W)', 'number', 'value.power');
|
|
2848
|
+
await mk('chargingManagement.control.pvBudgetMismatchW', 'Central EVCS cap minus local estimate (W)', 'number', 'value.power');
|
|
2849
|
+
await mk('chargingManagement.control.pvActiveDemandReserveW', 'Actual PV share reserved by active EVCS demand (W)', 'number', 'value.power');
|
|
2850
|
+
await mk('chargingManagement.control.pvActiveDemandIntentW', 'PV intent reserved during EVCS ramp/telemetry lag (W)', 'number', 'value.power');
|
|
2851
|
+
await mk('chargingManagement.control.pvPendingDemandIntentW', 'Connected PV charging demand reserved before power flow starts (W)', 'number', 'value.power');
|
|
2852
|
+
await mk('chargingManagement.control.pvPendingDemandTotalW', 'Total EVCS demand reserved while PV charging starts or ramps (W)', 'number', 'value.power');
|
|
2853
|
+
await mk('chargingManagement.control.pvPendingDemandWallboxes', 'Wallboxes with pending central PV demand', 'number', 'value');
|
|
2854
|
+
await mk('chargingManagement.control.pvTotalDemandIntentW', 'Total active and pending central EVCS PV demand (W)', 'number', 'value.power');
|
|
2855
|
+
await mk('chargingManagement.control.pvCentralGrantW', 'Central EMS PV grant available to EVCS (W)', 'number', 'value.power');
|
|
2856
|
+
await mk('chargingManagement.control.pvCentralReservedW', 'PV budget reserved centrally by EVCS (W)', 'number', 'value.power');
|
|
2857
|
+
await mk('chargingManagement.control.pvCentralRemainingAfterEvcsW', 'Central PV budget remaining after EVCS reservation (W)', 'number', 'value.power');
|
|
2530
2858
|
|
|
2531
2859
|
// Debug: PV surplus without EVCS (instant + smoothed)
|
|
2532
2860
|
// Used to verify sign conventions / smoothing for PV-only charging.
|
|
@@ -2537,7 +2865,8 @@ class ChargingManagementModule extends BaseModule {
|
|
|
2537
2865
|
// (helps diagnosing start/stop "hopping" when meters update delayed)
|
|
2538
2866
|
await mk('chargingManagement.control.pvEvcsActualW', 'EVCS actual power sum (W)', 'number', 'value.power');
|
|
2539
2867
|
await mk('chargingManagement.control.pvEvcsCmdW', 'EVCS last commanded power sum (W)', 'number', 'value.power');
|
|
2540
|
-
await mk('chargingManagement.control.pvEvcsUsedW', 'EVCS power used for PV surplus
|
|
2868
|
+
await mk('chargingManagement.control.pvEvcsUsedW', 'EVCS power used for local PV surplus diagnostics (W)', 'number', 'value.power');
|
|
2869
|
+
await mk('chargingManagement.control.pvEvcsPhysicalPvManagedW', 'Measured PV-managed EVCS power for central PV reconstruction (W)', 'number', 'value.power');
|
|
2541
2870
|
|
|
2542
2871
|
// Gate A: hard grid safety caps (transparency)
|
|
2543
2872
|
await mk('chargingManagement.control.gridImportLimitW', 'Grid import limit (W) configured', 'number', 'value.power');
|
|
@@ -4212,6 +4541,8 @@ class ChargingManagementModule extends BaseModule {
|
|
|
4212
4541
|
userMode,
|
|
4213
4542
|
evcsIndex: (Number.isFinite(evcsIndex) && evcsIndex > 0) ? Math.round(evcsIndex) : 0,
|
|
4214
4543
|
vehiclePlugged,
|
|
4544
|
+
connectorStatus: String(statusForPlug || ''),
|
|
4545
|
+
connectorStatusSource: String(statusForPlugSource || ''),
|
|
4215
4546
|
goalEnabled,
|
|
4216
4547
|
goalActive,
|
|
4217
4548
|
goalStatus,
|
|
@@ -4906,6 +5237,13 @@ class ChargingManagementModule extends BaseModule {
|
|
|
4906
5237
|
let pvAllocationEvcsCapWState = 0;
|
|
4907
5238
|
let pvAllocationUncappedWState = 0;
|
|
4908
5239
|
let pvAllocationStorageActualChargeWState = 0;
|
|
5240
|
+
let pvBudgetSourceState = 'none';
|
|
5241
|
+
let pvBudgetCentralAgeMsState = null;
|
|
5242
|
+
let pvBudgetCentralTotalWState = 0;
|
|
5243
|
+
let pvBudgetCentralEvcsCapWState = 0;
|
|
5244
|
+
let pvBudgetLocalEstimateWState = 0;
|
|
5245
|
+
let pvBudgetMismatchWState = 0;
|
|
5246
|
+
let pvBudgetCentralAuthoritative = false;
|
|
4909
5247
|
|
|
4910
5248
|
if (needPvBudget || needPvDiagnostics) {
|
|
4911
5249
|
// PV-Überschuss sauber ermitteln:
|
|
@@ -4933,6 +5271,7 @@ class ChargingManagementModule extends BaseModule {
|
|
|
4933
5271
|
let pvEvcsActualW = 0;
|
|
4934
5272
|
let pvEvcsCmdW = 0;
|
|
4935
5273
|
let pvEvcsUsedW = 0;
|
|
5274
|
+
let pvEvcsPhysicalPvManagedW = 0;
|
|
4936
5275
|
|
|
4937
5276
|
try {
|
|
4938
5277
|
for (const w of wbList) {
|
|
@@ -4944,6 +5283,18 @@ class ChargingManagementModule extends BaseModule {
|
|
|
4944
5283
|
: 0;
|
|
4945
5284
|
pvEvcsActualW += a;
|
|
4946
5285
|
|
|
5286
|
+
// Fuer die zentrale physikalische PV-Rekonstruktion zaehlt nur
|
|
5287
|
+
// gemessene Leistung von PV-/Min+PV-Ladepunkten. Normal/Boost
|
|
5288
|
+
// ist bereits eine priorisierte Last und darf kein neues
|
|
5289
|
+
// Speicher-PV-Budget erzeugen. Kommandowerte werden hier bewusst
|
|
5290
|
+
// nicht verwendet; der NVP bildet den realen Leistungsfluss ab.
|
|
5291
|
+
const effectiveMode = String(w.effectiveMode || '').trim().toLowerCase();
|
|
5292
|
+
if (effectiveMode === 'pv') {
|
|
5293
|
+
pvEvcsPhysicalPvManagedW += a;
|
|
5294
|
+
} else if (effectiveMode === 'minpv') {
|
|
5295
|
+
pvEvcsPhysicalPvManagedW += Math.max(0, a - Math.min(a, Math.max(0, Number(w.minPW) || 0)));
|
|
5296
|
+
}
|
|
5297
|
+
|
|
4947
5298
|
const prevCmd = (this._lastCmdTargetW && typeof this._lastCmdTargetW.get === 'function')
|
|
4948
5299
|
? this._lastCmdTargetW.get(w.safe)
|
|
4949
5300
|
: null;
|
|
@@ -4969,13 +5320,14 @@ class ChargingManagementModule extends BaseModule {
|
|
|
4969
5320
|
pvEvcsActualW = pvEvcsUsedW;
|
|
4970
5321
|
pvEvcsCmdW = pvEvcsUsedW;
|
|
4971
5322
|
}
|
|
4972
|
-
pvEvcsUsedWForBudget = Math.max(0, Math.round(
|
|
5323
|
+
pvEvcsUsedWForBudget = Math.max(0, Math.round(pvEvcsPhysicalPvManagedW || 0));
|
|
4973
5324
|
|
|
4974
5325
|
// Diagnostics (UI)
|
|
4975
5326
|
try {
|
|
4976
5327
|
await this._queueState('chargingManagement.control.pvEvcsActualW', Math.round(pvEvcsActualW || 0), true);
|
|
4977
5328
|
await this._queueState('chargingManagement.control.pvEvcsCmdW', Math.round(pvEvcsCmdW || 0), true);
|
|
4978
5329
|
await this._queueState('chargingManagement.control.pvEvcsUsedW', Math.round(pvEvcsUsedW || 0), true);
|
|
5330
|
+
await this._queueState('chargingManagement.control.pvEvcsPhysicalPvManagedW', Math.round(pvEvcsPhysicalPvManagedW || 0), true);
|
|
4979
5331
|
} catch {
|
|
4980
5332
|
// ignore
|
|
4981
5333
|
}
|
|
@@ -5136,36 +5488,52 @@ class ChargingManagementModule extends BaseModule {
|
|
|
5136
5488
|
// Effektiv bleibt dadurch im PV-Budget ein Puffer (Default 500 W), der kurze Messwertsprünge,
|
|
5137
5489
|
// Rundungsfehler und minimale Hauslaständerungen abfedert, ohne die restliche Logik zu ändern.
|
|
5138
5490
|
const pvChargeReserveW = clamp(num(cfg.pvChargeReserveW, 500), 0, 1e12);
|
|
5139
|
-
const
|
|
5140
|
-
|
|
5491
|
+
const pvCapBudgetLocalW = Math.max(0, pvCapRawW - pvChargeReserveW);
|
|
5492
|
+
pvBudgetLocalEstimateWState = pvCapBudgetLocalW;
|
|
5141
5493
|
pvAllocationStorageActualChargeWState = Math.max(0, Math.round(storageChargeNowW || 0));
|
|
5142
5494
|
|
|
5143
|
-
//
|
|
5144
|
-
//
|
|
5145
|
-
//
|
|
5495
|
+
// Zentrale Orchestrierung: Core-Limits berechnet EIN physikalisches PV-Budget
|
|
5496
|
+
// und teilt es gemaess Kundeneinstellung zwischen EVCS und Speicher. Die lokale
|
|
5497
|
+
// EVCS-Rekonstruktion bleibt nur Diagnose/Fallback. Ein `Math.min(local, central)`
|
|
5498
|
+
// waere fachlich falsch: Ein kurzzeitig 0 W meldender lokaler PV-/Last-DP wuerde
|
|
5499
|
+
// sonst trotz klarer NVP-Einspeisung den zentralen EVCS-Anteil wieder auf 0 setzen.
|
|
5146
5500
|
const centralBudget = this.adapter && this.adapter._emsBudget;
|
|
5147
|
-
const
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
:
|
|
5501
|
+
const pvBudgetControl = resolveChargingPvBudgetControl({
|
|
5502
|
+
centralBudget,
|
|
5503
|
+
now,
|
|
5504
|
+
maxAgeMs: Math.max(15000, clamp(num(cfg.centralBudgetMaxAgeSec, 30), 5, 120) * 1000),
|
|
5505
|
+
localRawW: pvCapRawW,
|
|
5506
|
+
localEffectiveW: pvCapBudgetLocalW,
|
|
5507
|
+
});
|
|
5508
|
+
const allocationGate = pvBudgetControl.allocation;
|
|
5509
|
+
pvBudgetCentralAuthoritative = pvBudgetControl.authoritative === true;
|
|
5510
|
+
pvBudgetSourceState = String(pvBudgetControl.source || '');
|
|
5511
|
+
pvBudgetCentralAgeMsState = pvBudgetControl.ageMs;
|
|
5512
|
+
pvBudgetCentralTotalWState = Math.max(0, Number(pvBudgetControl.totalW) || 0);
|
|
5513
|
+
pvBudgetCentralEvcsCapWState = Math.max(0, Number(pvBudgetControl.evcsCapW) || 0);
|
|
5514
|
+
pvBudgetMismatchWState = Number.isFinite(Number(pvBudgetControl.mismatchW))
|
|
5515
|
+
? Number(pvBudgetControl.mismatchW)
|
|
5516
|
+
: 0;
|
|
5517
|
+
|
|
5153
5518
|
if (allocationGate) {
|
|
5154
5519
|
pvAllocationModeState = String(allocationGate.mode || 'both');
|
|
5155
5520
|
pvAllocationEvcsSharePctState = Number.isFinite(Number(allocationGate.evcsSharePct))
|
|
5156
5521
|
? Math.max(0, Math.min(100, Number(allocationGate.evcsSharePct)))
|
|
5157
5522
|
: 50;
|
|
5158
|
-
pvAllocationEvcsCapWState = Number.isFinite(Number(allocationGate.evcsCapW))
|
|
5159
|
-
? Math.max(0, Number(allocationGate.evcsCapW))
|
|
5160
|
-
: pvCapBudgetW;
|
|
5161
5523
|
} else {
|
|
5162
|
-
// Rueckwaertskompatibler Fallback, falls Core-Limits in einem alten
|
|
5163
|
-
// Laufzeitstand noch keinen Allocation-Gate bereitstellt.
|
|
5164
5524
|
pvAllocationModeState = 'legacy-full-evcs';
|
|
5165
5525
|
pvAllocationEvcsSharePctState = 100;
|
|
5166
|
-
pvAllocationEvcsCapWState = pvCapBudgetW;
|
|
5167
5526
|
}
|
|
5168
|
-
|
|
5527
|
+
|
|
5528
|
+
// `totalW` ist das zentrale PV-Budget nach zentraler Reserve. `evcsCapW`
|
|
5529
|
+
// ist daraus der maximal zulaessige EVCS-Anteil. Beide Werte stammen aus
|
|
5530
|
+
// demselben Budget-Snapshot, den Speicher, Heizstab und weitere Verbraucher
|
|
5531
|
+
// anschliessend ueber `reserve()` weiter reduzieren.
|
|
5532
|
+
pvAllocationUncappedWState = pvBudgetCentralTotalWState;
|
|
5533
|
+
pvAllocationEvcsCapWState = pvBudgetCentralEvcsCapWState;
|
|
5534
|
+
const pvCapAllocatedW = pvBudgetCentralAuthoritative
|
|
5535
|
+
? pvBudgetCentralEvcsCapWState
|
|
5536
|
+
: Math.max(0, pvCapBudgetLocalW);
|
|
5169
5537
|
pvStartReadyBudgetW = pvCapAllocatedW;
|
|
5170
5538
|
pvCapW = pvCapAllocatedW;
|
|
5171
5539
|
|
|
@@ -5229,7 +5597,9 @@ class ChargingManagementModule extends BaseModule {
|
|
|
5229
5597
|
this._pvAvailable = pvAvail;
|
|
5230
5598
|
pvCapW = pvAvail ? pvCapAllocatedW : 0;
|
|
5231
5599
|
|
|
5232
|
-
pvCapRawWState =
|
|
5600
|
+
pvCapRawWState = pvBudgetCentralAuthoritative
|
|
5601
|
+
? Math.max(0, Number(pvBudgetControl.rawW) || 0)
|
|
5602
|
+
: pvCapRawW;
|
|
5233
5603
|
pvCapEffectiveWState = (typeof pvCapW === 'number' && Number.isFinite(pvCapW)) ? pvCapW : 0;
|
|
5234
5604
|
pvAvailableState = pvAvail;
|
|
5235
5605
|
|
|
@@ -5244,6 +5614,13 @@ class ChargingManagementModule extends BaseModule {
|
|
|
5244
5614
|
pvAvailableState = false;
|
|
5245
5615
|
pvSurplusNoEvRawWState = 0;
|
|
5246
5616
|
pvSurplusNoEvAvg5mWState = 0;
|
|
5617
|
+
pvBudgetSourceState = 'inactive';
|
|
5618
|
+
pvBudgetCentralAgeMsState = null;
|
|
5619
|
+
pvBudgetCentralTotalWState = 0;
|
|
5620
|
+
pvBudgetCentralEvcsCapWState = 0;
|
|
5621
|
+
pvBudgetLocalEstimateWState = 0;
|
|
5622
|
+
pvBudgetMismatchWState = 0;
|
|
5623
|
+
pvBudgetCentralAuthoritative = false;
|
|
5247
5624
|
}
|
|
5248
5625
|
|
|
5249
5626
|
// Publish PV diagnostics (even if PV budgeting is not active)
|
|
@@ -5258,6 +5635,16 @@ class ChargingManagementModule extends BaseModule {
|
|
|
5258
5635
|
await this._queueState('chargingManagement.control.pvAllocationEvcsCapW', Math.round(Number(pvAllocationEvcsCapWState) || 0), true);
|
|
5259
5636
|
await this._queueState('chargingManagement.control.pvAllocationUncappedW', Math.round(Number(pvAllocationUncappedWState) || 0), true);
|
|
5260
5637
|
await this._queueState('chargingManagement.control.pvAllocationStorageActualChargeW', Math.round(Number(pvAllocationStorageActualChargeWState) || 0), true);
|
|
5638
|
+
await this._queueState('chargingManagement.control.pvBudgetSource', String(pvBudgetSourceState || ''), true);
|
|
5639
|
+
await this._queueState(
|
|
5640
|
+
'chargingManagement.control.pvBudgetCentralAgeMs',
|
|
5641
|
+
Number.isFinite(Number(pvBudgetCentralAgeMsState)) ? Math.round(Number(pvBudgetCentralAgeMsState)) : 0,
|
|
5642
|
+
true,
|
|
5643
|
+
);
|
|
5644
|
+
await this._queueState('chargingManagement.control.pvBudgetCentralTotalW', Math.round(Number(pvBudgetCentralTotalWState) || 0), true);
|
|
5645
|
+
await this._queueState('chargingManagement.control.pvBudgetCentralEvcsCapW', Math.round(Number(pvBudgetCentralEvcsCapWState) || 0), true);
|
|
5646
|
+
await this._queueState('chargingManagement.control.pvBudgetLocalEstimateW', Math.round(Number(pvBudgetLocalEstimateWState) || 0), true);
|
|
5647
|
+
await this._queueState('chargingManagement.control.pvBudgetMismatchW', Math.round(Number(pvBudgetMismatchWState) || 0), true);
|
|
5261
5648
|
} catch {
|
|
5262
5649
|
// ignore
|
|
5263
5650
|
}
|
|
@@ -5380,6 +5767,13 @@ if (components.length) {
|
|
|
5380
5767
|
pvAllocationEvcsCapW: Math.round(Number(pvAllocationEvcsCapWState) || 0),
|
|
5381
5768
|
pvAllocationUncappedW: Math.round(Number(pvAllocationUncappedWState) || 0),
|
|
5382
5769
|
pvAllocationStorageActualChargeW: Math.round(Number(pvAllocationStorageActualChargeWState) || 0),
|
|
5770
|
+
pvBudgetSource: String(pvBudgetSourceState || ''),
|
|
5771
|
+
pvBudgetCentralAuthoritative: !!pvBudgetCentralAuthoritative,
|
|
5772
|
+
pvBudgetCentralAgeMs: Number.isFinite(Number(pvBudgetCentralAgeMsState)) ? Math.round(Number(pvBudgetCentralAgeMsState)) : null,
|
|
5773
|
+
pvBudgetCentralTotalW: Math.round(Number(pvBudgetCentralTotalWState) || 0),
|
|
5774
|
+
pvBudgetCentralEvcsCapW: Math.round(Number(pvBudgetCentralEvcsCapWState) || 0),
|
|
5775
|
+
pvBudgetLocalEstimateW: Math.round(Number(pvBudgetLocalEstimateWState) || 0),
|
|
5776
|
+
pvBudgetMismatchW: Math.round(Number(pvBudgetMismatchWState) || 0),
|
|
5383
5777
|
evPriorityStorageYieldW: Math.round(evPriorityStorageYieldW || 0),
|
|
5384
5778
|
components,
|
|
5385
5779
|
};
|
|
@@ -6021,6 +6415,11 @@ if (components.length) {
|
|
|
6021
6415
|
await this._queueState('chargingManagement.control.actualW', Math.max(0, Math.round(Number(totalFreshActualPowerW || 0))), true);
|
|
6022
6416
|
await this._queueState('chargingManagement.control.reserveW', 0, true);
|
|
6023
6417
|
await this._queueState('chargingManagement.control.activeDemandReserveW', 0, true);
|
|
6418
|
+
await this._queueState('chargingManagement.control.pvActiveDemandReserveW', 0, true);
|
|
6419
|
+
await this._queueState('chargingManagement.control.pvActiveDemandIntentW', 0, true);
|
|
6420
|
+
await this._queueState('chargingManagement.control.pvPendingDemandIntentW', 0, true);
|
|
6421
|
+
await this._queueState('chargingManagement.control.pvPendingDemandTotalW', 0, true);
|
|
6422
|
+
await this._queueState('chargingManagement.control.pvPendingDemandWallboxes', 0, true);
|
|
6024
6423
|
await this._queueState('chargingManagement.control.activeDemandWallboxes', 0, true);
|
|
6025
6424
|
|
|
6026
6425
|
// Phase 4.2: Even in failsafe, publish Gate A (Netz/Phasen) diagnostics so the
|
|
@@ -6267,6 +6666,11 @@ if (components.length) {
|
|
|
6267
6666
|
await this._queueState('chargingManagement.control.actualW', Math.max(0, Math.round(Number(totalFreshActualPowerW || 0))), true);
|
|
6268
6667
|
await this._queueState('chargingManagement.control.reserveW', 0, true);
|
|
6269
6668
|
await this._queueState('chargingManagement.control.activeDemandReserveW', 0, true);
|
|
6669
|
+
await this._queueState('chargingManagement.control.pvActiveDemandReserveW', 0, true);
|
|
6670
|
+
await this._queueState('chargingManagement.control.pvActiveDemandIntentW', 0, true);
|
|
6671
|
+
await this._queueState('chargingManagement.control.pvPendingDemandIntentW', 0, true);
|
|
6672
|
+
await this._queueState('chargingManagement.control.pvPendingDemandTotalW', 0, true);
|
|
6673
|
+
await this._queueState('chargingManagement.control.pvPendingDemandWallboxes', 0, true);
|
|
6270
6674
|
await this._queueState('chargingManagement.control.activeDemandWallboxes', 0, true);
|
|
6271
6675
|
// Cleanup session tracking for removed wallboxes (avoid memory leaks)
|
|
6272
6676
|
for (const [safeKey, lastSeenTs] of this._chargingLastSeenMs.entries()) {
|
|
@@ -6360,6 +6764,11 @@ if (components.length) {
|
|
|
6360
6764
|
await this._queueState('chargingManagement.control.actualW', Math.max(0, Math.round(Number(totalFreshActualPowerW || 0))), true);
|
|
6361
6765
|
await this._queueState('chargingManagement.control.reserveW', 0, true);
|
|
6362
6766
|
await this._queueState('chargingManagement.control.activeDemandReserveW', 0, true);
|
|
6767
|
+
await this._queueState('chargingManagement.control.pvActiveDemandReserveW', 0, true);
|
|
6768
|
+
await this._queueState('chargingManagement.control.pvActiveDemandIntentW', 0, true);
|
|
6769
|
+
await this._queueState('chargingManagement.control.pvPendingDemandIntentW', 0, true);
|
|
6770
|
+
await this._queueState('chargingManagement.control.pvPendingDemandTotalW', 0, true);
|
|
6771
|
+
await this._queueState('chargingManagement.control.pvPendingDemandWallboxes', 0, true);
|
|
6363
6772
|
await this._queueState('chargingManagement.control.activeDemandWallboxes', 0, true);
|
|
6364
6773
|
|
|
6365
6774
|
// Gate C: Speicher-Unterstützung in Failsafe immer deaktivieren
|
|
@@ -6688,7 +7097,20 @@ if (components.length) {
|
|
|
6688
7097
|
let totalTargetCurrentA = 0;
|
|
6689
7098
|
let evcsActiveDemandReserveW = 0;
|
|
6690
7099
|
let evcsActiveDemandPvReserveW = 0;
|
|
7100
|
+
// PV-Intent bleibt waehrend Wallbox-Rampe, Start-Hysterese und zaeher
|
|
7101
|
+
// Leistungstelemetrie sichtbar. Ohne diesen zweiten Wert kann die zentrale
|
|
7102
|
+
// Budgetierung den EVCS-Anteil fuer einen Tick auf 0 setzen und der Speicher
|
|
7103
|
+
// nimmt anschliessend den kompletten PV-Ueberschuss.
|
|
7104
|
+
let evcsActiveDemandPvIntentW = 0;
|
|
6691
7105
|
let evcsActiveDemandWallboxes = 0;
|
|
7106
|
+
// Noch nicht physisch gestartete beziehungsweise erst hochregelnde
|
|
7107
|
+
// PV-Ladepunkte erhalten ihren Anteil als reinen PV-Intent. Dadurch bleibt
|
|
7108
|
+
// die Kundenprioritaet waehrend Start-Hysterese/EVSE-Suspend und Rampe
|
|
7109
|
+
// zentral reserviert, ohne ihn als bereits bezogene Netzlast zu verbuchen.
|
|
7110
|
+
let evcsPendingDemandPvIntentW = 0;
|
|
7111
|
+
let evcsPendingDemandTotalW = 0;
|
|
7112
|
+
let evcsPendingDemandWallboxes = 0;
|
|
7113
|
+
let evcsPendingCentralTotalGrantW = null;
|
|
6692
7114
|
|
|
6693
7115
|
// More specific budget limitation reason based on the active caps in this tick.
|
|
6694
7116
|
// Used for per-connector diagnostics (without changing the underlying allocation math).
|
|
@@ -7264,7 +7686,18 @@ if (components.length) {
|
|
|
7264
7686
|
const demandReserveThisW = activeChargingDemand ? Math.max(demandActualW, demandCommandW, demandTargetW) : 0;
|
|
7265
7687
|
if (demandReserveThisW > 0) {
|
|
7266
7688
|
evcsActiveDemandReserveW += demandReserveThisW;
|
|
7267
|
-
|
|
7689
|
+
|
|
7690
|
+
// PV-Reservierung besteht aus zwei bewusst getrennten Signalen:
|
|
7691
|
+
// 1) tatsaechlich im aktuellen Allocation-Schritt genutzter PV-Anteil,
|
|
7692
|
+
// 2) aktiver PV-Ladeintent aus Ist-, Kommando- oder Zielwert.
|
|
7693
|
+
// Der Intent verhindert eine kurzzeitige Freigabe des EVCS-Anteils an
|
|
7694
|
+
// den Speicher, wenn PV-Hysterese oder Wallbox-Telemetrie fuer einen
|
|
7695
|
+
// einzelnen Tick noch keinen pvUsedThisW liefern. Der zentrale EVCS-Cap
|
|
7696
|
+
// begrenzt diesen Wert spaeter weiterhin strikt auf die Kundenvorgabe.
|
|
7697
|
+
const demandPvActualThisW = Math.max(0, Math.min(demandReserveThisW, pvUsedThisW || 0));
|
|
7698
|
+
const demandPvIntentThisW = computePvManagedDemandIntentW(effMode, demandReserveThisW, w.minPW);
|
|
7699
|
+
evcsActiveDemandPvReserveW += demandPvActualThisW;
|
|
7700
|
+
evcsActiveDemandPvIntentW += demandPvIntentThisW;
|
|
7268
7701
|
evcsActiveDemandWallboxes += 1;
|
|
7269
7702
|
}
|
|
7270
7703
|
|
|
@@ -7526,8 +7959,129 @@ if (components.length) {
|
|
|
7526
7959
|
}
|
|
7527
7960
|
|
|
7528
7961
|
|
|
7962
|
+
/**
|
|
7963
|
+
* Code-Teil: zentrale PV-Intent-Reservierung vor Speicherregelung
|
|
7964
|
+
* Zweck: Ermittelt nach der realen Wallbox-Allokation den noch offenen,
|
|
7965
|
+
* technisch nutzbaren PV-Bedarf verbundener Ladepunkte. Dieser zweite
|
|
7966
|
+
* Durchlauf ist bewusst nach allen Sollwerten angeordnet: Erst dadurch
|
|
7967
|
+
* sind Anschluss-, Stations- und aktive EVCS-Verbraeuche eindeutig
|
|
7968
|
+
* abgezogen, sodass mehrere Ladepunkte denselben Rest nicht doppelt
|
|
7969
|
+
* reservieren koennen.
|
|
7970
|
+
*/
|
|
7971
|
+
try {
|
|
7972
|
+
const centralEvcsCapW = Math.max(0, Number(pvStartReadyBudgetW) || 0);
|
|
7973
|
+
let pendingPvRemainingW = Math.max(
|
|
7974
|
+
0,
|
|
7975
|
+
centralEvcsCapW - Math.min(centralEvcsCapW, Math.max(0, Number(evcsActiveDemandPvIntentW) || 0)),
|
|
7976
|
+
);
|
|
7977
|
+
const centralBudgetRuntime = this.adapter && this.adapter._emsBudget;
|
|
7978
|
+
const centralTotalGrant = centralBudgetRuntime && typeof centralBudgetRuntime.getTotalGrant === 'function'
|
|
7979
|
+
? centralBudgetRuntime.getTotalGrant({ key: 'evcs', requestedW: Number.MAX_SAFE_INTEGER })
|
|
7980
|
+
: (centralBudgetRuntime && typeof centralBudgetRuntime.grant === 'function'
|
|
7981
|
+
? centralBudgetRuntime.grant({ key: 'evcs', requestedW: Number.MAX_SAFE_INTEGER, pvOnly: false })
|
|
7982
|
+
: null);
|
|
7983
|
+
evcsPendingCentralTotalGrantW = centralTotalGrant && Number.isFinite(Number(centralTotalGrant.grantW))
|
|
7984
|
+
? Math.max(0, Number(centralTotalGrant.grantW))
|
|
7985
|
+
: null;
|
|
7986
|
+
let pendingTotalRemainingW = computePendingPvStartTotalBudgetW({
|
|
7987
|
+
localRemainingW: Number.isFinite(Number(remainingW))
|
|
7988
|
+
? Math.max(0, Number(remainingW))
|
|
7989
|
+
: Number.POSITIVE_INFINITY,
|
|
7990
|
+
centralTotalGrantW: evcsPendingCentralTotalGrantW,
|
|
7991
|
+
activeDemandW: evcsActiveDemandReserveW,
|
|
7992
|
+
});
|
|
7993
|
+
const pendingStationRemainingW = new Map(stationRemainingW);
|
|
7994
|
+
const allocationRows = new Map(
|
|
7995
|
+
debugAlloc
|
|
7996
|
+
.filter((row) => row && typeof row.safe === 'string')
|
|
7997
|
+
.map((row) => [String(row.safe), row]),
|
|
7998
|
+
);
|
|
7999
|
+
|
|
8000
|
+
for (const w of sorted) {
|
|
8001
|
+
if (pendingPvRemainingW <= 0) break;
|
|
8002
|
+
const row = allocationRows.get(String(w.safe || '')) || {};
|
|
8003
|
+
const effMode = String(w.effectiveMode || row.effectiveMode || '').trim().toLowerCase();
|
|
8004
|
+
if (effMode !== 'pv' && effMode !== 'minpv') continue;
|
|
8005
|
+
|
|
8006
|
+
const actualNowW = (typeof w.actualPowerW === 'number' && Number.isFinite(w.actualPowerW))
|
|
8007
|
+
? Math.max(0, Math.abs(w.actualPowerW))
|
|
8008
|
+
: 0;
|
|
8009
|
+
const commandNowW = Math.max(0, Number(row.targetW) || 0);
|
|
8010
|
+
const demandNowW = Math.max(0, Number(row.demandReserveW) || 0, actualNowW, commandNowW);
|
|
8011
|
+
const activePvIntentW = computePvManagedDemandIntentW(effMode, demandNowW, w.minPW);
|
|
8012
|
+
const stationAvailW = w.stationKey && pendingStationRemainingW.has(w.stationKey)
|
|
8013
|
+
? Math.max(0, Number(pendingStationRemainingW.get(w.stationKey)) || 0)
|
|
8014
|
+
: Number.POSITIVE_INFINITY;
|
|
8015
|
+
const technicalMinW = (w.chargerType === 'AC' && Number(w.phases || 0) === 3)
|
|
8016
|
+
? Math.max(0, Math.max(num(w.minPW, 0), acMinPower3pW))
|
|
8017
|
+
: Math.max(0, num(w.minPW, 0));
|
|
8018
|
+
const startCooldownActive = effMode === 'pv'
|
|
8019
|
+
&& Number.isFinite(Number(w.pvStartCooldownUntilMs))
|
|
8020
|
+
&& Number(w.pvStartCooldownUntilMs) > now;
|
|
8021
|
+
const goalBlocked = w.goalEnabled === true
|
|
8022
|
+
&& (String(w.goalStatus || '') === 'waiting_soc' || String(w.goalStatus || '') === 'soc_stale');
|
|
8023
|
+
|
|
8024
|
+
const pending = computePendingPvStartIntentW({
|
|
8025
|
+
mode: effMode,
|
|
8026
|
+
enabled: w.enabled === true,
|
|
8027
|
+
online: w.online === true,
|
|
8028
|
+
connected: w.vehiclePlugged === true,
|
|
8029
|
+
controlBasis: w.controlBasis,
|
|
8030
|
+
status: w.connectorStatus,
|
|
8031
|
+
startCooldownActive,
|
|
8032
|
+
goalBlocked,
|
|
8033
|
+
currentPowerW: demandNowW,
|
|
8034
|
+
currentPvIntentW: activePvIntentW,
|
|
8035
|
+
minPowerW: w.minPW,
|
|
8036
|
+
technicalMinW,
|
|
8037
|
+
maxPowerW: w.maxPW,
|
|
8038
|
+
totalRemainingW: pendingTotalRemainingW,
|
|
8039
|
+
stationRemainingW: stationAvailW,
|
|
8040
|
+
pvRemainingW: pendingPvRemainingW,
|
|
8041
|
+
activityThresholdW,
|
|
8042
|
+
});
|
|
8043
|
+
const pendingIntentW = Math.max(0, Number(pending.intentW) || 0);
|
|
8044
|
+
if (pendingIntentW <= 0) {
|
|
8045
|
+
row.pendingPvIntentW = 0;
|
|
8046
|
+
row.pendingPvIntentReason = String(pending.reason || '');
|
|
8047
|
+
continue;
|
|
8048
|
+
}
|
|
8049
|
+
|
|
8050
|
+
const pendingTotalDemandW = Math.max(pendingIntentW, Number(pending.totalDemandW) || 0);
|
|
8051
|
+
evcsPendingDemandPvIntentW += pendingIntentW;
|
|
8052
|
+
evcsPendingDemandTotalW += pendingTotalDemandW;
|
|
8053
|
+
evcsPendingDemandWallboxes += 1;
|
|
8054
|
+
pendingPvRemainingW = Math.max(0, pendingPvRemainingW - pendingIntentW);
|
|
8055
|
+
if (Number.isFinite(pendingTotalRemainingW)) {
|
|
8056
|
+
pendingTotalRemainingW = Math.max(0, pendingTotalRemainingW - pendingTotalDemandW);
|
|
8057
|
+
}
|
|
8058
|
+
if (w.stationKey && pendingStationRemainingW.has(w.stationKey)) {
|
|
8059
|
+
pendingStationRemainingW.set(
|
|
8060
|
+
w.stationKey,
|
|
8061
|
+
Math.max(0, stationAvailW - pendingTotalDemandW),
|
|
8062
|
+
);
|
|
8063
|
+
}
|
|
8064
|
+
|
|
8065
|
+
row.pendingPvIntentW = Math.round(pendingIntentW);
|
|
8066
|
+
row.pendingPvIntentTotalDemandW = Math.round(pendingTotalDemandW);
|
|
8067
|
+
row.pendingPvIntentReason = String(pending.reason || '');
|
|
8068
|
+
}
|
|
8069
|
+
} catch (_ePendingPvIntent) {
|
|
8070
|
+
// Sicherheitsfallback: Ein Diagnose-/Intentfehler darf die produktive
|
|
8071
|
+
// Wallbox-Allokation nicht unterbrechen. Ohne Intent bleibt nur die
|
|
8072
|
+
// bereits aktive EVCS-PV-Reservierung bestehen.
|
|
8073
|
+
evcsPendingDemandPvIntentW = 0;
|
|
8074
|
+
evcsPendingDemandTotalW = 0;
|
|
8075
|
+
evcsPendingDemandWallboxes = 0;
|
|
8076
|
+
}
|
|
8077
|
+
|
|
8078
|
+
|
|
7529
8079
|
const evcsControlReserveW = Math.max(0, Math.round(evcsActiveDemandReserveW));
|
|
7530
8080
|
const evcsControlPvReserveW = Math.max(0, Math.round(evcsActiveDemandPvReserveW));
|
|
8081
|
+
const evcsControlPvIntentW = Math.max(0, Math.round(evcsActiveDemandPvIntentW));
|
|
8082
|
+
const evcsControlPendingPvIntentW = Math.max(0, Math.round(evcsPendingDemandPvIntentW));
|
|
8083
|
+
const evcsControlPendingDemandW = Math.max(0, Math.round(evcsPendingDemandTotalW));
|
|
8084
|
+
const evcsControlTotalPvIntentW = Math.max(0, evcsControlPvIntentW + evcsControlPendingPvIntentW);
|
|
7531
8085
|
const evcsControlRemainingW = Number.isFinite(budgetW)
|
|
7532
8086
|
? Math.max(0, Math.round(Number(budgetW) - evcsControlReserveW))
|
|
7533
8087
|
: 0;
|
|
@@ -7536,6 +8090,14 @@ if (components.length) {
|
|
|
7536
8090
|
budgetDebug.evcsReservedW = evcsControlReserveW;
|
|
7537
8091
|
budgetDebug.evcsActiveDemandReserveW = evcsControlReserveW;
|
|
7538
8092
|
budgetDebug.evcsActiveDemandPvReserveW = evcsControlPvReserveW;
|
|
8093
|
+
budgetDebug.evcsActiveDemandPvIntentW = evcsControlPvIntentW;
|
|
8094
|
+
budgetDebug.evcsPendingDemandPvIntentW = evcsControlPendingPvIntentW;
|
|
8095
|
+
budgetDebug.evcsPendingDemandTotalW = evcsControlPendingDemandW;
|
|
8096
|
+
budgetDebug.evcsPendingDemandWallboxes = evcsPendingDemandWallboxes;
|
|
8097
|
+
budgetDebug.evcsTotalPvIntentW = evcsControlTotalPvIntentW;
|
|
8098
|
+
budgetDebug.evcsPendingCentralTotalGrantW = Number.isFinite(Number(evcsPendingCentralTotalGrantW))
|
|
8099
|
+
? Math.round(Number(evcsPendingCentralTotalGrantW))
|
|
8100
|
+
: null;
|
|
7539
8101
|
budgetDebug.evcsActiveDemandWallboxes = evcsActiveDemandWallboxes;
|
|
7540
8102
|
}
|
|
7541
8103
|
const budgetEntry = debugAlloc.find(a => a && a.type === 'budget');
|
|
@@ -7543,6 +8105,14 @@ if (components.length) {
|
|
|
7543
8105
|
budgetEntry.details.evcsReservedW = evcsControlReserveW;
|
|
7544
8106
|
budgetEntry.details.evcsActiveDemandReserveW = evcsControlReserveW;
|
|
7545
8107
|
budgetEntry.details.evcsActiveDemandPvReserveW = evcsControlPvReserveW;
|
|
8108
|
+
budgetEntry.details.evcsActiveDemandPvIntentW = evcsControlPvIntentW;
|
|
8109
|
+
budgetEntry.details.evcsPendingDemandPvIntentW = evcsControlPendingPvIntentW;
|
|
8110
|
+
budgetEntry.details.evcsPendingDemandTotalW = evcsControlPendingDemandW;
|
|
8111
|
+
budgetEntry.details.evcsPendingDemandWallboxes = evcsPendingDemandWallboxes;
|
|
8112
|
+
budgetEntry.details.evcsTotalPvIntentW = evcsControlTotalPvIntentW;
|
|
8113
|
+
budgetEntry.details.evcsPendingCentralTotalGrantW = Number.isFinite(Number(evcsPendingCentralTotalGrantW))
|
|
8114
|
+
? Math.round(Number(evcsPendingCentralTotalGrantW))
|
|
8115
|
+
: null;
|
|
7546
8116
|
budgetEntry.details.evcsActiveDemandWallboxes = evcsActiveDemandWallboxes;
|
|
7547
8117
|
}
|
|
7548
8118
|
} catch {
|
|
@@ -7723,6 +8293,15 @@ if (components.length) {
|
|
|
7723
8293
|
await this._queueState('chargingManagement.control.actualW', Math.max(0, Math.round(Number(totalFreshActualPowerW || 0))), true);
|
|
7724
8294
|
await this._queueState('chargingManagement.control.reserveW', evcsControlReserveW, true);
|
|
7725
8295
|
await this._queueState('chargingManagement.control.activeDemandReserveW', evcsControlReserveW, true);
|
|
8296
|
+
await this._queueState('chargingManagement.control.pvActiveDemandReserveW', evcsControlPvReserveW, true);
|
|
8297
|
+
await this._queueState('chargingManagement.control.pvActiveDemandIntentW', evcsControlPvIntentW, true);
|
|
8298
|
+
await this._queueState('chargingManagement.control.pvPendingDemandIntentW', evcsControlPendingPvIntentW, true);
|
|
8299
|
+
await this._queueState('chargingManagement.control.pvPendingDemandTotalW', evcsControlPendingDemandW, true);
|
|
8300
|
+
await this._queueState('chargingManagement.control.pvPendingDemandWallboxes', evcsPendingDemandWallboxes, true);
|
|
8301
|
+
await this._queueState('chargingManagement.control.pvTotalDemandIntentW', evcsControlTotalPvIntentW, true);
|
|
8302
|
+
await this._queueState('chargingManagement.control.pvCentralGrantW', 0, true);
|
|
8303
|
+
await this._queueState('chargingManagement.control.pvCentralReservedW', 0, true);
|
|
8304
|
+
await this._queueState('chargingManagement.control.pvCentralRemainingAfterEvcsW', 0, true);
|
|
7726
8305
|
await this._queueState('chargingManagement.control.activeDemandWallboxes', evcsActiveDemandWallboxes, true);
|
|
7727
8306
|
await this._queueState('chargingManagement.control.remainingW', tsControlApply ? tsControlApply.remainingW : evcsControlRemainingW, true);
|
|
7728
8307
|
|
|
@@ -7747,19 +8326,58 @@ if (components.length) {
|
|
|
7747
8326
|
if (rt && typeof rt.reserve === 'function') {
|
|
7748
8327
|
const evcsActualW = Math.max(0, Math.round(Number(totalFreshActualPowerW || 0)));
|
|
7749
8328
|
const evcsReserveW = evcsControlReserveW;
|
|
7750
|
-
const
|
|
8329
|
+
const evcsAllocationCapW = Number.isFinite(Number(pvAllocationEvcsCapWState))
|
|
8330
|
+
? Math.max(0, Number(pvAllocationEvcsCapWState))
|
|
8331
|
+
: evcsReserveW;
|
|
8332
|
+
// Nicht an pvAvailableState koppeln: Dieses Hysterese-Signal darf den
|
|
8333
|
+
// bereits aktiven/angeforderten EVCS-PV-Anteil nicht fuer einen einzelnen
|
|
8334
|
+
// Tick freigeben. Der Allocation-Cap bleibt die harte Obergrenze.
|
|
8335
|
+
const centralGrantFn = typeof rt.getPvGrant === 'function'
|
|
8336
|
+
? rt.getPvGrant.bind(rt)
|
|
8337
|
+
: (typeof rt.grant === 'function' ? rt.grant.bind(rt) : null);
|
|
8338
|
+
const totalPvDemandW = Math.max(0, evcsControlTotalPvIntentW, evcsControlPvReserveW);
|
|
8339
|
+
const centralGrant = centralGrantFn
|
|
8340
|
+
? centralGrantFn({ key: 'evcs', requestedW: totalPvDemandW, maxW: evcsAllocationCapW, pvOnly: true })
|
|
8341
|
+
: null;
|
|
8342
|
+
const centralGrantW = centralGrant && Number.isFinite(Number(centralGrant.grantW))
|
|
8343
|
+
? Math.max(0, Number(centralGrant.grantW))
|
|
8344
|
+
: evcsAllocationCapW;
|
|
8345
|
+
const evcsPvReserveW = computeEvcsPvBudgetReservationW({
|
|
8346
|
+
reserveW: evcsReserveW,
|
|
8347
|
+
// Aktive Ladeleistung bleibt reale Gesamtlast. Ein noch nicht
|
|
8348
|
+
// gestarteter PV-Anteil wird ausschließlich als Intent geführt,
|
|
8349
|
+
// damit er das Speicher-PV-Budget reduziert, ohne Netz-/Anschluss-
|
|
8350
|
+
// leistung vorzutäuschen.
|
|
8351
|
+
demandW: evcsReserveW,
|
|
8352
|
+
pendingDemandW: evcsControlPendingDemandW,
|
|
8353
|
+
actualPvW: evcsControlPvReserveW,
|
|
8354
|
+
intentPvW: evcsControlPvIntentW,
|
|
8355
|
+
pendingIntentPvW: evcsControlPendingPvIntentW,
|
|
8356
|
+
allocationCapW: Math.min(evcsAllocationCapW, centralGrantW),
|
|
8357
|
+
});
|
|
7751
8358
|
rt.reserve({
|
|
7752
8359
|
key: 'evcs',
|
|
7753
8360
|
app: 'chargingManagement',
|
|
7754
8361
|
label: 'Ladepunkte',
|
|
7755
8362
|
priority: 100,
|
|
7756
8363
|
actualW: evcsActualW,
|
|
7757
|
-
requestedW: evcsReserveW,
|
|
8364
|
+
requestedW: Math.max(0, evcsReserveW + evcsControlPendingDemandW),
|
|
7758
8365
|
reserveW: evcsReserveW,
|
|
7759
8366
|
pvReserveW: evcsPvReserveW,
|
|
7760
8367
|
pvOnly: false,
|
|
7761
8368
|
mode: String(mode || ''),
|
|
7762
8369
|
});
|
|
8370
|
+
|
|
8371
|
+
// Diagnose nach der Reservierung veröffentlichen. Speicher,
|
|
8372
|
+
// Thermik und Heizstab sehen im selben EMS-Zyklus genau diesen
|
|
8373
|
+
// Restwert; damit existiert kein paralleles Modulbudget mehr.
|
|
8374
|
+
await this._queueState('chargingManagement.control.pvCentralGrantW', Math.round(centralGrantW), true);
|
|
8375
|
+
await this._queueState('chargingManagement.control.pvCentralReservedW', Math.round(evcsPvReserveW), true);
|
|
8376
|
+
await this._queueState(
|
|
8377
|
+
'chargingManagement.control.pvCentralRemainingAfterEvcsW',
|
|
8378
|
+
Number.isFinite(Number(rt.remainingPvW)) ? Math.round(Math.max(0, Number(rt.remainingPvW))) : 0,
|
|
8379
|
+
true,
|
|
8380
|
+
);
|
|
7763
8381
|
}
|
|
7764
8382
|
} catch (_e) {
|
|
7765
8383
|
// budget diagnostics only
|
|
@@ -7785,4 +8403,11 @@ if (components.length) {
|
|
|
7785
8403
|
}
|
|
7786
8404
|
}
|
|
7787
8405
|
|
|
7788
|
-
module.exports = {
|
|
8406
|
+
module.exports = {
|
|
8407
|
+
ChargingManagementModule,
|
|
8408
|
+
computePvManagedDemandIntentW,
|
|
8409
|
+
computePendingPvStartIntentW,
|
|
8410
|
+
computePendingPvStartTotalBudgetW,
|
|
8411
|
+
computeEvcsPvBudgetReservationW,
|
|
8412
|
+
resolveChargingPvBudgetControl,
|
|
8413
|
+
};
|