1 """Support for Wireless Sensor Tags."""
5 from wirelesstagpy.sensortag
import SensorTag
10 from .const
import DOMAIN
12 _LOGGER = logging.getLogger(__name__)
16 hass: HomeAssistant, tag: SensorTag, domain: str, key: str
18 """Migrate old unique id to new one with use of tag's uuid."""
19 registry = er.async_get(hass)
20 new_unique_id = f
"{tag.uuid}_{key}"
22 if registry.async_get_entity_id(domain, DOMAIN, new_unique_id):
25 old_unique_id = f
"{tag.tag_id}_{key}"
26 if entity_id := registry.async_get_entity_id(domain, DOMAIN, old_unique_id):
27 _LOGGER.debug(
"Updating unique id for %s %s", key, entity_id)
28 registry.async_update_entity(entity_id, new_unique_id=new_unique_id)
None async_migrate_unique_id(HomeAssistant hass, SensorTag tag, str domain, str key)