FYI, I’ve developed 2026 version of such migration (which will also migrate the ‘cost’ data, as well as long and short term stats)
I’ve left my guide here: [Guide] Migrate / copy energy statistics & history to new entity - keep full history in Energy Dashboard (2026)