sensor.evcs_batterie_projection_soir : volontairement « indetermine » tant que la prevision est fausse

Incident 27/09 : l'agent annoncait « vers 90 % » de sa tete. La prevision
Forecast.Solar sous-estime d'environ 50-60 % : on publie des faits (SOC,
ecart de prevision), jamais un SOC projete. Tests 61/61.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011uJ47NxgfpGnuuMr3f2n7Z
This commit is contained in:
Tallagrand Thierry
2026-09-27 18:12:32 +02:00
parent 10d9b43728
commit dfd99ca957
3 changed files with 57 additions and 2 deletions

View File

@@ -2,7 +2,7 @@
// Les cas PV reprennent les gammes du banc OpenClaw (HANDOFF §77) : G3, G4, G5, G7.
// node tests/diagnostics-agent/run.mjs
import fs from 'node:fs';
import { diagnosticPv, etatCellules, productionJour, chargeSolaire, bilanNuit, etatReseau, importJour, COMPTEURS_IMPORT, COMPTEUR_EDF, MPPT_MODES, ORIGINE_PAR_SOURCE, consoJour, COMPTEURS_CONSO } from '../../tools/diagnostics-agent.mjs';
import { diagnosticPv, etatCellules, productionJour, chargeSolaire, bilanNuit, etatReseau, importJour, COMPTEURS_IMPORT, COMPTEUR_EDF, MPPT_MODES, ORIGINE_PAR_SOURCE, consoJour, COMPTEURS_CONSO, projectionSoir } from '../../tools/diagnostics-agent.mjs';
const LIM = 'voltage_current_limited', ACT = 'mppt_active';
function st({ pv, conso, reseau, soc = 80, courant = 0, edf = 'off', modes }) {
@@ -269,6 +269,24 @@ for (const [nom, r, test] of imp) {
globalThis.__nConso = cj.length;
}
// --- Projection du soir : indetermine tant que la prevision est fausse -----
{
const m = new Map([['sensor.victron_battery_soc', { state: '42' }],
['sensor.energy_production_today_remaining', { state: '6.8' }], ['sensor.evcs_prevision_contre_reel', { state: '63' }]]);
const r = projectionSoir(m);
const pj = [
['projection : etat indetermine, JAMAIS un SOC chiffre (incident 27/09 « vers 90 % »)', r,
(x) => x.etat === 'indetermine' && !/\b(9\d|[1-8]\d) ?% au coucher/.test(x.attributs.explication)],
['projection : l explication donne le SOC actuel et l ecart de prevision', r,
(x) => /42 %/.test(x.attributs.explication) && /63 %/.test(x.attributs.explication)],
];
for (const [nom, x, test] of pj) {
const ok = test(x); if (!ok) { ko++; console.log(JSON.stringify(x)); }
console.log(`${ok ? 'OK ' : 'KO '} ${nom}`);
}
globalThis.__nConso = (globalThis.__nConso || 0) + pj.length;
}
const n = (globalThis.__nConso || 0) + cas.length + cel.length + prod.length + charge.length + 1 + bn.length + res.length + imp.length;
console.log(`\n${n - ko}/${n}`);
process.exit(ko ? 1 : 0);