@callback
def async_generate_entity_id(entity_id_format: str, name: Optional[str], current_ids: Optional[Iterable[str]]=None, hass: Optional[HomeAssistant]=None) -> str:
    'Generate a unique entity ID based on given entity IDs or used IDs.'
    name = (name or DEVICE_DEFAULT_NAME).lower()
    preferred_string = entity_id_format.format(slugify(name))
    if (current_ids is not None):
        return ensure_unique_string(preferred_string, current_ids)
    if (hass is None):
        raise ValueError('Missing required parameter current_ids or hass')
    test_string = preferred_string
    tries = 1
    while (not hass.states.async_available(test_string)):
        tries += 1
        test_string = f'{preferred_string}_{tries}'
    return test_string
Generate a unique entity ID based on given entity IDs or used IDs.
@callback
def async_generate_entity_id(entity_id_format: str, name: Optional[str], current_ids: Optional[Iterable[str]]=None, hass: Optional[HomeAssistant]=None) -> str:
    
    name = (name or DEVICE_DEFAULT_NAME).lower()
    preferred_string = entity_id_format.format(slugify(name))
    if (current_ids is not None):
        return ensure_unique_string(preferred_string, current_ids)
    if (hass is None):
        raise ValueError('Missing required parameter current_ids or hass')
    test_string = preferred_string
    tries = 1
    while (not hass.states.async_available(test_string)):
        tries += 1
        test_string = f'{preferred_string}_{tries}'
    return test_string