The combination of Artificial Intelligence and IoT technologies, the so-called AIoT, is expected to contribute to the sustainability of public and private buildings, particularly in terms of energy management, indoor comfort, as well as in safety and security for the occupants. However, IoT systems deployed on modern buildings may generate big amounts of data that cannot be efficiently analyzed and stored in the Cloud. Fog computing has proven to be a suitable paradigm for distributing computing, storage control, and networking functions closer to the edge of the network along the Cloud-to-Things continuum, improving the efficiency of the IoT applications. Unfortunately, it can be complex to integrate all components to create interoperable AIoT applications. For this reason, it is necessary to introduce interoperable architectures, based on standard and universal frameworks, to distribute consistently the resources and the services of AIoT applications for smart buildings. Thus, the rationale for this study stems from the pressing need to introduce complex computing algorithms aimed at improving indoor comfort, safety, and environmental conditions while optimizing energy consumption in public and private buildings. This article proposes an open multi-layer architecture aimed at smart buildings based on a standard framework, the OpenFog Reference Architecture (IEEE 1934–2018 standard). The proposed architecture was validated experimentally at the Faculty of Engineering of Vitoria-Gasteiz to improve indoor environmental quality using Fuzzy logic. Experimental results proved the viability and scalability of the proposed architecture.