@asyncio.coroutine
def async_handle_lock_service(service):
    'Handle calls to the lock services.'
    target_locks = component.async_extract_from_service(service)
    code = service.data.get(ATTR_CODE)
    for entity in target_locks:
        if (service.service == SERVICE_LOCK):
            (yield from entity.async_lock(code=code))
        else:
            (yield from entity.async_unlock(code=code))
    update_tasks = []
    for entity in target_locks:
        if (not entity.should_poll):
            continue
        update_coro = hass.loop.create_task(entity.async_update_ha_state(True))
        if hasattr(entity, 'async_update'):
            update_tasks.append(update_coro)
        else:
            (yield from update_coro)
    if update_tasks:
        (yield from asyncio.wait(update_tasks, loop=hass.loop))
Handle calls to the lock services.
@asyncio.coroutine
def async_handle_lock_service(service):
    
    target_locks = component.async_extract_from_service(service)
    code = service.data.get(ATTR_CODE)
    for entity in target_locks:
        if (service.service == SERVICE_LOCK):
            (yield from entity.async_lock(code=code))
        else:
            (yield from entity.async_unlock(code=code))
    update_tasks = []
    for entity in target_locks:
        if (not entity.should_poll):
            continue
        update_coro = hass.loop.create_task(entity.async_update_ha_state(True))
        if hasattr(entity, 'async_update'):
            update_tasks.append(update_coro)
        else:
            (yield from update_coro)
    if update_tasks:
        (yield from asyncio.wait(update_tasks, loop=hass.loop))