Recently, the policymakers, economy, and societies' primary and ambitious objective has been to make the world cleaner and carbon neutral. One critical problem in reaching these goals is building energy management, including using local energy sources.This paper provides a methodology based on a total sustainable performance index estimated as the "total life cycle costs," including externalities, that apply to a possible energy source, energy generation, energy storage, energy use, and management. The methodology is applicable to comparative analysis of the locally available energy sources, optimization of the energy generation mix, and real-time energy management of the building, especially for individuals and groups of small and private houses. The significant results of this research conducted in this paper show that (i) the effective, optimized energy mix includes 2 or 3 types of locally available energy sources, (ii) the real-time energy support of the building is effective in case of dealing with all the energy sources, energy generation, and energy use methods, (iii) the energy management system should be centralized and supported by a large number of sensors, (iv) developing local micro grid including 20-100 houses increasing the energy supply efficiency for 20-45%.