How is the unique ID generated?

I just went through two days of cleaning up a number of old, unused entities. (I was prompted with the repair notice that I had integrations with duplicate unique IDs.)

Are the unique IDs built using the MAC address? That would explain how this situation developed as I do a lot of experimenting and reuse of ESP devices. Until now I had never thought of deleting the entity when repurposing an ESP.