Nowadays, in contemporary building and energy management systems (BEMSs), the predominant approach involves rule-based methodologies, typically employing supervised or unsupervised learning, to deliver energy-saving recommendations to building occupants. However, these BEMSs often suffer from a critical limitation—they are primarily trained on building energy data alone, disregarding crucial elements such as occupant comfort and preferences. This inherent lack of adaptability to occupants significantly hampers the effectiveness of energy-saving solutions. Moreover, the prevalent cloud-based nature of these systems introduces elevated cybersecurity risks and substantial data transmission overheads. In response to these challenges, this article introduces a cutting-edge edge computing architecture grounded in virtual organizations, federated learning, and deep reinforcement learning algorithms, tailored to optimize energy consumption within buildings/homes and facilitate demand response. By integrating energy efficiency measures within virtual organizations, which dynamically learn from real-time inhabitant data while prioritizing comfort, our approach effectively optimizes inhabitant consumption patterns, ushering in a new era of energy efficiency in the built environment.