I know it is an old question, but I just encoutered a similar problem and solved it, so here goes my solution for reference.
The laptop: Dell 5520
Problem: Only charging battery when laptop was off, started over night and day of work, came home turn it on to discover it was not charging unless...