Chauffe-eau en HC de nuit les jours faibles : decision quotidienne du bilan, workflow ECS sous controle du depot (VRM, prevision du jour), energie 24 h
This commit is contained in:
@@ -33,6 +33,7 @@ import { creerSchemaKm, ingererReleves, ingererNiveauSaisi, ingererJeep } from '
|
||||
import { texteRapport, envoyer, donneesNuit, texteDepuis } from './rapport-nuit.mjs';
|
||||
import { diagnosticPv, etatCellules, productionJour, chargeSolaire, bilanNuit, etatReseau, importJour, minuitLocal, COMPTEURS_IMPORT, COMPTEUR_EDF, consoJour, COMPTEURS_CONSO, projectionSoir, previsionNuit, vrmVersCourbes, nuitMaisonPrevue } from './diagnostics-agent.mjs';
|
||||
import { transitionsDansSerie } from './allers-retours.mjs';
|
||||
import { energieSur24h, COMPTEUR_CHAUFFE_EAU } from './chauffe-eau.mjs';
|
||||
|
||||
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const ONCE = process.argv.includes('--once');
|
||||
@@ -2064,6 +2065,25 @@ async function valeursAMinuit() {
|
||||
return valeurs;
|
||||
}
|
||||
|
||||
// Chauffe-eau sur 24 h (07/10/2026) : securite eau chaude de la regle « jour
|
||||
// faible » du workflow ECS. Illisible -> « indisponible » : le workflow ne
|
||||
// restreint alors rien (jamais un ballon froid par panne de capteur).
|
||||
async function publierChauffeEau24h() {
|
||||
const fin = new Date(), debut = new Date(fin.getTime() - 24 * 3600e3);
|
||||
const r = await fetch(
|
||||
`${HA_URL}/api/history/period/${debut.toISOString()}?end_time=${encodeURIComponent(fin.toISOString())}` +
|
||||
`&filter_entity_id=${COMPTEUR_CHAUFFE_EAU}&minimal_response&no_attributes`,
|
||||
{ headers: { Authorization: `Bearer ${HA_TOKEN}` }, signal: AbortSignal.timeout(15000) },
|
||||
);
|
||||
if (!r.ok) throw new Error(`historique HA ${r.status}`);
|
||||
const kwh = energieSur24h((await r.json())[0]);
|
||||
await publierCapteur('sensor.evcs_chauffe_eau_24h_kwh', kwh === null ? 'indisponible' : kwh, {
|
||||
friendly_name: 'EVCS — chauffe-eau sur 24 h', unit_of_measurement: 'kWh', icon: 'mdi:water-boiler',
|
||||
compteur: COMPTEUR_CHAUFFE_EAU, calcule_a: fin.toISOString(),
|
||||
});
|
||||
return 1;
|
||||
}
|
||||
|
||||
async function publierImportJour(st) {
|
||||
const minuit = await valeursAMinuit();
|
||||
const courant = {};
|
||||
@@ -2171,6 +2191,7 @@ async function publierNuitMaison(client) {
|
||||
return 1;
|
||||
}
|
||||
let bilanNuitPublie = false; // publie des le premier cycle, puis toutes les 5 min
|
||||
let chauffeEauPublie = false; // chauffe-eau sur 24 h (07/10) : premier cycle puis toutes les 5 min
|
||||
async function publierBilanNuit(client) {
|
||||
if (DRY || !client) return 0;
|
||||
const d = await donneesNuit(client);
|
||||
@@ -2282,6 +2303,9 @@ async function cycle(client) {
|
||||
nuitMaison: (DRY || (nuitMaisonPubliee && new Date().getMinutes() % 5 !== 2)) ? 0 : await publierNuitMaison(client).then((n) => { nuitMaisonPubliee = true; return n; }).catch((e) => {
|
||||
console.error(`nuit de la maison : ${e.message}`); return 0;
|
||||
}),
|
||||
chauffeEau24h: (DRY || (chauffeEauPublie && new Date().getMinutes() % 5 !== 4)) ? 0 : await publierChauffeEau24h().then((n) => { chauffeEauPublie = true; return n; }).catch((e) => {
|
||||
console.error(`chauffe-eau 24 h : ${e.message}`); return 0;
|
||||
}),
|
||||
bilanNuit: (DRY || (bilanNuitPublie && new Date().getMinutes() % 5 !== 1)) ? 0 : await publierBilanNuit(client).then((n) => { bilanNuitPublie = true; return n; }).catch((e) => {
|
||||
console.error(`bilan de nuit : ${e.message}`); return 0;
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user