Jeep identifiee aussi par sa fin de trajet juste avant le branchement (soir sans charge)

This commit is contained in:
Tallagrand Thierry
2026-10-05 23:42:14 +02:00
parent 8f526bdcd6
commit 5e88ce5720
4 changed files with 61 additions and 16 deletions

View File

@@ -1434,15 +1434,15 @@ async function appliquerEtiquetteConcierge(sql, client, st) {
// 3. niveau « saisi » du vehicule = niveau lu, sauf saisie humaine depuis le
// branchement - 1 h (l'automatisation HA recale la reference du compteur).
// Le concierge ne doit alors plus poser sa question : il lit etiquette_branchement.
async function etiqueterJeepUconnect(sql, client, st, branche, niveau) {
async function etiqueterJeepUconnect(sql, client, st, branche, niveau, motif = 'branchee') {
if (DRY) return 0;
const { rowCount } = await client.query(
`INSERT INTO etiquette_branchement (branchement, label, source_airtria, confirmed_at)
VALUES ($1, 'JEEP', 'uconnect', $2) ON CONFLICT (branchement) DO NOTHING`,
[branche, new Date().toISOString()]);
if (!rowCount) return 0; // deja etiquete (le proprietaire a repondu) : on ne touche a rien
await journaliser(sql, 'vehicule', `Branchement identifie : JEEP (la voiture se declare branchee, Uconnect), niveau ${niveau} %`,
{ origine: 'uconnect', label: 'JEEP', branchement: branche.toISOString(), niveau });
await journaliser(sql, 'vehicule', `Branchement identifie : JEEP (${motif === 'arrivee' ? 'fin de trajet juste avant le branchement' : 'la voiture se declare branchee'}, Uconnect), niveau ${niveau} %`,
{ origine: 'uconnect', label: 'JEEP', branchement: branche.toISOString(), niveau, preuve: motif });
let n = 1 + await piloterSelecteurVehicule(sql, st, 'JEEP', 'uconnect');
const saisieA = Number(st.get('input_datetime.victron_evcs_vehicle_level_at')?.attributes?.timestamp) * 1000;
if (!(saisieA >= branche.getTime() - 3600000)) {
@@ -2212,7 +2212,7 @@ async function cycle(client) {
}) + await ingererNiveauSaisi(sql, st).catch((e) => {
console.error(`niveau saisi en echec : ${e.message}`); return 0;
}) + await ingererJeep(sql, (q, v) => client.query(q, v), st, journaliser,
(branche, niveau) => etiqueterJeepUconnect(sql, client, st, branche, niveau)).catch((e) => {
(branche, niveau, motif) => etiqueterJeepUconnect(sql, client, st, branche, niveau, motif)).catch((e) => {
console.error(`jeep uconnect en echec : ${e.message}`); return 0;
}),
pvDiagnostic: DRY ? 0 : await publierDiagnosticPv(st).catch((e) => {