## 4 Conclusions  
The results of this study show that the methodology defined in this work for the smart management of a microgrid based on the efficiency of the available ESSs allows optimisation of the operation of the microgrid by reducing energy consumption of the distribution grid during the highest tariff periods and eliminating power peaks (of up to 2 h). This methodology was carried out using an energy management system developed by CEDER based on open-source software (and therefore free) and easy to implement (Home Assistant and NodeRed).  
The procedure for reducing energy consumption of the distribution network during the highest tariff periods saves up to 288.38 kWh in a day (245.31 kWh P1 and 43.07 kWh P2). Taking into account the capacity of the storage systems and the time needed to recharge them, as well as the fact that consumption similar to that of the target day in this case study occurs almost every working day in winter and autumn, we can estimate that this methodology can be applied about 80 days per year, which means a saving of 23,0/07.4 kWh (19,624.8 kWh P1 and 3445.6 kWh P2). The price of energy (year 2023) during the highest tariff periods is 0.331692 \(\upmu\)K/kWh in P1 and 0.319483 \(\upmu\)K/kWh in P2, which means an estimated annual saving of 7610.2 \(\upmu\)(6509.4 \(\upmu\) in P1 and 1100.8 in \(\upmu\) P2).  
The peak shaving procedure saves 51.6 kWh of consumption each day it is carried out. Taking into account that similar situations occur about 60 times a year, this allows for a saving of 3009 kWh in period P1, which is equivalent 855.8 \(\upmu\) per year. In this case, the annual saving is lower, but it avoids exceeding the contracted power limit by CEDER (135 kW peak power), which would entail high penalties in the electricity bill.  
Overall, the application of this methodology allows for annual savings of approximately 68500, optimising the operation of the energy storage systems and the management of the microgrid.  
Table 9 shows the savings achieved in terms of energy and money (according to current tariffs in Table 8) by applying this methodology to the CEDER-CIEMAT microgrid (reducing energy consumption plus peak shaving).  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Period of Time** & **Energy Savings** & **Money Savings** \\ \hline Day & 340 kWh & 110 \(\upmu\) \\ Week & 500 kWh & 165 \(\upmu\) \\ Month & 2170 kWh & 710 \(\upmu\) \\ Year & 26,080 kWh & 8500 \(\upmu\) \\ \hline \hline \end{tabular}
\end{table}
Table 9: Savings achieved in terms of energy and money at the CEDER microgrid (reducing energy consumption).  
Figure 12: CEDER microgrid consumption using ESS (12 January 2023).  
As future work, further tests should be carried out over a longer period of time to determine the real savings that could be achieved per year with this methodology. The estimated savings for the year 2024 is \(\xi\)1000, as efforts will be made to optimise the performance of this methodology. Methodologies based on factors other than the efficiency of the storage system, as in this case, but also considering other factors such as response time, storage capacity, etc., will also be carried out.  
Conceptualization, O.I.-M. and A.Z.-L.; methodology, O.I.-M.; investigation, O.I.-M. and A.H.-J.; software, O.I.-M. and P.P.-C.; validation, O.I.-M. and A.Z.-L.; writing--original draft, O.I.-M.; writing--review and editing, A.Z.-L., A.H.-J. and L.H.-C. All authors have read and agreed to the published version of the manuscript. This research received no external funding.  
Not applicable.  
The data presented in this study are available on request from the corresponding author. The data are not publicly available due to privacy.  
The authors declare no conflicts of interest.