Nowadays, it is becoming increasingly common to deploy sensors in public buildings or homes with the aim of obtaining data from the environment and taking decisions that help to save energy. Many of the current state-of-the-art systems make decisions considering solely the environmental factors that cause the consumption of energy. These systems are successful at optimizing energy consumption; however, they do not adapt to the preferences of users and their comfort. Any system that is to be used by end-users should consider factors that affect their wellbeing. Thus, this article proposes an energy-saving system, which apart from considering the environmental conditions also adapts to the preferences of inhabitants. The architecture is based on a Multi-Agent System (MAS), its agents use Agreement Technologies (AT) to perform a negotiation process between the comfort preferences of the users and the degree of optimization that the system can achieve according to these preferences. A case study was conducted in an office building, showing that the proposed system achieved average energy savings of 17.15%.