Building managers need effective tools to improve occupants' experiences considering constraints of energy efficiency. Current building management systems are limited to coordinating device services in simple and prefixed situations. Think of an office with lights offering services, such as turn on a light, which are invoked by the system to automatically control the lights. In spite of the evident potential for energy saving, the office occupants often end up in the dark, they have too much light when working with computers, or unnecessary lights are turned on. The office is thus not aware of the occupants' presence nor anticipates their activities. Our proposal is to coordinate services while anticipating occupant activities with sufficient accuracy. Finding and composing services that will support occupant activities is however a complex problem. The high number of services, the continuous transformation of buildings, and the various building standards imply a search through a vast number of possible contextual situations every time occupants perform activities. Our solution to this building coordination problem is based on Hierarchical Task Network (HTN) planning in combination with activity recognition. While HTN planning provides powerful means for composing services automatically, activity recognition is needed to identify occupant activities as soon as they occur. The output of this combination is a sequence of services that needs to be executed under the uncertainty of building environments. Our solution supports continuous context changes and service failures by using an advanced orchestration strategy. We design, implement and deploy a system in two cases, namely offices and a restaurant, in our own office building at the University of Groningen. We show energy savings in the order of 80% when compared to manual control in both cases, and 60% when compared to using only movement sensors. Moreover, we show that one can save a figure of 600 annually for the electricity costs of the restaurant. We use a survey to evaluate the experience of restaurant occupants. The majority of them are satisfied with the solution and find it useful. Finally, the technical evaluation provides insights into the efficiency of our system.