def extract_entity_ids(hass, service_call):
    if not (service_call.data and ATTR_ENTITY_ID in service_call.data):
        return []

    group = get_component('group')

    # Entity ID attr can be a list or a string
    service_ent_id = service_call.data[ATTR_ENTITY_ID]

    if isinstance(service_ent_id, str):
        return group.expand_entity_ids(hass, [service_ent_id])

    return [ent_id for ent_id in group.expand_entity_ids(hass, service_ent_id)]
Helper method to extract a list of entity ids from a service call.
dataset/ETHPy150Open home-assistant/home-assistant/homeassistant/helpers/service.py/extract_entity_ids