I do something similar. If I'm not anxious but awake, I try to just visualise random stuff, random worlds. Somehow my brain is decent at that and I slowly drift off, though I sometimes get a jolt from reality.
Recently I found that when I'm anxious it's better to try and imagine doing a hobby. I just imagine myself trail running. Reduces anxiety, pushes me towards sleep.