We evaluate the effect of a time-of-use pricing program introduced in Spain on residential electricity consumption. Using a Difference-in-Difference approach, we find that households responded by reducing consumption during peak hours. We then use machine learning for variable selection and show that it is able to capture pre-trends unrelated to the policy, improving the credibility of our estimates. We find that the program could have reduced consumption by up to 9% during peak periods, with significant spillovers to weekends. Using a more conservative estimator, we find that it reduced consumption by at least 1%–2% during peak periods. We find evidence of habit formation during periods of uniform pricing, accompanied by an adaptation process that ends with a permanent change in consumption behavior. The results suggest that a predetermined pricing program can enhance consumer awareness and increase household price elasticity, thus making it an effective policy tool to reduce peak electricity demand and improve market efficiency.