This lecture presents a project focused on optimizing the power profile of a heat pump in a grid-tied photovoltaic system using the thermal inertia of a hot water tank. The instructor discusses the development of heuristic and instant control algorithms, the optimization of the system, and the comparison of different approaches to enhance efficiency and flexibility. The final algorithm, based on indicators, proves to be the most efficient, cost-effective, and parameter-less solution, incorporating electric heating for improved peak response and self-consumption. The lecture emphasizes the robustness of the algorithm in forecasting weather and consumption data, ensuring a low extra cost due to unpredictable events and achieving efficient storage of excess PV production as heat.