Energy storage cabinet algorithm