Arbitre : voiture qui ne charge pas avec EDF ferme (tout etat), alerte recharge bridee
This commit is contained in:
@@ -2129,6 +2129,11 @@ async function arbitrer(sql, client, st) {
|
||||
raison: txt(st.get('input_text.victron_evcs_surplus_reason')?.state),
|
||||
vehicule: txt(st.get('input_select.victron_evcs_vehicle')?.state),
|
||||
modeNuit: txt(st.get('input_select.victron_evcs_night_charge_mode')?.state),
|
||||
sessionEngagee: txt(st.get('input_boolean.victron_evcs_night_grid_session_committed')?.state) === 'on',
|
||||
manqueKwh: Number(st.get('input_number.evcs_balance_grid_energy_needed_kwh')?.state),
|
||||
soc: Number(st.get('sensor.victron_battery_soc')?.state),
|
||||
batterieA: Number(st.get('sensor.victron_battery_current')?.state),
|
||||
dvccA: Number(st.get('sensor.victron_max_charge_current_setting')?.state),
|
||||
});
|
||||
const { rows: [ouvert] } = await client.query(`SELECT * FROM arbitrage WHERE ferme IS NULL ORDER BY ouvert DESC LIMIT 1`);
|
||||
const publier = (etat, a) => publierCapteur('sensor.evcs_arbitrage', etat, { friendly_name: 'Arbitrage demande au proprietaire', ...a });
|
||||
@@ -2155,15 +2160,17 @@ async function arbitrer(sql, client, st) {
|
||||
await client.query(`INSERT INTO arbitrage (id, cas, question, choix, depuis) VALUES ($1,$2,$3,$4,$5) ON CONFLICT DO NOTHING`,
|
||||
[id, sit.cas, sit.question, JSON.stringify(sit.choix), new Date(arbitrageCandidat.depuis)]);
|
||||
await journaliser(sql, 'arbitrage', `Arbitrage demande : ${sit.cas}`, { id, question: sit.question });
|
||||
await publier('question', { id, cas: sit.cas, question: sit.question,
|
||||
// Sans choix = ALERTE (10/10) : rien a decider, seulement a signaler.
|
||||
await publier(sit.choix.length ? 'question' : 'alerte', { id, cas: sit.cas, question: sit.question,
|
||||
choix: sit.choix.map((c) => ({ cle: c.cle, libelle: c.libelle })),
|
||||
depuis: new Date(arbitrageCandidat.depuis).toISOString(),
|
||||
consigne: 'Repondre par le numero du choix. Seul l ordre attache au choix est applique.' });
|
||||
consigne: sit.choix.length ? 'Repondre par le numero du choix. Seul l ordre attache au choix est applique.'
|
||||
: 'Alerte : rien a repondre.' });
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Reponse du proprietaire, par le concierge.
|
||||
if (!ouvert.reponse_cle) {
|
||||
// Reponse du proprietaire, par le concierge (pas pour une alerte).
|
||||
if (!ouvert.reponse_cle && (ouvert.choix || []).length) {
|
||||
let rep = null;
|
||||
try { rep = JSON.parse(txt(st.get('input_text.evcs_arbitrage_reponse')?.state) || 'null'); } catch { rep = null; }
|
||||
if (rep && rep.id === ouvert.id) {
|
||||
|
||||
Reference in New Issue
Block a user