This article proposes a cutting-edge smart building design that contributes to sustainable development objectives by fostering clean energy, facilitating sustainable cities and communities, and promoting responsible consumption and production. The main goal is to create a clever rule-based framework that will boost the penetration of renewable energy in local grids, reduce the size of the components and, consequently, investment costs, and promote the shift towards a more environmentally friendly future. The system is driven by photovoltaic thermal panels, a novel biomass heater scheme, and a scaled-down heat pump to supply the entire energy demands of multi-family houses. The grey wolf optimizer and a cascade forward neural network model achieve the most optimal condition. According to the results, the suggested smart model outperforms the conventional Swedish system, with an energy cost of 121.2 euro/MWh and a low emission index of 11.2 kg/MWh. The results show that knowing how biomass price changes affect the heat pump's operational mode is crucial to ensuring the system's economic viability. In comparison to the design condition, the optimized model increased efficiency by 3.8% while decreasing overall cost (2.1 euro/h), emission index (4.4 kg/MWh), and energy costs (29.9 $/MWh). The results further demonstrate that the heat pump meets the vast majority of the year's heating needs, but as electricity prices rise in December, the biomass heater becomes the principal energy provider. May is the month with the lowest average monthly cost, while December and July stand out as the most expensive months of the year due to a dramatic increase in demand. Eventually, the results show that the system runs without external energy sources through the designed optimal control framework and generates excess electricity for around half the year.