NRG Energy Inc. agreed to buy Vivint Smart Home Inc. for $2.8 billion to accelerate the U.S. power producer’s strategy of diversifying from its core electricity-generation business by focusing on retail consumers.

Vivint, based in Provo, Utah, sells smart thermostats, locks, lights and other household devices. NRG said it will pay $12 a share in cash for Vivint, representing a premium of about 33 percent to the closing share price the day before.

The deal will increase NRG’s customer base to about 7.4 million across North America. The Houston-based company expanded in the retail sector with its purchase of Centrica Plc’s Direct Energy unit for $3.6 billion, a deal it completed in 2021. NRG is one of the largest U.S. independent power producers and operates a fleet of natural gas, coal and other generating plants totaling 18 gigawatts. It’s also one of the biggest retail electricity providers in Texas.

“Last year at our investor day, we presented our strategic roadmap to becoming the leading provider of essential services for homes and businesses, informed by consumer trends and underpinned by disciplined execution,” NRG CEO Mauricio Gutierrez said in a statement. “The acquisition of Vivint is a transformational step in achieving our vision.”

The Vivint transaction is expected to close in the first quarter of 2023 and is subject to customary closing conditions. The enterprise value of the deal is $5.2 billion, including $2.4 billion of debt.

NRG said it plans to complete its current $1 billion share-buyback program, of which $360 million remained at the end of November. For next year, it expects to use excess free cash flow to fund the Vivint takeover, cut debt related to the acquisition and maintain dividend growth.

Credit rating agency S&P Global Ratings put NRG on “CreditWatch” with negative implications, reflecting the potential for a downgrade of no more than one notch.

“We see the potential benefits of unlocking higher customer lifetime value,” S&P analysts wrote. “However, we also see execution risks amid a potentially recessionary environment.”

Goldman Sachs Group Inc. is NRG’s financial adviser on the deal and is providing financing. White & Case LLP is the company’s legal counsel. JPMorgan Chase & Co. is Vivint’s financial adviser and Simpson Thacher & Bartlett LLP is its legal counsel.