Replacing device but keeping entity_id/long term statistics in HA

Dropping in my solution as this thread was coming up when I was looking for one