Could you keep us updated? Even if you don't do so very often it would be very helpful!
OK, here is the update.
In my case I still suspect an issue related to chromecast casting. I think the issue was quite severe on SultanXDA Lineage OS 14.1 (June 7, 2017) that I was using. I noticed and sometimes I had several hours of phone being awake after casting (Netflix and some other apps). Later I have switched to Freedom OS (currently on 2.10 version). In regards to "sleeping", I think it behaves better. Even after casting sessions, it usually sleeps fine. It's not perfect though, because from time to time I do notice awake time being several times more than expected, but not as bad. This doesn't happen often and not easy for figure out. Again when checking for wakelocks, I couldn't see anything pointing to specific issue, but I still suspect casting problem. So to combat this I currently switched to "deep clear" options in recents (FreedomOS) and clear all recents once a day (sometimes once in 2-3 days). Not a perfect solution, but I do it before going to bed and fast app start up in the morning makes it sort of a fresh start that I don't mind too much. I would prefer not to clear recents, just because I think OS should be able to manage everything automatically, but I believe that "deep clear" does help to resolve issues with phone being awake when it shouldn't.
EDIT/UPDATE: Turns out that "deep clear" does too much "clearing" for my linking. I noticed that I was missing some notifications from app. Switched to "normal clear". Phone being awake after casting is still a bit of an issue (I think), but it is not as bad as it was on Lineage OS.
I restored/unfrozen pretty much all of the apps that I use. I keep frozen only apps that I use once a month or even less (for example Uber).
So far I haven't seen or been able to pinpoint any issues in following social apps: Instagram, FB Messenger, Whatsapp, Viber, Skype. I use browser for Facebook instead of an app (been doing it for a while now). I do not use Snapchat.
I'm on a fence about Tasker and profiles that I'm using. I have started using it again not long time ago and still trying to figure out if I can see any pattern related to sleep/awake time and battery performance.
As far as the ROM, with my kind of use, I think Sultan's Lineage OS 14.1 from June 7, 2017 (and supplied kernel) is a bit better optimized in terms of battery performance, but it is less consistent than Freedom OS (and stock kernel that comes with it), so I decided to stay on Freedom OS for a while. Later will try again some other kernels.
I have Magisk 12 in core mode. I believe some modules can cause issue, though I didn't test much thoroughly. Once there will be a stable release of 13, I will try several modules again. I hope my usage and awake/sleep behavior will keep being consistent enough to notice any unusual patterns.
Still hoping for lower lever solution that can more accurately pinpoint what's keeping phone awake in some cases. Until a better solution, I think statistics gathering is a best way to see what could be the problem with performance.
---------- Post added at 12:07 PM ---------- Previous post was at 11:32 AM ----------
This hardly helps, because your screen time equals awake time. Very rarely people have display on for 4 hours straight and in those cases performance solely depends on what exact app you're using during these 4 hours (for example 3D gaming vs reading a book) and screen brightness. It is fairly easy to achieve 7+ hours of SOT in 12-18 hours. Try using your phone for 2-3 days without a charge and see if you can get 5+ SOT. The more screen ON/OFF cycles you have, the more difficult it is to get a good SOT. Ideally phone would go to sleep fairly fast after screen is OFF and won't be awake often or for long, so you can use phone without a charge for a long time.