## 1 Introduction and Review of Existing Research
### SEMS Combined with Thermoeconomic Diagnosis  
The main objective of this work is to define a methodology that combines advanced energy management techniques of FDD and Machine Learning with Thermoeconomic analysis to optimise performance and detect anomalies in real time applied to building energy systems. This interdisciplinary approach provides a comprehensive framework for assessing energy performance and detecting anomalies, enabling more effective decision-making for sustainable development. Thermoeconomics integrates the principles of thermodynamics and economics to analyse energy systems, and allows evaluating the costs associated with the production, transformation, distribution, and consumption of energy, based on the irreversibilities of the process [7]. In the context of buildings, which are highly dynamic systems conditioned by the external climate and the changing profile of users, thermoeconomic analysis helps to identify and locate inefficiencies and cost overruns in order to optimise operational and control strategies, detect failures and/or select energy alternatives. Thus, when SEMS are combined with the principles of thermoeconomics, they provide a deeper insight into the whole energy chain, the overall system efficiency, and cost-effectiveness. Thus, by merging SEMS data and thermoeconomic diagnosis algorithms, the energy efficiency of components can be improved and operating costs can be reduced. As mentioned above, in the thermoeconomic analysis, costs are not only allocated to the energy consumed, but also to the processes involved in the transformation and supply of the entire energy chain, also considering changing operating modes and external conditions. In this way, the irreversibilities of each active process are identified, their local impact is assessed and weighted in the cost of the final product, thus helping to prioritise interventions and energy savings. The irreversibilities of each process are evaluated in terms of exergy destructions since, unlike energy, which is always conserved, exergy is destroyed as inefficiencies increase; or, in thermodynamic terms, as the capacity of the energy resource to generate useful work is reduced [8]. Thus, if the cost is linked to the flow exergy, it represents the real cost of energy waste, taking into account both the quantity of energy and its quality. Thermoeconomic diagnosis is the discipline dedicated to locating anomalies or equipment degradation in an energy system by comparing the current operating mode with a reference mode without anomalies. Diagnosis based on the productive structure of the system makes it possible to evaluate each anomaly in terms of cost overruns and to quantify its effect on the other components, which must adapt to the new anomalous operating state while maintaining unchanged production. The challenge arises when multiple components degrade at the same time, which makes it difficult to identify the specific causes and the impact of each anomaly on the other components and on the total cost overrun. The origins of thermoeconomic diagnosis date back to the beginning of the 21 st century with the structures Structural-Theory [9] of authors such as [PERSON], [PERSON] et al. [10], and also with the TADEUS problem [11] of [PERSON] et al. [12]. Later, in 2007, [PERSON] and [PERSON] [13] proposed a new approach based on the characteristic curves of the equipment, dynamically developed by [PERSON] et al. in [14] and improved in [15]. This approach is the one used for the methodology proposed in this work. This work proposes a methodology that automates the detection of anomalies in building thermal systems and assess their economic impact, facing the challenge of integrating ML models with thermoeconomic diagnosis, detection of anomalies, and the development of causal methods to understand the relationships between anomalies and cost overruns in the other components and in the system as a whole.