1. Absolutely attend every post-surgery physical therapy session prescribed by the doctors.
2: when you do get on any pedal device, (bike, ebike, physical therapy lab recumbents) make sure the seat is way up so you don't over bend the affected joint. The Physical Therapist can measure the angles to determine the max bend as you recover. I see most inexperience riders want the seat down so they can reach the ground, big mistake.
3: a motor won't do you any good unless it's a fixie and it forces your legs to turn all the time. We all need more exercise (except maybe the olympic gold medal winners, the silver medalists should have trained more).
If you want more speed, get a faster bike and set it up right. There is nothing wrong with not keeping up with other riders. Keeping your heart rate up at a steady level is more important. A heart rate monitor is going to be more useful for riding.
up and walking right away is good. For young health people it takes about 6 weeks for the bones to heal and about 3 years for them to fully fill in. the more you stress bones, the stronger they get. Running & volley ball are the best for bone strength. The impact of hitting the ground is what does it. Swimming and cycling, while great for the heart, does nothing for bone strength. The older you get the longer it takes to fully grow in the bone around the implants. Postmenopausal women are the worst. 50% of older women who break hips die within a year because there are no decent bones left to attach implants to. Only laying in bed will kill anyone in a year. Some surgeons use a special epoxy to hold the implants in, others use ground up and sterilized donor bone as it helps regrow bone around the implant to hold it in place. Ask your surgeon what he uses.
My wife worked in orthopedic surgery for 35+ years on hip & knee replacements. She just cringes when she sees the patients smoking. Smoking slows recovery to a glacial pace, ie, expect to never fully recover. All the new wonder drugs for weight loss probably give you a better chance for weight loss. Cycling can work for weight if you ride a lot, like 10,000 miles a year and don't ride to bars every day. I lost about 15 pounds riding across the USA.
You may hear surgeons say joint replacements were never designed for physically active people. One of my former Ragbrai buddies had 2 knee replacements, 2 steel hips, a shoulder socket replaced, a pace maker and diabetic meds pump. That wasn't about to keep him off a bike. The only thing that stopped him from riding was dying. Many of the implants wear out after 10 - 15 years so you can look forward to having it redone later on.
I worked with the man who invented the bariatric surgery field. I had access to a data base of thousands of people who had surgery for weight loss. I plotted their weight for 10 years after. About 1/3 lost weight and kept it off for 10 years. About 1/3 lost weight and regained it all in 10 years. About 1/3 just waffled and never lost weight. So about 1/3 chance of it actually working. A nasty stat is the 30 day after surgery death rate. About 1 in 25 die within 30 days. Some surgeons were caught putting patients on life support until the 30 days was up so it wouldn't be considered their fault. It's a high risk procedure as most patients are very over weight and the anesthesia risks are higher.