Flexibility has gained notoriety with the advancement of topics such as microgrids, renewable generation, distributed energy resources, and energy storage. Proposals like local flexibility markets (LFMs) demonstrate the growing interest in existing demand-side flexibility and the development of methods to access this resource. This work presents a matheuristic to managing battery energy storage systems (BESS) by controlling flexibility reserves of power and energy independently and parameterized through virtual control parameters. The system executes the processes of reserving flexibility, unlocking it, and utilizing it during day-ahead planning and in real-time operation to meet flexibility actions for increasing and reducing demand within LFMs. The management system's behavior is presented in an application case that demonstrates the system’'s ability to manage different flexibility levels. We present the impact of flexibility management on operating profitability, observing a lower loss of profitability in the allocation of power (kW) capacity and a higher loss of profitability in the energy (kWh) flexibility reserve. The method's effectiveness is presented through a set of proposed flexibility metrics, which allow for representing the available flexibility based on power, energy, and time duration of the parameterized demand response action.