Change device config to update sensor names and ids

my esphome device has sensors that are not named correctly, so in ha the entities names and ids are also not correct. if i want to rename them in the esphome config and reflash that device with the correct config, what needs to be done via the integration or its entities to retain the data but get the new sensor names and ids? i dont want to just change the name of the sensors in ha. id like to have them generated correctly by ha and retain their data.

if i rename the entity ids to what i want, remove the device in ha, flash my esp device with the correct config with renamed sensors, add it back in ha, it will inherit the previous entity history.