Energy management systems can help to minimize energy costs and reduce CO2 emissions by making efficient use of renewable and often fluctuating energy (wind, solar power). At the same time, decentralized power generation could increase the efficient use of fossil fuels such as natural gas. The decentralization and volatility of power supply make it necessary to integrate the endpoints of power usage more tightly with the operation of distribution grids in order to keep up their stability. Endpoints must be able to react to requests from the grid and adapt their power consumption or generation. Automated systems for interacting with the grid are necessary for adhering to real-time requirements and to handle the information load. This paper outlines the architecture for such an energy management system and describes an initial study that explores the potential of an office environment as a contributor to the smart grid.