Keeping historic data from a sensor after device is repurposed (energy dashboard)

I am using a Shelly EM to monitor my energy consumption. Say I want to start using a different device and repurpose the shelly EM, how can I keep the historical data in my energy dashboard?

The statistics are bound to the entity_id.
As long as your new device has the same entity_id the old statistics will carry over.

Also you could rename the entlty_id the statistics are associated with by editing the table “statistics_meta” in the database.