SDB : seche-serviette et deshumidificateur en consommateurs de surplus solaire (chargeurs brides), arret a 28 °C

This commit is contained in:
Tallagrand Thierry
2026-10-10 00:49:53 +02:00
parent 75252d64be
commit ff54d014ae
5 changed files with 112 additions and 3 deletions

View File

@@ -59,6 +59,40 @@ d = dec({ sdb_temperature_c: '26.3', sdb_humidity_pct: '56', sdb_humidity_age_mi
ok('hysteresis-humidite-inchangee', d.deshumide_action === 'none', JSON.stringify(d));
d = dec({ sdb_temperature_c: '26.3', sdb_humidity_pct: '56', sdb_humidity_age_min: '400', soc_percent: '80' });
ok('valeur-figee-3h-muet', d.deshumide_action === 'turn_off', JSON.stringify(d));
// MODE SURPLUS (10/10) : releve du 08/10 16 h — SOC 96, batterie 2 A, solaire bride.
const D16 = class extends Date { constructor(...a) { super(...(a.length ? a : [Date.parse('2026-10-08T16:00:00+02:00')])); } static now() { return Date.parse('2026-10-08T16:00:00+02:00'); } };
const decAt = (o, DC = D16) => { const ctx = { $input: { first: () => ({ json: { data: JSON.stringify({ ...base, ...o }) } }) }, console, Date: DC, Intl, Math, Number, Object, String, JSON, Array, Boolean };
vm.createContext(ctx); return vm.runInContext(`(function(){\n${COMPUTE}\n})()`, ctx)[0].json.decision; };
const soleil = { soc_percent: '96', battery_current_a: '2', pv_power_w: '4646', pv_power_10m_avg_w: '4600', house_ac_power_w: '900',
sdb_temperature_c: '24', sdb_humidity_pct: '50', sdb_humidity_age_min: '3',
mppt_operation_modes: 'voltage_current_limited,voltage_current_limited,mppt_active,mppt_active,mppt_active,mppt_active,mppt_active',
sdb_master_power: 'off', deshumide_switch: 'off', radiator_switch: 'off', master_power_latch: 'off', deshumide_latch: 'off', radiator_latch: 'off',
deshumide_last_on_at: '2026-10-08 10:00:00', deshumide_last_off_at: '2026-10-08 10:30:00',
master_last_on_at: '2026-10-08 10:00:00', master_last_off_at: '2026-10-08 10:30:00',
evcs_vehicle_connected: 'off', evcs_ac_power_w: '0', evcs_surplus_state: 'vehicle_not_connected' };
d = decAt(soleil);
ok('surplus-0810-les-deux-demarrent', d.deshumide_action === 'turn_on' && d.radiator_action === 'turn_on' && d.master_action === 'turn_on', JSON.stringify(d));
d = decAt({ ...soleil, sdb_temperature_c: '28.2' });
ok('surplus-28c-seche-serviette-non', d.deshumide_action === 'turn_on' && d.radiator_action === 'none', JSON.stringify(d));
d = decAt({ ...soleil, sdb_temperature_c: 'unavailable', sdb_humidity_pct: 'unavailable' });
ok('surplus-temperature-inconnue-seche-serviette-non', d.radiator_action === 'none' && d.deshumide_action === 'turn_on', JSON.stringify(d));
d = decAt({ ...soleil, evcs_vehicle_connected: 'on', evcs_surplus_state: 'idle_wait_conditions' });
ok('surplus-voiture-branchee-passe-dabord', d.deshumide_action === 'none' && d.radiator_action === 'none', JSON.stringify(d));
d = decAt({ ...soleil, grid_state: 'on' });
ok('surplus-edf-ferme-non', d.radiator_action === 'none', JSON.stringify(d));
d = decAt({ ...soleil, mppt_operation_modes: 'mppt_active,mppt_active,mppt_active,mppt_active,mppt_active,mppt_active,mppt_active' });
ok('surplus-aucun-chargeur-bride-non', d.radiator_action === 'none' && d.deshumide_action === 'none', JSON.stringify(d));
const enMarche = { ...soleil, radiator_switch: 'on', radiator_latch: 'on', deshumide_switch: 'on', deshumide_latch: 'on', sdb_master_power: 'on', master_power_latch: 'on',
radiator_last_on_at: '2026-10-08 15:00:00', deshumide_last_on_at: '2026-10-08 15:00:00', master_last_on_at: '2026-10-08 15:00:00',
last_signature: '2026-10-08|deshumide_and_radiator_on|m=1|d=1|r=1|sp=1',
mppt_operation_modes: 'mppt_active,mppt_active,mppt_active,mppt_active,mppt_active,mppt_active,mppt_active' };
d = decAt({ ...enMarche, battery_current_a: '1' });
ok('surplus-maintien-batterie-ne-se-decharge-pas', d.radiator_action === 'none' && d.deshumide_action === 'none', JSON.stringify(d));
d = decAt({ ...enMarche, battery_current_a: '-12' });
ok('surplus-fin-batterie-se-decharge-tout-coupe', d.radiator_action === 'turn_off' && d.deshumide_action === 'turn_off' && d.master_action === 'turn_off', JSON.stringify(d));
d = decAt({ ...enMarche, battery_current_a: '1', sdb_temperature_c: '28.5' });
ok('surplus-28c-arrete-le-seche-serviette', d.radiator_action === 'turn_off' && d.deshumide_action === 'none', JSON.stringify(d));
const out = run(COMPUTE, { data: JSON.stringify(base) })[0].json;
const acts = run(BUILD, out).map((x) => x.json.action);
ok('build-coupe-enfant-puis-master', acts.indexOf('deshumide') >= 0 && acts.indexOf('deshumide') < acts.indexOf('master_power'), acts.join(','));