According to the recent research significant amount of building energy consumption can be saved through optimized operation and management and it is not necessary to change the building structure and the hardware configuration of the energy supply system. Therefore, there is a huge potential for building energy savings through efficient operation. In this paper a smart building (microgrid) is assumed to be supplied by different power sources such as CHP, PV, battery, and main grid. The microgrid is connected to the main grid and it can buy/sell power from/to the grid. Furthermore, day-ahead electricity pricing is assumed for the grid power. The goal is to find optimized solution for scheduling problem of the building energy sources. Furthermore the effect of the battery on operation cost is investigated.