async def home(request):
    """
    This initializes a call to pipette.home() which, as a side effect will:
        1. Check the pipette is actually connected (will throw an error if you
        try to home a non-connected pipette)
        2. Re-engages the motor
    :param request: Information obtained from a POST request.
        The content type is application/json.
        The correct packet form should be as follows:
        {
        'target': Can be, 'robot' or 'pipette'
        'mount': 'left' or 'right', only used if target is pipette
        }
    :return: A success or non-success message.
    """
    hw = hw_from_req(request)
    req = await request.text()
    data = json.loads(req)
    target = data.get('target')
    if target == 'robot':
        if ff.use_protocol_api_v2():
            await hw.home()
        else:
            hw.home()
        status = 200
        message = "Homing robot."
    elif target == 'pipette':
        mount = data.get('mount')
        if mount in ['left', 'right']:
            if ff.use_protocol_api_v2():
                await hw.home([Axis.by_mount(Mount[mount.upper()])])
                await hw.home_plunger(Mount[mount.upper()])
                status = 200
                message = 'Pipette on {} homed successfuly'.format(mount)
            else:
                pipette, should_remove = _fetch_or_create_pipette(hw,
                                                                  mount)
                pipette.home()
                if should_remove:
                    hw.remove_instrument(mount)
                status = 200
                message = "Pipette on {} homed successfully.".format(mount)
        else:
            status = 400
            message = "Expected 'left' or 'right' as values for mount" \
                      "got {} instead.".format(mount)
    else:
        status = 400
        message = "Expected 'robot' or 'pipette' got {}.".format(target)

    return web.json_response({"message": message}, status=status)
async def home ( request ) : hw = hw_from_req ( request ) req = await request . text ( ) data = json . loads ( req ) target = data . get ( 'target' ) if target == 'robot' : if ff . use_protocol_api_v2 ( ) : await hw . home ( ) else : hw . home ( ) status = 200 message = "Homing robot." elif target == 'pipette' : mount = data . get ( 'mount' ) if mount in [ 'left' , 'right' ] : if ff . use_protocol_api_v2 ( ) : await hw . home ( [ Axis . by_mount ( Mount [ mount . upper ( ) ] ) ] ) await hw . home_plunger ( Mount [ mount . upper ( ) ] ) status = 200 message = 'Pipette on {} homed successfuly' . format ( mount ) else : pipette , should_remove = _fetch_or_create_pipette ( hw , mount ) pipette . home ( ) if should_remove : hw . remove_instrument ( mount ) status = 200 message = "Pipette on {} homed successfully." . format ( mount ) else : status = 400 message = "Expected 'left' or 'right' as values for mount" "got {} instead." . format ( mount ) else : status = 400 message = "Expected 'robot' or 'pipette' got {}." . format ( target ) return web . json_response ( { "message" : message } , status = status )
This initializes a call to pipette.home() which, as a side effect will:
        1. Check the pipette is actually connected (will throw an error if you
        try to home a non-connected pipette)
        2. Re-engages the motor
    :param request: Information obtained from a POST request.
        The content type is application/json.
        The correct packet form should be as follows:
        {
        'target': Can be, 'robot' or 'pipette'
        'mount': 'left' or 'right', only used if target is pipette
        }
    :return: A success or non-success message.