Sensor id doesn't match the unique id?

Someone just submitted changes to allow localization of the various sensors in the bambulab printer integration I work on. It seemed to be working fine until I noticed that the dynamically added sensor for the AMS units was now broken.

From playing around it seems the entity ID is generated by sluggifying the device name and sensor name? And because localization removed the name and replaced it with a translation key, the entity ID now becomes just the device name and _ to make it a unique entity id which is no longer descriptive of what the sensor is.

Additionally, because there can be multiple AMS units, it’s no longer unique except in the sense that HA will use a different _ value. I had been attempting to set a unique ID and while that does work for identifying the sensor uniquely (if I change it I end up with an dead original sensor and a second working sensor), I hadn’t noticed that the entity id didn’t match (it was similar enough that I missed it didn’t have the AMS serial number in it).

I’m now trying to work out how to solve this while still supporting localization of the entity names - it’s critical to have the entity name in the entity ID otherwise they’ll be practically unusable for automations as no one will know what foo_ is.

Example debug output.
The ‘ADDING AMS’ line lists the unique ID I’m assigning.
‘p1p_01s00a292501557_ams_1’ is the device name I assigned to the AMS and that’s all that’s being used for the entity ids + the appended unique ID.

2023-09-03 15:38:50.162 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.bambu_lab
2023-09-03 15:38:50.163 DEBUG (MainThread) [custom_components.bambu_lab] ADDING AMS SENSOR: p1p_01s00a292501557_ams_00600a290903483_humidity_index
2023-09-03 15:38:50.163 DEBUG (MainThread) [custom_components.bambu_lab] ADDING AMS SENSOR: p1p_01s00a292501557_ams_00600a290903483_tray_1
2023-09-03 15:38:50.163 DEBUG (MainThread) [custom_components.bambu_lab] ADDING AMS SENSOR: p1p_01s00a292501557_ams_00600a290903483_tray_2
2023-09-03 15:38:50.163 DEBUG (MainThread) [custom_components.bambu_lab] ADDING AMS SENSOR: p1p_01s00a292501557_ams_00600a290903483_tray_3
2023-09-03 15:38:50.163 DEBUG (MainThread) [custom_components.bambu_lab] ADDING AMS SENSOR: p1p_01s00a292501557_ams_00600a290903483_tray_4
2023-09-03 15:38:50.164 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.bambu_lab entity: sensor.p1p_01s00a292501557_ams_1
2023-09-03 15:38:50.165 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.bambu_lab entity: sensor.p1p_01s00a292501557_ams_1_2
2023-09-03 15:38:50.165 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.bambu_lab entity: sensor.p1p_01s00a292501557_ams_1_3
2023-09-03 15:38:50.165 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.bambu_lab entity: sensor.p1p_01s00a292501557_ams_1_4
2023-09-03 15:38:50.165 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.bambu_lab entity: sensor.p1p_01s00a292501557_ams_1_5
2023-09-03 15:38:50.167 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.bambu_lab entity: sensor.p1p_01s00a292501557_17

Updated from 2023.3.6 to 2023.8.4 and all the issues seem to have evaporated - I get correct entity IDs now and working display names again.