I have found a partial solution, which has made a positive difference for me at least. A few weeks ago I installed the Sleep Cycle app on my iPhone (there are presumably equivalents for other platforms). It claims to measure your sleep quality by listening to your breathing. This is the graph it drew of my sleep last night:
Now, I actually thought I slept rather better last night than this implies; certainly I don't recall the moments of blurry consciousness around 0415 which the phone thinks I experinced. (Er, on a different topic, er, yesterday was an unusually sedentary day - I normally manage 7,000 steps between various stations, but was lucky with public transport despite the lack of new train services. 2,556 steps is pretty pathetic.)
Imperfect though the app's measurement is, it mitigates one of the psychological exacerbating factors of insomnia, where you lie awake worrying about how much the fact that you are lying awake will impact you at work and at home the next day. The knowledge that the app will measure your lack of sleep so precisely is in fact welcome reassurance that you don't need to worry about it so much, because the phone is measuring it.
The other thing is that because the app reminds you that it is running on the phone, it's another incentive to put the damn gadget down and try to go to sleep.
So, it may not work for everyone, and it may not work for you; I can only say that it's made a tangible difference for me.