A method for controlling electrical connection of at least two battery packs (202, 203) of an energy storage system of a vehicle in parallel to a common load during operation of the vehicle, each one of the at least two battery packs (202, 203) being connectable to the load via at least one respective switching device (205, 206), the method comprising: - receiving measurement data relating to current operating conditions of the energy storage system, - based on at least the measurement data, estimating at least one battery state of each one of the at least two battery packs (202, 203), wherein said at least one battery state is at least one of an open circuit voltage and a state of charge, the at least one battery state comprising at least the state of charge, the method being characterized by: - based on at least the estimated state of charge and a measured temperature of the at least two battery packs (202, 203), predicting a magnitude of a circulation current expected to flow between the at least two battery packs (202, 203) upon electrical connection of said at least two battery packs (202, 203), wherein the magnitude of the circulation current is predicted using a dynamic state-space model of a parallel multi-battery system, which model takes as input a total energy storage system current, initial state of charge, state of health, and temperature values of each battery pack, and gives as output individual battery pack currents including transient and steady-state responses of each individual battery pack, - based on the magnitude of the predicted circulation current, controlling electrical connection of each battery pack (202, 203) to the load via the at least one respective switching device (205, 206), wherein the at least two battery packs (202, 203) are electrically connected only if the magnitude of the predicted circulation current is below a predefinable allowable circulation current magnitude. - receiving measurement data relating to current operating conditions of the energy storage system, - based on at least the measurement data, estimating at least one battery state of each one of the at least two battery packs (202, 203), wherein said at least one battery state is at least one of an open circuit voltage and a state of charge, the at least one battery state comprising at least the state of charge, the method being - based on at least the estimated state of charge and a measured temperature of the at least two battery packs (202, 203), predicting a magnitude of a circulation current expected to flow between the at least two battery packs (202, 203) upon electrical connection of said at least two battery packs (202, 203), wherein the magnitude of the circulation current is predicted using a dynamic state-space model of a parallel multi-battery system, which model takes as input a total energy storage system current, initial state of charge, state of health, and temperature values of each battery pack, and gives as output individual battery pack currents including transient and steady-state responses of each individual battery pack, - based on the magnitude of the predicted circulation current, controlling electrical connection of each battery pack (202, 203) to the load via the at least one respective switching device (205, 206),