In this paper, the design of an event-driven usercentric middleware for monitoring and managing energy consumption in public buildings and spaces is presented. The main purpose is to increase energy efficiency in buildings and public spaces, thus reducing consumption. To achieve this, the proposed service-oriented middleware has been designed to be event based, also exploiting the user behavior patterns of people who live and work in buildings. Furthermore, it allows an easy integration of heterogeneous technologies in order to enable a hardwareindependent interoperability between them. Moreover, a heating ventilation and air conditioning (HVAC) control strategy has been developed, and the whole infrastructure has been deployed in a real-world case study consisting of a historical building. Finally, the results will be presented and discussed.