## 3 Methods
It also manages the use of the energy storage system, taking energy from it, or recharging it (prioritizingrecharging over returning energy to the grid). Finally, the planner sets the HVAC system operating guidelines to make efficient use of it, giving directives for the indoor temperature that it should try to reach in the rooms to supplement the energy storage capacity of the house as a whole considered as a TES, optimizing the use of batteries. In order to minimize the cost of electric energy, once the need for electric energy to meet the demand at a given time has been obtained, priority will be given to the use of self-consumption energy that has no cost. The remaining energy will be distributed between the energy supplied by the grid and the energy supplied by the storage system, prioritizing the use of storage when energy prices are high, and grid consumption when prices are low and then recharging the batteries. Additionally, the house is considered as a TES when it takes advantage of the thermal and insulation characteristics of its structure and envelopes. Heat can be stored in the structure and materials of the house and released, when necessary, by acting on the interior temperature to be reached in the rooms. For this purpose, the materials of the envelope are not modified, but with the existing ones, the planning system proposes slight variations of the target temperature inside the rooms, always maintaining comfortable indoor temperatures that cause energy storage based on the abovementioned TES principles. This approach leverages the thermal inertia of the building to store or release heat strategically, reducing energy demand during peak periods and enhancing overall efficiency. By allowing controlled deviations from the setpoint temperature, the system can shift energy usage to times when it is more cost-effective or environmentally friendly, contributing to a sustainable and optimized climate control strategy. This approach improves the efficiency of the system, reducing the heating or cooling energy consumption and, consequently, reducing the energy cost. In this way, the planner works by analyzing data on energy demand and indoor temperatures, outdoor weather conditions, energy prices, and occupant schedules to anticipate heating and cooling needs. Based on these data, the optimizer proactively adjusts heating and cooling systems, storing thermal energy when renewable energy is abundant, and/or energy prices are low. During peaks in energy demand or when energy costs are high, the system reduces active heating or cooling by drawing on thermal energy stored in the home's structure. This approach not only improves energy efficiency and reduces  
Figure 1: General overview of the system. greenhouse gas emissions but also offers flexibility to the grid, reducing stress during peak hours and allowing for the greater integration of renewable energy sources. By means of continuous optimization, the home can be made to achieve energy savings, improve comfort levels, and contribute to broader sustainability goals. At the planning level, the use of a seven-day forecast horizon offers a significant advantage over a one-day horizon by providing the system with a broader perspective on future energy demand, costs, and generation trends. With this extended horizon, the planner can better anticipate fluctuations in energy prices, PV generation, and thermal energy demand, allowing him to make more strategic decisions about when to store energy in the TES and when to consume it. A shorter horizon lacks the ability to forecast and plan for longer-term trends, leading to less efficient energy management and higher cumulative costs. While a one-day horizon can respond reactively to immediate conditions, it misses opportunities to optimize for the longer term, underscoring why a seven-day model achieves better results in both cost savings and operational efficiency.