Regulation of indoor temperature based on neurophysiological and psychological signals is one of the most promising technologies for intelligent buildings. In this study, we developed a system for closed‐loop control of indoor temperature based on brain–computer interface (BCI) technology for the first time. Electroencephalogram (EEG) signals were collected from subjects for two room temperature categories (cool comfortable and hot uncomfortable) and used to build a thermal‐sensation discrimination model (TSDM) with an ensemble learning method. Then, an online BCI system was developed based on the TSDM. In the online room temperature control experiment, when the TSDM detected that the subjects felt hot and uncomfortable, BCI would automatically turn on the air conditioner, and when the TSDM detected that the subjects felt cool and comfortable, BCI would automatically turn off the air conditioner. The results of online experiments in a hot environment showed that a BCI could significantly improve the thermal comfort of subjects (the subjective thermal comfort score decreased from 2.45 (hot uncomfortable) to 0.55 (cool comfortable), p < 0.001). A parallel experiment further showed that if the subjects wore thicker clothes during the experiment, the BCI would turn on the air conditioner for a longer time to ensure the thermal comfort of the subjects. This has further confirmed the effectiveness of TSDM model in evaluating thermal sensation under the dynamic change of room temperature and showed the model's good robustness. This study proposed a new paradigm of human–building interaction, which is expected to play a promising role in the development of human‐centered intelligent buildings. [ABSTRACT FROM AUTHOR]