Posting here as this seems to affect some Forester and Imprezza models with Electronic Throttle Bodies or IACV that undergo a battery disconnect, and lose their idle calibration.
As per THIS POST
and ANOTHER POST
and THIS OTHER POST
and YET ANOTHER POST
to retrain the ECU idle parameters:
1) Turn off the lights, aircon, stereo or any system in the car that draws extra current on top of the engine.
2) Disconnect the battery for 30 mins.
3) Reconnect the battery.
4) Before you start the car for the first time, turn the key to the ON position but do NOT turn the engine over. Wait 10-15 seconds so the electronic throttle body or IACV has time to go to the factory programmed home position.
5) After waiting, start the car and let it idle without any load, lights, A/C etc.
6) Every 20 seconds or so the idle will be adjusted up and down as the ECU tries to adjust it towards a stoichiometric fuel / air mix.
7) Leave the engine running for a full 10 mins but DO NOT TOUCH THE ACCELERATOR during this time or turn on anything that will cause extra electrical current draw.
8) Turn off the engine, and leave the key in the OFF position for at least 20 sec.
9) As per step (4) turn the key back to the ON position for 10-15 sec without actually starting the engine.
10) Start the engine and leave to idle for a further 5 minutes without touching the accelerator and without turning on other systems in the car.
11) Turn off the engine again and wait at least 20 sec before restarting.
12) Take the car for a test drive as the ECU should now be fully retrained.
I know for a fact that this is necessary for the 2003 Forester XT because this process seems to have been the cause of all the teething problems with the LPG system because it was never retrained after the battery was disconnected during the conversion. I used an OBD2 adapter to measure the AFR beforehand - and the LPG AFR was waaay out in comparison to the petrol. After following the process above both sets of AFRs are now very close to a stoichiometric mix, and the car idles correctly without the revs bouncing up and down constantly.