This research aims to investigate a hybrid renewable energy system (HRES) and its integration in buildings to create zero-energy buildings. Each location has its specific climate condition that requires a related HRES configuration that can address energy demand in that particular location. Hence, the applicability of HRES in four different case studies has been considered, Tehran, Yazd, Tabriz, and Bandar Abbas. The energy system has been simulated in TRNSYS, which is a powerful transient-simulation software. Although energy system simulation in TRNSYS brings users remarkable benefits, it lacks an optimization setup. To address the mentioned issue, a neural network-genetic algorithm optimization has been proposed. Simulated HRES comprised of PV panels, vertical axis wind turbines, and hydrogen storage. Results of the simulation indicate between 35% and 49% of the required electricity of the buildings in each city can be generated via PV panels and wind turbines, and between 70% and 88% can be encompassed with the combination of renewable resources and a hydrogen storage system depend on the climate. Results indicate that adding a hydrogen storage system to the main system increases the reliability of the HRES and reduces dependency on grid electricity. Afterward, by employing a neural network–genetic algorithm optimization method, an optimized number of PV panels and wind turbines for the building located in Tehran as a final case is computed. The optimized configuration has the lowest installation cost, CO2 production and loss of power supply probability (LPSP). Optimization procedure is implemented in MATLAB. Appraised data indicated that by installing 1 wind turbine and 291 PV panels, total CO2 production, LPSP, and cost are 53.48 ton/year, 0.4057, and 1.422 EUR/hr, respectively.