The paper is devoted to the problem of power consumption control in a medium-sized office building. The controlled devices are air conditioners. It is necessary to minimize the power consumption during peak periods and maintain a given temperature range. Some devices can be turned off during periods of high electricity demand to reduce overall building consumption. This assumes a reward for reducing the power load on the grid during peak periods. The objective function is to minimize the total electricity cost, taking into account the reward for reduced consumption. A three stage approach is proposed. Machine learning-based prediction of the consumption of an office building one month ahead is presented. Then a baseline schedule of air conditioner is constructed using a solver, taking into account the constraints and the objective function. During peak demand hours, the operation of the devices is determined by an online algorithm. Computational experiments on real data for month-ahead prediction and on test data for the optimization problem and the online algorithm are performed.