MacBook randomly doesn't recognize the battery
After leaving my MacBook for a week (turned off, about 50% of battery) I started to have some problems with the battery. When I tried to power it up for the first time the discharged battery sign appeared. It made me a little bit surprised because, as it was turned off, it should last for the week without problem, but I plugged the charger and left it for a couple of hours. When I came back and powered up the MacBook, the black "no battery available" sign appeared. I performed SMC and PRAM reset many times, but nothing seemed to help for a longer period of time. I managed to have my battery been recognized again, but after 20 minutes of work it suddenly turned off without a warning. At first I thought that it could be problem with connections because I observed that I can make my battery recognized when the laptop is cold (after 2-3 minutes of work with charger plugged it shows up) and after disconnecting the charger I can work on battery for about 20 minutes (until MacBook gets a little bit warm), after this it turns off. As I am out of warranty I decided to open lower case and check battery connections (and look for any signs of something been fried because with the first run after week I think that I smelled this characteristic smell of burned electronics, but I am not sure about this so it can be just my imagination). But after opening I didn't find anything interesting. No loose connectors, no signs and smell of fried electronics. Only a lot of dust. I cleaned it thoroughly with compressed air and disconnected battery connector for 10 seconds. After this symptoms has changed. Now it doesn't turn off randomly after getting warm and it seems to work on the battery without a problem when I use it continuously. But after every sleep (even if I I close the hatch for 10 seconds), when I try to wake it up, "discharged battery" sign appears and I have to connect the charger to make it work. When it wakes up(yes, it wakes up as normal, every window, opened app is on its place) it shows black "no battery available" sign on the bar. After couple of minutes battery is recognized and from that moment everything seems to work as normal (until next sleep).
I also performed Apple Hardware Test(by pressing "D" while booting up) and Advanced Apple Hardware Test(command+D) with battery being recognized and not recognized, but the only output I get from this is "everything is ok" or "no battery" depending on case.
I am looking forward for your advices. Any help appreciated!