The increasing demand for flexible resources in power systems, coupled with the evolution of smart buildings, underscores the significance of optimizing energy use and quantifying dispatchable potential in heating, ventilation, and air conditioning systems. This work develops an energy optimization framework for these systems, accounting for external factors like solar radiation, temperature, and humidity. The goal is to minimize the energy consumption of holistic systems and devise optimal control strategies for each subsystem. The framework includes a mechanistic model that accurately describes the performance of cooling towers, a three-damper control strategy for air-side economizers, and three operational modes for air handling units. Furthermore, the relationship between the fresh air ratio and the supply/return air duct pressure drop obtained through analysis simplifies the optimization problem and reduces the difficulty of solving it. Subsequently, the framework utilizes indoor temperature and humidity ranges to ascertain optimal control strategies for both maximal and minimal energy consumption in the system. Simulation results for a hypothetical building reveal that dispatchable potential of the system can account for up to 13.055% of maximal energy consumption.