else if (conditions.shouldStepDownVebusVoltage) { setOn({ stateName: 'charging_step_down_dc_voltage', decisionName: 'step_down_fast', currentA: Math.max( params.currentMinA, Math.min( derived.currentReferenceA - Math.max(params.currentStepDownA + 1, 3), derived.physicalCapA ) ), reasonText: 'Baisse rapide: tension DC basse', dynamic: true, mustStopFlag: false, }); } else if ( activeSourceMode === 'battery_assist_night' && conditions.batteryAssistNightShouldStepDown ) { setOn({ stateName: 'charging_step_down_battery_assist_night', decisionName: 'step_down', currentA: Math.max( params.currentMinA, Math.min( derived.currentReferenceA - params.currentStepDownA, derived.physicalCapA ) ), reasonText: nightEvcs?.batteryRecoveryUrgent ? 'Réduction: approche départ, préparation takeover réseau' : 'Réduction: assistance batterie nuit devient trop coûteuse', dynamic: true, mustStopFlag: false, }); } else if ( (activeSourceMode === 'grid_hc_allowed' || activeSourceMode === 'grid_forced') && conditions.gridShouldStepDownBattery ) { setOn({ stateName: activeSourceMode === 'grid_forced' ? 'charging_step_down_grid_forced_guard' : 'charging_step_down_grid_guard', decisionName: 'step_down', currentA: Math.max( params.currentMinA, Math.min( derived.currentReferenceA - params.currentStepDownA, derived.physicalCapA ) ), reasonText: activeSourceMode === 'grid_forced' ? 'Réduction réseau forcé: la batterie commence à participer' : 'Réduction réseau: la batterie commence à participer', dynamic: true, mustStopFlag: false, }); } else if ( (activeSourceMode === 'solar_only' || activeSourceMode === 'solar_potential') && conditions.solarShouldStepDownCloudDebt ) { setOn({ stateName: 'charging_step_down_cloud_debt', decisionName: 'step_down', currentA: Math.max( params.currentMinA, Math.min( derived.currentReferenceA - Math.max(params.currentStepDownA, 2), derived.physicalCapA ) ), reasonText: 'Réduction: dette nuage trop élevée', dynamic: true, mustStopFlag: false, }); } else if ( (activeSourceMode === 'solar_only' || activeSourceMode === 'solar_potential') && conditions.solarShouldStepDownBattery ) { setOn({ stateName: 'charging_step_down_battery', decisionName: 'step_down', currentA: Math.max( params.currentMinA, Math.min( derived.currentReferenceA - params.currentStepDownA, derived.physicalCapA ) ), reasonText: 'Réduction: batterie trop sollicitée', dynamic: true, mustStopFlag: false, }); } else if ( (activeSourceMode === 'grid_hc_allowed' || activeSourceMode === 'grid_forced') && conditions.gridShouldStepUp ) { setOn({ stateName: activeSourceMode === 'grid_forced' ? ( nightEvcs?.batteryRecoveryUrgent ? 'night_departure_deadline_grid_forced' : 'charging_step_up_grid_forced' ) : 'charging_step_up_grid_hc', decisionName: 'step_up', currentA: clamp( derived.currentReferenceA + params.currentStepUpA, params.currentMinA, derived.physicalCapA ), reasonText: activeSourceMode === 'grid_forced' ? ( nightEvcs?.batteryRecoveryUrgent ? 'Hausse prudente: priorité départ, réseau forcé' : 'Hausse prudente du courant en charge réseau forcée' ) : 'Hausse prudente du courant en HC réseau', dynamic: true, mustStopFlag: false, }); } else if ( activeSourceMode === 'battery_assist_night' && conditions.batteryAssistNightShouldStepUp ) { setOn({ stateName: 'charging_step_up_battery_assist_night', decisionName: 'step_up', currentA: clamp( derived.currentReferenceA + params.currentStepUpA, params.currentMinA, derived.physicalCapA ), reasonText: 'Hausse prudente du courant en assistance batterie nuit', dynamic: true, mustStopFlag: false, }); } else if ( (activeSourceMode === 'solar_only' || activeSourceMode === 'solar_potential') && conditions.solarShouldStepUp ) { setOn({ stateName: conditions.probeSuccessNow ? 'probe_success_step_up' : (modes.batteryPriorityMode ? 'charging_step_up_battery' : 'charging_step_up_forecast'), decisionName: 'step_up', currentA: clamp( derived.currentReferenceA + params.currentStepUpA, params.currentMinA, derived.physicalCapA ), reasonText: 'Hausse prudente du courant', dynamic: true, mustStopFlag: false, }); } else { setOn({ stateName: conditions.probeSuccessNow ? 'probe_success_hold' : activeSourceMode === 'battery_assist_night' ? 'charging_hold_battery_assist_night' : (activeSourceMode === 'grid_hc_allowed' || activeSourceMode === 'grid_forced') ? 'charging_hold_grid' : cloud.cloudDebtActive ? 'charging_hold_cloud_tolerance' : 'charging_hold', decisionName: 'hold', currentA: Math.min(derived.currentReferenceA, derived.physicalCapA), reasonText: activeSourceMode === 'battery_assist_night' ? 'Maintien du courant en assistance batterie nuit' : 'Maintien du courant', dynamic: true, mustStopFlag: false, }); } } }