Be sure you keep a good thick pillow between your knees when you sleep. I discovered this trick after my knee arthroscopy back in Feb. I couldn't stand the pain of the surgery knee "hanging" against the bottom knee. I could literally feel the lower bones slipping in the joint--very painful! Once I started sleeping with the pillow between the knee it didn't wake me up so much. When you turn over be sure to readjust the pillow. I found that I couldn't tolerate the good knee lying on top of the surgery knee, unless it was padded by my trusty pillow.
About the pain med--I'm not surprised that you are still needing pain medicine. If you ever watched a TKR you would gag (the first surgery I ever witnessed in nursing school was a TKR. I lasted only 10 minutes before I went down.) Try taking your pain med on a schedule even during the night. Set your clock to get up and take your medicine so your pain doesn't get out in front of the meds. It's so much harder to catch up to the pain once it gets a foothold.