Yes, you need to treat the actual underlying condition causing issues. Lots of health issues interfere with sleep.
Muscle tension was another confounding factor. I was tense all the time. Treating muscle tension improved my symptoms, but it was only a band-aid.
Potassium deficiency can cause muscle tension or cramping and will also cause poor sleep.