Battery energy storage systems can be readily integrated with buildings to enhance renewable energy self-consumptions while leveraging time-variant electricity tariffs for possible operation cost reductions. The extensive variability in building operating conditions presents significant challenges in developing universally applicable methods for optimal controls. To ensure reliable and robust controls, this study integrates predictive control with efficient linear programming to effectively fine-tune battery controls for real-time operations. An adaptive time aggregation scheme has been proposed to streamline the optimization process by accounting for unique changes in energy balances and tariffs. Comprehensive data experiments, based on measurements from 95 unique building operation scenarios, have been conducted to quantify the control performance given different optimization formulations, varying types and levels of prediction uncertainties in building energy demands and PV generations. The results validate the value of the method proposed, leading to 11.75 %–34.63 % operation cost reductions on average, while reducing computation steps by 87.75 %–92.60 % compared with conventional linear programming approaches. The insights obtained are useful for developing flexible building control strategies with improved computation efficiency and robustness, while providing extensible optimization frameworks for buildings with various energy patterns and storage systems.