The present work aims to improve the comfort of architectural interior design and reduce indoor energy consumption. The Weight K-Nearest Neighborhood (WKNN) algorithm and Nondominated Sorting Genetic algorithm are proposed to locate and analyze the spatial location of indoor personnel and optimize the indoor energy consumption in combination with residential behavior. Firstly, the indoor human behavior data and energy-saving problems are analyzed based on residential behavior theory and architectural physics. The indoor positioning algorithm is proposed to identify the personnel activities to realize the optimization of indoor energy distribution. Secondly, mean filtering and cluster analysis are adopted to optimize sampling points’ data and fingerprint database to eliminate data noise. Besides, the WKNN algorithm is used for Wireless Fidelity (Wi-Fi) indoor location fingerprint location. Then, aiming at the multiobjective optimization problem of building indoor energy consumption, the Nondominated Sorting Genetic algorithm obtains the optimal solution of the model. Combined with the indoor location information of personnel, the indoor heating and cooling system is monitored and distributed to reduce the energy consumption in the building while ensuring the living comfort of personnel. The test and simulation results demonstrate that the mean filtering algorithm can solve the room’s fluctuation problem of Wi-Fi signals. The cluster analysis algorithm can eliminate the data noise of the fingerprint database and improve the positioning accuracy of the positioning algorithm. Moreover, the location result is independent of the number of nodes; the number of sampling points does not affect the location result. The positioning accuracy of the WKNN algorithm is 2 m, and the positioning error rate within 2 m is about 60%. Compared with other algorithms, the WKNN algorithm has better positioning accuracy and positioning stability. Therefore, the location algorithm designed here can be applied to indoor location optimization. This study provides a reference for optimizing buildings’ indoor positioning and energy consumption.