I feel your pain, I suffered from insomnia too, for years. But I read a good book a while back that changed everything for me. It was this sleep study performed by UCLA on insomnia. After reading it I developed a routine that solved my problem. Here's what I learned.
1) working from home is horrible for your sleep, if you do work from home keep your work space as separate as possible from your living space.
2) keep your bedroom free of distractions (tv's, video games, desks, computers etc). Your bedroom should be for sleeping, a place for relaxing, not a place where you DO anything.
3) eat healthy, avoid caffeine, sugar and other stimulants, especially in the late afternoon through the evening.
4) excercise regularly, your body should be physically and mentally tired at the end of the day (in a good way).
5) as the daylight fades things should gradually get darker in your house/room. Start slowly dimming the lights. By the time you go to sleep your house should be dark. Very important that the house never gets brighter, only darker. Don't turn off the lights and then an hour later turns some back on so you can brush your teeth etc. your body is photo sensitive, we're programmed to fall asleep at night, light triggers stress hormones that keep you awake.
This one thing has been the most important part of sleeping well. I'm Very Very strict about this rule. I use night lights and candles in the bathroom etc so I don't ever have to turn the lights up once things start dimming.
5) realize that things won't change overnight, it'll take months weeks or months for your circadian rhythm to reset. Melatonin will help with this.
6) also, always go to sleep and wake up at the same time. Consistency is key.
Hope that helps. These things literally changed my life. I'm religious about my sleep rituals now because they actually work. I used to have panic attacks and severe anxiety over this. I used to fall asleep driving in the middle of the day. But not anymore, I've slept great for years.
I can't sleep WITHOUT the TV going. Preferably a rerun/binge of something I really like but have seen several times alteady. If the TV shuts off for any reason - time out. power outage, whatever, i wake up within minutes.
A major part of my problem is that after spending roughly 50 of my 70 years working nights as a musician or engineer/tech my circadian bio-clock is totally screwed. My natural clock is to wake around noon, go to work around 3PM, get off around 2:30-3:00 AM,and get to sleep around 3:30-4:00 AM.
Melatonin doesn't work because its primary function (in a sleep context) is to reinforce one's natural rhythm and my "natural" rhythm hasn't been for decades.
I find cannabis to be quite useful, but sometimes not completely adequate.
Honestly pot is probably the thing that comes closest to working, it’s just with my tolerance ( last described by an anesthesiologist as small adult elephant like) it gets damn expensive.
We're fortunate in that we have friends who are (legal) growers who give us quantities of free shake. Not great for smoking but does a good job for makng butter for cooking. One brownie after dinner....