Photovoltaic (PV) systems in smart buildings need to be equipped with energy storage components to increase their production efficiency. However, battery energy storage systems are no longer the most economical solution in the current technology. Contrastingly, thermal energy storage systems can increase photovoltaic self-consumption while reducing the configuration capacity of battery energy storage devices. Therefore, this paper proposes an optimal configuration model of energy storage system in smart building that is equipped with PV system, heat pump (HP), thermal and electrical energy storage systems. In order to optimize both the electric storage and heat storage system, Monte Carlo simulation and metaheuristic algorithm are adopted to minimize the annual comprehensive operation cost of smart building. This paper mainly adjusts the water flow in the energy storage tank to meet the thermal energy demand, and controls the charge and discharge behavior of the heat pump operation and the battery energy storage system based on the demand response. Simulation is presented to validate the effectiveness of the proposed model.