With the recent advances in smart grid technologies as well as the increasing dissemination of smart meters, the electricity usage of every moment can be detected in modern smart building environments. Thus, the utility company adopts different price of electricity at each time slot considering the peak time. This paper presents a new power consumption scheduling algorithm for smart buildings that adopts smart meters and real-time pricing of electricity. The proposed algorithm dynamically changes the power mode of each electric device according to the change of electricity prices. Specifically, we formulate the electricity usage scheduling problem as a real-time task scheduling problem, and show that it is a complex search problem that has an exponential time complexity. The proposed scheme uses an efficient heuristic based on genetic algorithms to cut down the huge searching space and finds a reasonable schedule within a feasible time budget. Experimental results with various building conditions show that the proposed algorithm reduces the electricity charge of a smart building by 25.6% on average and up to 33.4%.