The continuous migration of people towards cities has led to an increase in resource consumption among homes, primarily in terms of energy and water. This phenomenon calls for resource management solutions in an attempt to drive sustainable consumption patterns. Among these solutions lie Home Automation Systems (HAS) capable of monitoring and controlling different appliances so as to deliver services such as appliance control and security surveillance. As in most HAS architectures today, these appliances are uniquely identified and connected to the Internet, as in Internet of Things (IoT) networks. Though, despite their potential, such architectures generally fail to address four essential features altogether: easy adaptability, access to remote services, interoperability and software portability. In this work, we propose a reference HAS architecture which implements the previous features. Our approach is based on the synergy between the FIWARE IoT middleware and a multi-agent system (MAS), leading to an autonomous IoT (AIoT) system. To demonstrate the applicability of this architecture and to evaluate its potential to drive sustainable resource consumption, we have deployed a Home Energy Management System (HEMS) in accordance with the proposed architecture, and gathered results of various simulations of a home environment managed by the HEMS. Our results suggest that the HEMS can aid home-owners in decision making, raise awareness as of their resource consumption profiles, and provoke behavioral changes leading to more sustainable consumption patterns.